![](/media/cache/profiles/fa1fc368935a59b748bec5e15aca97ea.jpg.50x50_q85.png)
This code contains the game Starship designed for the STM32F429i-DISC1 board. It requires a keyboard to play.
Dependencies: Starship LCD_DISCO_F429ZI USBHost mbed
Diff: Player.c
- Revision:
- 0:c9afe145b57b
- Child:
- 1:527a11035e0b
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Player.c Sun Sep 17 17:05:27 2017 +0000 @@ -0,0 +1,22 @@ +#include "Player.h" +void movePlayer(uint8_t x_vel, uint8_t y_vel) +{ + player.x_pos += x_vel; + player.y_pos -= y_vel; + if(player.x_pos<=0) + player.x_pos=0; + else if(player.x_pos>=LCD_WIDTH-PLAYER_WIDTH) + player.x_pos = LCD_WIDTH-PLAYER_WIDTH; + if(player.y_pos<=0) + player.y_pos = 0; + else if(player.y_pos>=LCD_HEIGHT-PLAYER_HEIGHT) + player.y_pos = LCD_HEIGHT-PLAYER_HEIGHT; +} +void updatePlayerTimers() +{ + player.rapidFireTimer = player.rapidFireTimer ? player.rapidFireTimer-1 : 0; + player.powerShotTimer = player.powerShotTimer ? player.powerShotTimer-1 : 0; + player.wideShotTimer = player.wideShotTimer ? player.wideShotTimer-1 : 0; + player.shieldTimer = player.shieldTimer ? player.shieldTimer-1 : 0; + player.gunTimer = player.gunTimer ? player.gunTimer-1 : 0; +} \ No newline at end of file