Tag Info

New answers tagged


You need to keep a enemy heading (direction) variable and only move the enemy along that direction. Slowly rotate the enemy heading to face where it actually wants to go but only a few degrees per frame. You move forward according to the dot product of the heading and where you should be heading. This prevents overshooting the target. The enemy will move a ...


Why not use an IF statement: IF ($power > $defence) { $totalDamage = $power - $defence; } else { $totalDamage = 0; }


I would recommend having something like this in your loop: if (<death check>) break; <death check> would probably best be suited to a method (to steal from Josh Petrie, Character.IsDead()) which does the actual checking and returns a boolean true if they are dead. What the break keyword does is immediately, unhesitatingly break out of the ...


You already have a game loop that (currently) runs "forever:" while (true) { ... do stuff ... } What you want to do instead is guard this loop with a variable that says if the game is done yet: bool done = false; while (!done ) { ... do stuff ... } Then, every time through the loop after you've checked for player input, drawn the map, et cetera, ...

Top 50 recent answers are included