Tag Info

Hot answers tagged

35

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 ...


25

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 ...


14

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

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 ...


11

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 ...


10

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 ...


10

Yes, it does make sense. As you said it will make less load on the system, which is good for thermals, and other applications. However.... Your games logic should NOT depend on the updates per second. Therefore I recommebd you to take a look at deltatime, which will make your game independent of the updates per second. I recommend you to take a look at ...


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 ...


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

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

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

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

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

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

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 ...


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

Your title asks a different question than your body content. In the title, you ask why logic and rendering should be separated, but in the body you ask for implementations of logic/graphics/rendering systems. The second question has been addressed previously, so I will focus on the first question. Reasons for separating logic and rendering: The widely ...


6

Since Hearthstone is written in Unity it is trivial to decompile the scripts (because .NET), and this does in fact allow us to see the algorithm for deck building. The algorithm (found in RandomDeckMaker.GetChoices) is actually very simple. It basically tries to pick random cards to bring the deck to the following distribution: 12 class-specific cards ...


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 ...


5

You are asking for a concept of scenes inside one activity. This is as easy as creating an abstract scene or an interface that will have methods like renderMe() and onUpdate(long timeElapsed). Then in your engine or game-loop you simply render the current scene. How do you switch between scenes is upto you. You can have a governing class SceneManager. So how ...


5

I think this can be done amazingly easy with regular expressions (provided you can provide the gameboard as string). Once you have the board in stringform, use the following regex: (\w) //capture any letter (\1{2,}) //capture that letter again twice or more. The beauty of this is that it works on any number of items, and any amount of ...


5

To have the gun heat up quickly but reach its overheat threshold slowly, you could take the gun's current temperature into account in the heat dissipation, rather than having a constant rate of heat dispersion. That's actually how it works in the real world: the rate of heat / thermal transfer is proportional to the difference in temperature. Wikipedia has a ...


4

Well, there's pretty much no other way to do it - you're going to have to loop through and call think() for every entity at least once every few frames. You could put entities on their own thread, but then you have the whole state-synchronization nightmare, which is definitely not worth it. On a first look, this idea is reasonable, but it can take too ...


4

My recommendation is to look at the Python code for Constraint Satisfaction Problems (CSPs) provided with the AIMA project. They use a Dictionary (associative array/hash table) to keep track of valid constraints. Also, there are implementations of several algorithms used to solve CSPs, like min-conflicts and AC3. The code includes a sample Zebra problem as ...


4

Wow. This actually seems like a situation where old-school AI semantic webs, like Richard Bartle thought were going to be important to the future of games when he wrote Artificial Intelligence and Computer Games, would be useful. You basically have a couple of data lists (database tables, whatever), the first of which specifies rules about how things can ...


4

This should do: (((source-dest+360) mod 360)>180)?1:-1 The +360 is only necessary for languages with a fuzzy mod function. Note that most languages implement fuzzy mod.


4

There's no easy answer, without your knowing what sort of strengths and weaknesses you actually want... And I'm guessing this is part of the problem. You really don't need any fancy formulas (yet?). Start with simple arithmetic and take it from there. It's actually those very numbers that give your game a unique feel in terms of how it plays. Before you go ...


4

I'm a beginner too, but I just tackled this problem in my own game, so hopefully you will find this helpful: First off: you have screenOffsetY spelled as screenOffestY, with the e and s reversed. So I'm not sure if that was intentional or not. Secondly: Since there is only limited source code provided to base my answer on, I'm going to have to generalize ...


4

What you are basically talking about is Procedural Content Generation. Roughly, you want to use a randomizing algorithm to make a "map" of upcoming content, and then run a check over that map to look for problems like "This gap is too small and makes the level impossible." I found, of all things, a wiki dedicated to the topic, which also has some code ...



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