Game Development Reference
In-Depth Information
Pretty straightforward there — we create a window and two shapes (for both players) as
well as setting the socket to non-blocking mode so we can use it inside our game loop
without blocking it. Each shape fills each tile of the board perfectly. You might notice that
there isn't actually a board object anywhere and that is because we don't need it in such a
simple example. We can simulate a board by moving a player by exactly TILE_SIZE
pixels in any direction and create the illusion that the simulation is actually happening on
a tiled board.
Moving on to the game loop itself, the first thing we want to do is handle input:
This event switch is nothing special. It checks against button presses and assigns a value
to the move direction vector, depending on which key is pressed. We will later use that
direction vector in our game logic in the update frame. We also handle the
Event::Closed event as is customary.
In the game logic section of the loop we want to do two things:
Search WWH ::




Custom Search