Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed wave_player mbed-rtos 4DGL-uLCD-SE SDFileSystem
player.cpp
00001 #include "player.h" 00002 #include "missile.h" 00003 00004 void draw_player_object(int blk_x, int blk_y, int player_color, int p_width, int p_height) 00005 { 00006 uLCD.filled_rectangle(blk_x,blk_y,blk_x+p_width,blk_y+p_height,player_color); 00007 } 00008 00009 void erase_player(int blk_x, int blk_y, int p_width, int p_height) 00010 { 00011 uLCD.filled_rectangle(blk_x,blk_y,blk_x+p_width,blk_y+p_height,BACKGROUND_COLOR); 00012 } 00013 00014 void player_init(player_t * g, int blk_x, int blk_y, int color) 00015 { 00016 g->player_blk_x = blk_x; 00017 g->player_blk_y = blk_y; 00018 g->player_color = 0x00FF00; 00019 g->player_height = 8; 00020 g->player_width = 8; 00021 g->status = PLAYER_ALIVE; 00022 } 00023 00024 void player_show(player_t * g) 00025 { 00026 draw_player_object(g->player_blk_x, g->player_blk_y, g->player_color, g->player_width, g->player_height); 00027 } 00028 00029 void player_erase(player_t *g) 00030 { 00031 erase_player(g->player_blk_x, g->player_blk_y, g->player_width, g->player_height); 00032 } 00033 00034 int check_player(player_t * g, missile_t * h) 00035 { 00036 int player_died = 0; 00037 if (g->status == PLAYER_ALIVE 00038 && ((h->missile_blk_x >= g->player_blk_x) && (h->missile_blk_x <= (g->player_blk_x + g->player_width)))) 00039 { 00040 player_erase(g); 00041 g->status = PLAYER_DEAD; 00042 player_died = 1; 00043 h->status = ENEMY_MISSILE_EXPLODED; 00044 } 00045 00046 return player_died; 00047 }
Generated on Fri Jul 15 2022 11:23:44 by
1.7.2