Yes. You should implement a system to load content outside your main engine.
Headers for succinct answers.
No. It does not consume too much time.
I think the question of whether it is a valid allocation of your limited time is moot; even if only for the fact that it will be a small portion of total project time.
You will spend hundreds (thousands) of ...
Go with the second approach, simply due to the fact that you can introduce new resource types or items at any time without having to rewrite or update code (data driven development).
To elaborate a bit more on why this is in general good practice, even if you're 100% sure some value won't ever change.
Let's take the console game example mentioned in ...
First of all, it's way less clutter. If you have a position, a velocity and an acceleration, that's already 6 variables you have to deal with, 9 in 3d.
Secondly, and this is the most important part, it grants you access to many ways to use or change them. For instance, getting the length of the vector, normalizing it, adding them together, dot product, ...
A rule of thumb is that you use different classes when objects require different code and instances of the same class when the objects only require different values.
When the resources have different game mechanics which are unique to them, it might make sense to represent them with classes. For example, when you have Plutonium which has a half-life time ...
This would depend on the game and the indexing structure used for the chunks. Though, at such a high level, it's not too likely it has much to do with memory or a specific performance enhancement. More than likely it's an arbitrary decision for sizing chunks in a predictable way. It allows for some counting and indexing tricks using bit shifting that wouldn'...
At first you see that your commands are in the form of a list, so your first instinct might be to recreate that structure, and each dwarf will run through that list in sequence. What I suggest though is to break the list into steps, with each step having prerequisite(s), and then you run the entire command in reverse. Let me demonstrate with an example:
One quick way to get key-value pairs in Unity's inspector is to define a serializable entry class, and then use an array or List<> of them. eg...
public class SpellAnimationMap : ScriptableObject
public class SpellAnimationEntry
public Spell spell;
public AnimationClip animation;
Test case of 500 players all communicating, that's 250K streams of information flying around at 20Hz. The internal bandwidth for that would be, assuming 100 bytes each message, about 500MB/sec. Sounds ambitious. Especially between processes.
If you segregate players to groups of 100, that lowers to 20MB/sec, and so on. Which is why MMOs have zones, and ...
Use one of the common space partitioning algorithms, such as a Quadtree, Octree, BSP tree, or even a simple Grid System. Each has their own pros and cons for each specific scenario. You may read more about them in these books.
Generally (or so I've heard, I'm not too familiar with the reasoning behind this) a Quadtree or Octree is better fit for outdoor ...
First, multiplying by powers of two is much cheaper than multiplying by an arbitrary number, since you can do it by bit shifting. Most of the time the compiler can do this for you, so whenever you write "* 16" in your code, the compiler actually does a shift by four, and you don't need to worry about it - you just need to give the compiler the opportunity by ...
The common terminology is "structure of arrays" (SOA) and "array of structures" (AOS) which come from C and is most often seen in terms of SIMD work.
Typically, the AOS approach is faster, if used appropriately, but SOA tends to be easier to work with (and hence optimizes for the more important quality - development time).
SOA, especially in Java, means ...
Compare the function signatures of both RotatePoints versions.
const float *in_x,
const float *in_y,
float s = sinf(angle);
float c = cosf(...
I would like to add there are two extra options:
Interface: you can consider it if the resource class would be just a "storage" for 5 integers and each other entity would have different logic regarding resources (e.g. player spend/loot, city produces resource). In that case you might not want a class at all - you merely wanted to expose that some entity has ...
How are you moving Quad Tree objects? The simplest (and slowest) method is to remove the object and re-insert it. The open-source XNA Quad Tree me and a friend made does a little bit of logic when an object moves:
If the object is still inside the same quad
if the object fits into a child quad
Add to child
move the object to the parent(...
Are associative arrays a good idea for games? Perhaps, depending on your needs.
However, you need to differentiate between comments about "associative arrays" and specifically about the class std::map.
Associative arrays are just some kind of data structure that allows you to associate one kind of value with another, such that you can ...
Why not both? There are times when you'll want to look to see if there's any NPC on a specific tile (such as for collision detection, as you mentioned), and other times when you'll want to iterate over all the NPCs in the world (such as for running their AI methods every frame).
A pointer per tile is not that much memory unless you're working on a memory-...
What you are looking for is Rooted Tree Isomorphism, which is a specialised version of the Graph Isomorphism, except for trees and the root node is fixed.
The explanation given in this assignment uses two properties:
Have the same number of levels (distance between root and leaf nodes)
Each level has the same number of nodes
Using these two properties, ...
Readability > Writeability
I feel like it's just slow me down and barely has any benefit other
than organizing your code.
You are correct in that it (slightly) slows you down writing that code. However, you write it once in the beginning and from then on everytime you come back you are going to read it. So optimizing the reading speed will do much more ...
This is a good question and the best answer I can give is that only experience can really tell you when it's a good idea to take the path that is more difficult/time-consuming. If anyone tells you you should ALWAYS do it the 'proper' way, then they are simply wrong.
You already understand that it is a tradoff. On one hand, hardcoding is so tempting because ...
If you can make sequences pretty general, there's not much of a spaghetti code.
In case of deliveries e.g.: WorkTask operates with a WorkPlan. Workplan says what kind of resource unit must pick, from what kind of house, using which walk animation, using which work animation, time to work and all such details. So in the end WorkTask might look like:
I don't think a path finder is necessary, just ray cast to each AI in the area, if there's a wall in the way, they don't hear it. This would work best with some sort of scene graph + spacial partitioning
2D hexagonal maps are a representation of spheres packed in a flat (2D) tray, with each hex centred on the equivalent sphere, and allow distances between cells to be determined to workable (for gaming purposes anyway) accuracy, just by counting the number of hex cells through which you step.
The equivalent 3D representation is the face-centred cubic (FCC)/...
You could use the TMX map format used by the Tiled editor (as well as several other map editors).
Even if you don't use Tiled yourself, the TMX format supports all the functionality you mentioned and it has several existing loaders/parsers for a variety of languages. It's also very easy to understand the format and extend it for your own game.
The real answer is just this: On a binary computer, powers of two are nice round numbers.
When a normal person needs to pick an arbitrary number for some purpose, they typically choose nice round numbers in the number system they're comfortable with, base 10. So they'll pick 10, 100, 1000, etc. Because they're simple and easy and don't require much ...
Quadtrees typically store and retrieve rectangles. A point is a specific case where width and height are zero. The following logic is used to find home for new rectangles in the tree, starting with the root node:
void Store(Rectangle rect)
if(I have children nodes)
bool storedInChild = false;
foreach(Node childNode in nodes)
Tiles and icons (even in UIs like window systems) are often in a size like 16x16 or 24x24 to make it easier to modify the tiles. Most times the tile size is a multiple of 8 because of the folowing reasons.
It is relatively easy to shrink a tile with the size 32x32 to 16x16 by simply putting 4 pixels together (e.g. create the median/average of the 4 pixels).
Is there some advantage to having each attribute laid out contiguously in memory?
It's better for cache locality of data access. Memory access is slowest part of all modern computing systems. As memory buses pull in multiple bytes in "cachelines" and most modern CPUs will prefetch memory that it detects are being accessed contiguously, keeping data that is ...
If your argument against an array is "The world will be huge", then it's not about the data-structure, but rather about memory constraints. If your world is so large, that it doesn't fit into memory with a 2D array, then it won't fit into any other data-structure.
Instead you would have to implement a (file-)format, that allows loading chunks (or sectors) ...
What you're talking about is data-driven programming.
For small projects, it may not be worth the time investment, as there are often much more important features that you could improve.
However, data driven programming can be VERY easy to implement. If you're serious about it, you should probably use XML, JSON, or YAML, but you can also use plain text ...