Tag Info

Hot answers tagged

33

You don't want to send player input to the server. What you probably want to do is send an abstracted representation of what the player wants to do to the server, and then run the logic on there. Likewise you don't necessarily want to send back everything the client needs to do. For example, you can send some kind of message saying "NPC X died", and the ...


23

The way you have it described, somebody hacking a save file would just need to construct an MD5 hash of the save file values in order to bypass this measure. You need to add one thing in order for this to even really be worthwhile: a secret block of arbitrary data that's added to what you're hashing (both when creating the save and when validating it on ...


19

Your main problem is likely this: final int skipTicks = 1000 / ticksPerSecond; Dividing an int by an int returns an int (the value is rounded down if needed), so skipTicks evaluates to 16. 1000 / 16 is 62.5 so you get around this many ticks per second. To solve this the easiest solution would be to use a millisecondsPerTick variable (what you are ...


17

A turn based game is going to be governed by a state machine. Basically, you would lay out a series of states that can occur in a logical order. At a high level, a player's turn could be the start of a new state, followed by all the possible actions that are allowed during that turn. For instance State - change player it is now player 1's turn ...


13

Dialog trees are created with a directed graph structure. The graph is traversed based on the dialog decisions the player makes. The dialog options provided to the user come from the edges that define the paths to other dialog nodes. Directed graphs are a basic data structure. They can easily be implemented and you'll likely want to implement it ...


13

An idea is to use the Visitor design pattern. You need a Renderer implementation that knows how to render props. Every object can call the renderer instance to handle the render job. In a few lines of pseudocode: class Renderer { public: void render( const ObjectA & obj ); void render( const ObjectB & obj ); }; class ObjectA{ public: ...


11

I'm not really sure what card game you're trying to create, but here are the general steps I would go through: Write the rules down on paper - Write the rules down in bullet format. This will get your brain thinking about the logic, and will provide you with a handy reference to use later on. Rewrite the rules to follow the programmatic flow - Keep the ...


11

Use a List called "Path" to store the way-points that describe your path, and a doubly-linked list called "Snake" to store the moving objects and Path. The leading object defines new way-points as it travels. The following objects move along the path as defined by these way-points. Each object has a security zone defined by some distance. If the leading ...


10

If this is not an online tracked competitive type game: Let em hack away man. You can spend way too much energy on things like this when people who will play the game, will just play the game. Those who want to hack it will never really want to play it, they just want to hack it. If it is an online competitive type game: All you have to do is store the ...


10

There are several open-source projects of this nature, with different approaches to implementing the rules. Here is a blog entry from the creator of one of the more well-known MtG implementations, CardForge. It may not be a complete list, but it contains several open-source projects where you can simply browse the code, or visit the forums for specific ...


9

First of all, using a thread per entity (talking about OS threads here, not language specific cheap co-routines) is insane. A thread is expensive, for example it needs a stack which by default uses 1MB of address space. Thread switching is expensive costing thousands of CPU cycles. I wouldn't use multi threading at all in your main game logic. It adds a lot ...


9

The name "dialogue tree" is a bit misleading - they usually are simple directed graphs, not just trees. The basic data structure of such graphs usually consists of some kind of "data" for the nodes, which represent the points we are at in the conversation, and links from them to other nodes, which represent what is being said and done by the participants and ...


8

Flag all players as either stationary or moving, depending if they submitted a move this turn. Go through the list of moves. If two moves point to the same location, remove them from the list and set the players stationary. Loop through the list removing all moves that point to a stationary player or other obstacle. Do this repeatedly until the list ...


8

Well, you got answers but your real answer is at "try yourself". The things differ from game to game. I did couple of multiplayer games for some distributed network game design course. The most challenging was doing a realtime action game where many players involved and sending inputs like hell. When it comes to that point, everything becomes problem. As ...


8

You could go for a linked list, as others suggested. But basically, a snake is just a FIFO stack (sometimes called a queue) of grid coordinates: When the snake grows one bit, you just push an element on top of the stack When it moves one square, you push an element on top and pop an element off the bottom For an implementation of a queue in Objective-C, ...


7

Suppose you have a scene composed of a world, a player, and a boss. Oh, and this is a third person game, so you also have a camera. So your scene looks like this: class Scene { World* world Player* player Enemy* boss Camera* camera } (At least, that's the basic data. How you contain the data, is up to you.) You only want to update and ...


7

Alex's answer seems sufficient, but you say you want more detail, so here goes. First, why does the gameloop from http://www.koonsolo.com/news/dewitters-gameloop/ deliver its desired frame rate while your version doesn't? Because their integer division works out exactly: const int FRAMES_PER_SECOND = 25; const int SKIP_TICKS = 1000 / FRAMES_PER_SECOND; ...


6

My advice would be "don't". I've used a domain-specific markup language for game data. It was a pain. I spent days designing it, and then every week or two I needed to tweak it to add more features. At one point I realized I needed to automatically generate some of my game data, and I ended up writing a small program to parse input files in the markup ...


6

Programming Role-Playing Games with DirectX walks through creating what the author calls a "Mad Lib Script System", complete with the editor and the module of the engine that is created over the course of the book. It would surely take some tweaking and doesn't generate LUA so it might be totally unrelated to what you need, but on the other hand, its ...


6

First steps: write something and measure the performance. If the performance is not good enough then use the measurements you made to drive your optimization. Naively threading hundreds of entities is probably not the way to go. A scheduling queue might be, but only if you determined by your measurements above that the big OnAction() loop is tying you ...


6

The best practice for separating the game logic from game rendering is to have separate objects for the logic and the renderable, instead of having one large object that performs both tasks. The renderable object has a reference to the logic object so that it can update its own state (eg. animations) based on data in the game logic, or just query for ...


6

In your second paragraph, you bring up the issue of simultaneous movement. This is how objects move in the real world (obviously), and if you're interested in physical accuracy you would need to solve your collisions by taking this into account. However, this can very quickly become expensive, so most games perform collision detection by moving objects ...


6

Build a game and not an engine. You're getting caught up in what you inevitably get caught up in when you're making an engine: you have no specific requirements and you have no idea what will be most useful or pleasant, or how it will impact using your engine or your game's performance. You also have no way to know. Build a game, and the game will tell you ...


6

If you don't mind a reference to a book, there's an article named "Large-Scale Stack-Based State Machines" in Game Programming Gems 5 which provides a very good implementation of what you seek. I've been using a variation of it for the last few years, and like it a lot. Most of the insights that I got from that article, I've already talked about in this ...


6

Essentially you'll need two data structures (logical, intrusive, or real, depending on the rest of your code). The first will track the chains of objects, and the other the path. Chain Simply you need to know which objects are following other objects. In the simplest case this will simply be A follows B, but could include more followers. There is a ...


6

If I was the ball, I think I would try to 1. maximise the surface of contact with the ground and 2. maximise the vertical compression so that the release will generate forces that are normal to the ground: In your example, a lot of the energy stored by the compression is lost: if the released surface does not touch or hit the ground, it'll just move air ...


6

This is actually rather easy to do. Just get every item some bitmask to define how/where it can be equipped. Some random example: enum Slot { SLOT_NONE = 0x0000, SLOT_LEFT = 0x0001, SLOT_RIGHT = 0x0002, SLOT_TWOH = 0x0004, }; When trying to equip a weapon into a specific slot, you can check/compare flags to do different things: If ...


6

This depends on the combination of frameworks you are using. Sometimes a 2D game framework makes it very difficult to work with coordinates that are not bound to pixels because they were designed specifically for designers to think about their game world in pixel units. However, it's not a requirement. A game I'm currently working on relies on Box2D units ...


6

You are essentially creating 3 coordinate systems when you only need 2. The coordinate system for your grid is 0 to 800. Your "real" space is a normalized position from 0 to 1.0. And your "screen" space is measured from 0 to whatever your pixel width is. You will always need to convert between some kind of world coordinate system and screen space in order ...


5

I don't think dispatching events is the best way to do this. If you have a high amount of draw calls the event dispatching and listeners will have a lot of overhead. Also you might want to look what classes you have, because you don't need a class for each color of square, or even if there are more properties. You could be able to just store the color or ...



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