# TheComet

Member

607

3902 Excellent

• Rank

• Interests
Art
Programming

• Github
TheComet93
• Twitch
TheComet93
1. ## Manual syntax trees

I thought this thing I wrote might be a worthy candidate for a coding horror. Expression* SymbolicMatrix::determinant3x3() const { /* * Given the matrix * * / a b c \ * A = | d e f | * \ g h i / * * The determinant can be calculated with: * * det(A) = (aei + bfg + cdh) - (gec + hfa + idb) * * The entries in the matrix are stored such that a=0, b=1, c=2, etc. */ return Expression::make(op::sub, // (aei + bfg + cdh) - (gec + hfa + idb) Expression::make(op::add, // aei + bfg + cdh Expression::make(op::add, // aei + bfg Expression::make(op::mul, // aei Expression::make(op::mul, // ae entries_[0]->clone(), // a entries_[4]->clone()), // e entries_[8]->clone()), // i Expression::make(op::mul, // bfg Expression::make(op::mul, // bf entries_[1]->clone(), // b entries_[5]->clone()), // f entries_[6]->clone())), // g Expression::make(op::mul, // cdh Expression::make(op::mul, // cd entries_[2]->clone(), // c entries_[3]->clone()), // d entries_[2*3+1]->clone())), // h Expression::make(op::add, // gec + hfa + idb Expression::make(op::add, // gec + hfa Expression::make(op::mul, // gec Expression::make(op::mul, // ge entries_[6]->clone(), // g entries_[4]->clone()), // e entries_[2]->clone()), // c Expression::make(op::mul, // hfa Expression::make(op::mul, // hf entries_[7]->clone(), // h entries_[5]->clone()), // f entries_[0]->clone())), // a Expression::make(op::mul, // idb Expression::make(op::mul, // id entries_[8]->clone(), // i entries_[3]->clone()), // d entries_[1]->clone()))); // b } All jokes aside, how would one make this look better?
2. ## C++ Writing char arrays (binary)

I'd add methods for doing that to you serializer/deserializer classes: class Deserializer { /* ... */ void readFloatArray(std::vector<float>* v) { size_t arraySize = readUInt(); // we saved the size so we know how much to read v->resize(arraySize); for (size_t i = 0; i < arraySize; ++i) v->push_back(readFloat()); } /* ... */ }; class Serializer { /* ... */ void writeFloatArray(const std::vector<float>& v) { writeUInt(v.size()); // save size, for reading back for (size_t i = 0; i < v.size(); ++i) writeFloat(v[i]); } /* ... */ }; Then, to read the 100 floats: File file; file.open("whatever.dat"); std::vector<float> myFloats; file.readFloatArray(&myFloats);
3. ## C++ Polymorphic ECS | error C2385: ambiguous access of 'set'

For some reason the compiler cannot resolve which base class set() is to be called (someone more experienced might be able to shed light on the exact issues here). The solution seems to be to do something like this: template <class ...Ts> class entity : public component<Ts>... { public: entity() {}; ~entity() {}; template <class U> void set(const U& data) { component<U>::set(data); } };

5. ## Newbie, Need Help..

If you were me and saw this thread with 1. An unhelpful title 2. A post that doesn't ask a question How would you respond? It's like going into a car repair shop without a car and saying "I have a problem..." and then just awkwardly standing there. Please ask an actual question next time.
6. ## Getter + dirty flag + "mutable"

@_Silence_ that would be less than optimal and defeating the purpose of the dirty flag in the first place. In practice, doSomethingThatChangesResult() can be called anywhere from 2 to thousands of times before getResult() is called. With your suggestion, the time consuming calculation would needlessly be performed thousands of times instead of just once.
7. ## Getter + dirty flag + "mutable"

I've run into this problem a few times in my own code and in code from open source projects and would like to hear your op-onyos about it. It basically looks like this: class Foo { float cachedResult_; bool dirty_; public: void doSomethingThatChangesResult() { dirty_ = true; /* ...*/ } float getResult() { if (dirty_) cachedResult_ = doComplexCalculation(); return cachedResult_; } }; The problem is that you cannot use Foo::getResult in any other methods that are const. As a client of this class, you don't necessarily care about whether the result is cached or not (or maybe you should be caring, and that is the core of this apparent issue?) Is it acceptable to make dirty_ and cachedResult_ mutable in exchange for making getResult() const?
8. ## Is there such a thing as cheap but quality voice acting?

I'm going to go ahead and say yes, there is such a thing. In the brief period of my life where I actually completed a game, I went looking for voice actors on youtube. I was pleased to find an overwhelming number of people who were pretty much unknown (they have 10-100 subscribers or something) and yet their voices sounded amazing. I found a girl to voice my female character for a total price of free, and it sounded really good.
9. ## Java game from 1998

I suggest hopping onto #graal on irc.stinkybear.net and asking the guy personally there.
10. ## Using DOT to Debug Data Structures

Hi! It's fairly stable at this point (as in, it doesn't crash, there are no memory leaks, it correctly calculates results in every situation). The biggest API change in the near future will be that positions and rotations are specified in local space rather than in global space (which is currently the case). Other than that I don't see the API changing. Functionally, the way it was designed introduces some major flaws (none of which you will not run into if you don't try to solve nested trees with multiple end effectors). I'm still working on getting those fixed.
11. ## C++ Object-oriented vs loop-based programming?

It should be pointed out that doing it this way will introduce new, harder to solve design issues into your code that can potentially explode into a huge mess. For instance: Draw order of different entities is no longer defined. Before, you could be certain that no matter how many Cars you added and removed and how many Boats you added and removed, all of your cars would always draw before boats. With the Entity base class, this is no longer the case. It could be that Cars and Boats and Boars and Goats are all interleaved in weird ways and thus rendered/updated as such. Why is this an issue? Well, if you want to put cars on your boats and properly calculate collision for this (for example), while updating one of your car entities, the boat your car is on is in an unknown state. Was the boat already updated? Or is it still waiting to be updated? Half of the time you will be calculating collisions using the previous frame's boat position, the other half of the time you will be using the correctly updated boat position. As a side-note: This is the fundamental flaw with ECS frameworks and why I've taken such a disliking towards them.
12. ## How to stay motivated?

I find the github issue tracker to be a powerful motivation tool, if you use it correctly. Stuffing a three layered cake into your mouth all at once will of course not end well, and the same is true for any programming project: If you try to think about how much you have yet to implement, you will be mentally overwhelmed. The issue tracker helps you break your project down into small manageable steps, and if you're using github, you can generate visual graphs of your progress and use milestones to see the progress of particular features in your game. It's a lot easier to motivate yourself when you can set goals and reach those goals. For instance, you could tell yourself that you will fix 2 issues a day, and when at the end of the day you were able to fix those two issues, you can smile to yourself and feel good about your accomplishment.
13. ## How do you balance gaming and game dev?

Everything has pretty much been said, but I'd like to share an idle observation. I'm fairly active in the GDNet online chat, enough to know pretty much everyone who talks there, and I've noticed that all of the people there who are good at making games are making games. Like, all the time. I've never seen them do anything else (be it gaming or other forms of goofing off). Those that are struggling with improving their coding skills and have been stuck in the same spot for years and seem to be asking the same questions over and over in the chat are those that also play a lot of games in their free time (or are only there for the lolz). It's really not enough to invest only 1-2 hours a day into coding and expect to improve beyond a basic Level. For me: I will immensely enjoy playing the occasional rare game. Half Life 2, Portal, StarCraft 1+2, WarCraft 3, Banjo Kazooie, to Name a few. But I'm not the person who can play games for longer periods of time. Even with the examples I mentioned, I had to turn them off after about an hour and go back to coding. My default mode on the computer is to write code. Everything else I do I consider to be "goofing off".