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 hours ...
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'...
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;
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:
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 ...
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 ...
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 ...
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, ...
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)
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:
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 ...
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 ...
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.
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)/...
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 ...
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 ...
Some even use the Rectangle class:
float x, y, w, h;
It's just a choice of design, it doesn't really matter. If you're doing your own code, make what you feel more confortable. If you're using some API, framework or engine, or editing/modding a game, try to be consistently with the rest ...
You're overthinking it. Let's be real for a second here. What you're doing is creating a log flow that is essentially:
var result = randome.next(0, hittable.maxvalue)
foreach outcome in hittable
if result < outcome.max_value
// Reached the end of the table without finding an outcome
// Probably an error here, but let's fake ...
Vector v3 = v2 + v1;
There is now only one place in your code where you have to write, test and debug vector addition, as opposed to tens, hundreds or thousands.
Obviously vector addition is an overly simplistic example, but there are more complex vector operations and the same applies to those too.
If the tables are stable (don't change), you can get an O(1) sampling via the Alias Method. It almost certainly isn't worth the trouble if the tables are smaller, though.
As mentioned in PeterT's comment, you don't need to load all of your levels at once; instead you just load the current level and when the player transitions from that to a new one, you unload the current and load the new.
That gets you down to about 100mb (the raw per-level cost), but we can go lower still.
Consider a cube; right now you're defining each ...
Depending on your needs there are different data structure that you can use for geometry representation, before I answer your question I need to point out that geometric representation are usually chosen based on two basic factors,
Topological Requirements: this includes the types of meshes you are going to store, triangles only? n-polys ? regular, ...