Skip to main content
50 votes
Accepted

Use an instance or a class for game resources (wood,iron,gold)

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). Edit: To ...
Mario's user avatar
  • 8,497
38 votes

Benefit of using Vector2 data type over separate x & y variables

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, ...
Bálint's user avatar
  • 14.9k
30 votes

Use an instance or a class for game resources (wood,iron,gold)

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 ...
Philipp's user avatar
  • 121k
14 votes

Use an instance or a class for game resources (wood,iron,gold)

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 ...
wondra's user avatar
  • 4,930
14 votes

Benefit of using Vector2 data type over separate x & y variables

Compare the function signatures of both RotatePoints versions. Lone variables: ...
Stephane Hockenhull's user avatar
11 votes

Benefit of using Vector2 data type over separate x & y variables

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. ...
Raphael Schmitz's user avatar
8 votes

Benefit of using Vector2 data type over separate x & y variables

Operator overloading. 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, ...
Maximus Minimus's user avatar
6 votes
Accepted

What is the recommended way of storing large sets of organized, immutable data in Unity?

My preferred workflow here is to author the move data in a spreadsheet, then write an importer script in Unity that reads the spreadsheet and creates or updates a ...
DMGregory's user avatar
  • 135k
6 votes

How to store condition dependent item information in JSON

I wouldn't do this based on item name. Instead, I'd implement a system of modifiers to describe what an item does, something like... ...
DMGregory's user avatar
  • 135k
5 votes
Accepted

Appropriate Cache Friendly Associative Container For An Entity Component System

Do the simplest thing that works, especially early on. If you've ever seen videos of triple-A titles in alpha, you'll know how slow / buggy they are. This is normal; in fact, it's desirable. And it's ...
Engineer's user avatar
  • 30.1k
5 votes

How to better refactor loops in procedural world generation?

Building on the answer from @congusbonus, if you are committed to using a single variable in an array as you have shown, you can define each combination in such a way that encodes each direction as a ...
Ed Marty's user avatar
  • 5,229
5 votes
Accepted

How to efficiently store a large amount of data?

First of all, consider if it is actually necessary to break down the world into units of storage. 32x16x32x16x16x16 = 67,108,864 blocks. When each block is a 2 byte integer representing the type-ID, ...
Philipp's user avatar
  • 121k
4 votes
Accepted

Data Structures for Game State

This is sort of open ended, but I would generally recommend that you have a list of open quests, separate from your other state. When something interesting happens, you generate an event that ...
jasonb's user avatar
  • 56
4 votes
Accepted

Managing game progress - states, stages, or flags

While I can't speak to any game specifically, my first instinct would be to approach this using a graph. It sounds like something you have started doing, by your use of "stages", though maybe only ...
CLo's user avatar
  • 1,330
4 votes
Accepted

How to better refactor loops in procedural world generation?

Use four attributes instead of one for expressing the types of exits for a room. ...
congusbongus's user avatar
  • 14.8k
4 votes

What is the recommended way of storing large sets of organized, immutable data in Unity?

You might be able to solve this by turning Move into a scriptable object as well. Those are much more stable in case of changes than POCOs in a serialized array of ...
Philipp's user avatar
  • 121k
3 votes

How to make compound data in Game Maker?

Because I don't have enough reputation to comment, I'm submitting an answer that further clarifies the previous answer regarding ds_map. Here's an example of ds_map in action: ...
derstander's user avatar
3 votes

How to structure a non rectangular maze

If your maze doesn't easily map to a 2d array, make it a graph. Make each cell a structure which includes where that cell is, how it looks and most importantly an array of references to the the cells ...
Philipp's user avatar
  • 121k
3 votes
Accepted

Where and how to store players collection in a computer card game?

The relational-database-by-the-book solution would have a table players, a table cards_owned_by_players, a table ...
Philipp's user avatar
  • 121k
3 votes
Accepted

Three levels deep composition (player<-character<-spell), with preset character+skill sets

This looks like a job for the Flyweight Pattern! (Closely related to the Type Object pattern) Here you separate the concept of a character archetype from the instance of the character itself. You ...
DMGregory's user avatar
  • 135k
3 votes

Managing complicated RPG character data

This is not a complete answer since as others here have noted, this question is rather broad. But I just wanted to give you some pointers. body parts / ...
Engineer's user avatar
  • 30.1k
3 votes

How do I implement Pokemon-style moves?

I see no other solution that having distinct 'moves' that are implemented in some mechanism that allows the 'owner' to invoke them without really knowing what those moves are. However, it is unclear ...
Steven's user avatar
  • 3,072
3 votes

How do I implement Pokemon-style moves?

An alternative to every move inheriting from an abstract class Move, you can instead use interfaces in C#. This has the advantage of allowing your move classes to be more flexible while still sharing ...
Varisius's user avatar
3 votes
Accepted

How should I store world data in a 2D grid sandbox game?

But here is the problem, since not every tile's size is 1x1, some may take 2x3 block size. and if i just put in Array this object's pointer, there is 6 same pointer will store in single array. Don't ...
Philipp's user avatar
  • 121k
3 votes

How can I load and store data for a large map in Unity

What I am specifically asking for is a way to store that data in any file format without needing to massively rework my game. It should be noted I am a novice level programmer and in way over my head,...
Kevin's user avatar
  • 6,494
3 votes

How is data regarding items in RPGs and other loot-based games stored and implemented?

We can't answer questions like "how do they do it" because, well, we don't know, and they won't tell us. We can help you figure out a few things, though. In software development in general, ...
Vaillancourt's user avatar
  • 16.3k
2 votes

How to program destructibles?

A rational approach might be to simplify your problem. This is a game, so most of the time there is no need for 100% accurate physics. Instead of tracking every single component that makes your ship, ...
rlam12's user avatar
  • 380
2 votes
Accepted

How to handle interaction with the map in a 2D-RPG-typed TileMap?

The method I would choose for this is to just use your existing map for as much as possible. This is essentially your first approach. Yes, you will need to figure out the IDs of trees (and other ...
milk's user avatar
  • 243
2 votes
Accepted

C++ Data structure pattern preferability?

The theory will tell that you're likely to get less cache misses (so 'more efficiency' w.r.t. response time) if your objects are close one to another in memory. This means that if you use an array, ...
Vaillancourt's user avatar
  • 16.3k

Only top scored, non community-wiki answers of a minimum length are eligible