Tag Info

New answers tagged

3

This line: int num = TileNode z; You are declaring a TileNode with symbol z, but you are assigning that to an int. You can't assign a symbol declaration under any circumstances, so the compiler is yelling at you for it. It also doesn't make any sense; you probably want to assign that int to some property of z, right? This is doubly wrong because you ...


0

Give your tank a Property that Tracks where its Bounds are. Give all other objects a Bounds as well. Check against the two rectangles to see if they are binding. Rectangle rect1 = new Rectangle(x,y,width,height); Rectangle rect2 = new Rectangle(x,y,width,height); x and y would be your sprites location in the world (Vector2.X and Vector2.Y) Width and ...


0

If you have uncapped FPS, it should eat 100% of your CPU, but most probably you want cap FPS at some reasonable value, say 60 fps, basic implementation can be as follows: const unsigned int FPS = 60; const unsigned int DELAY_TIME = 1000 / FPS; unsigned int frameStart, frameTime; int spareTime; // your main loop while (bRunning) { frameStart = ...


0

Your answer to the collision problem is true/false. Instead you can differentiate between no collision, penetration of the object and touching the object. Then only disallow movement in the case of penetration, but allow touching. I'd also suggest you move the collision code out of your tank and GameObject. Tanks and GameObjects both really just contain a ...


1

The practical reason to enforce a maximum delta time is to keep your numerical integration from breaking down. An essential principle of numerical integrators is that the smaller the time delta, the smaller the error delta. A "perfect" integrator would have a time delta of zero and would be indistinguishable from an analytical solution (neglecting ...


1

This is, in general, a bad way to accomplish this goal. Just use the callback requestAnimationFrame. Otherwise you run the risk of wasting a ton of power and draining the user's battery faster (remember laptops and mobile are more prevalent than desktops these days, so performance and power usage matters!). The use of Date().getTime() is also wrong. This is ...


0

The major CON is inconsistency... If you do like most game programmers so and define motion in terms of distance per unit time, capping the delta per frame causes time to magically disappear, slowing down the motion and causing potentially visible artifacts when the render loop most needs to show as close to stable output as it possibly can. Changing the ...



Top 50 recent answers are included