Game Development Reference
In-Depth Information
Gun is a little bit different. It follows mouse cursor. To determine the angle we had to use
some math. The formula to get angle in degrees is arctan(delta_x / delta_y) *
180 / PI . You can see it explained in more detail on stackoverflow .
Run it and stroll around the island. You can still move on water and into the darkness, away
from the map itself, but we will handle it later.
$ ruby 02-warmup/player_movement.rb
See that tank hiding between the bushes, ready to go in 8 directions and blow things up
with that precisely aimed double cannon?
Tank moving around and aiming guns
Game Coordinate System
By now we may start realizing, that there is one key component missing in our designs.
We have a virtual map, which is bigger than our screen space, and we should perform all
calculations using that map, and only then cut out the required piece and render it in our
game window.
There are three different coordinate systems that have to map with each other:
1.
Game coordinates
2.
Viewport coordinates
3.
Screen coordinates
Search WWH ::




Custom Search