diff --git a/software/game/lcd.h b/software/game/lcd.h index 423f0c7..1a8e96f 100644 --- a/software/game/lcd.h +++ b/software/game/lcd.h @@ -15,9 +15,9 @@ alt_up_character_lcd_dev * char_lcd_dev; void initialize_lcd() { char_lcd_dev = alt_up_character_lcd_open_dev ("/dev/character_lcd_0"); if ( char_lcd_dev == NULL) - alt_printf ("Error: could not open character LCD device\n"); + alt_printf ("\nError: could not open character LCD device\n"); else - alt_printf ("Opened character LCD device\n"); + alt_printf ("\nOpened character LCD device\n"); alt_up_character_lcd_init (char_lcd_dev); } #endif /* LCD_H_ */ diff --git a/software/game/main.c b/software/game/main.c index e2ab89a..2ff76c3 100644 --- a/software/game/main.c +++ b/software/game/main.c @@ -13,7 +13,6 @@ #define keys (volatile char *) BUTTONS_BASE void init() { - initialize_lcd(); initialize_vga(); initialize_sdcard(); } @@ -22,30 +21,16 @@ int main(void) { alt_timestamp_start(); init(); + printf("\nSeed %d", (unsigned int)alt_timestamp()); + srand((unsigned int)alt_timestamp()); bool game_on = true; -<<<<<<< HEAD - srand((int)alt_timestamp()); + Player *player1 = construct_player(get_screen_name()); + printf("\nPlayer created with name %s, screen %s", player1->screen_name, get_screen_name()); + Map *map = construct_map(); -======= ->>>>>>> Moved test method from main() to test() - test(); - - //Player player1; - Map map; - Obstacle obstacle1, obstacle2; - - obstacle1.type = WALL; - set_coordinates(obstacle1, 0, 0); - - Map map; - Player player1; - char* phrases[PHRASES_COUNT] = {"Pow", "Nice Job", "You Suck", "", ""}; - - construct_player(&player1, get_screen_name()); - construct_map(&map, phrases, 10); - - while (player1.health != 0 && game_on) { + while (player1->health != 0 && game_on) { + printf("\nGame playing"); // read player controls // calc player next move // check interactions diff --git a/software/game/map.h b/software/game/map.h index 8530f99..edc1154 100644 --- a/software/game/map.h +++ b/software/game/map.h @@ -2,25 +2,25 @@ #define MAP_H_ #include "obstacle.h" + +/* Following info will usually come from a map structure in the sdcard */ #define PHRASES_COUNT 5 +#define MAP_VELOCITY 10 +char* phrases[PHRASES_COUNT] = {"Pow", "Nice Job", "You Suck", "", ""}; +/**/ typedef struct{ int graphics[640][240]; int velocity; char *phrases[PHRASES_COUNT]; - Obstacle obstacles []; + Obstacle * obstacles; } Map; -void construct_map(Map* map, char* phrases[PHRASES_COUNT], int velocity) { - Obstacle obstacle1, obstacle2; - - construct_obstacle(&obstacle1, WALL, 0, 0); - construct_obstacle(&obstacle2, POTION, 10, 10); - - map->velocity = velocity; +Map * construct_map() { + Map * map; + map->velocity = MAP_VELOCITY; memcpy(map->phrases, phrases, sizeof(phrases)); - map->obstacles[0] = obstacle1; - map->obstacles[1] = obstacle1; + map->obstacles = construct_obstacle(WALL, 100, 100); } #endif /* LCD_H_ */ diff --git a/software/game/obstacle.h b/software/game/obstacle.h index 6ffea7b..d62ad9e 100644 --- a/software/game/obstacle.h +++ b/software/game/obstacle.h @@ -10,24 +10,27 @@ typedef enum { WALL, - POTION + POTION, + WENCH, + CHEST, + COIN, + POISION } ObstacleType; typedef struct{ ObstacleType type; int coordinates_x; int coordinates_y; + struct Obstacle * next; } Obstacle; -void construct_obstacle(Obstacle* obstacle, ObstacleType type, int xpos, int ypos) { +Obstacle * construct_obstacle(ObstacleType type, int xpos, int ypos) { + Obstacle * obstacle; obstacle->type = type; obstacle->coordinates_x = xpos; obstacle->coordinates_y = ypos; -} - -void set_obstacle_coordinates(Obstacle *obstacle, int x, int y){ - obstacle->coordinates_x = x; - obstacle->coordinates_y = y; + obstacle->next = NULL; + return obstacle; } #endif /* OBSTACLE_H_ */ diff --git a/software/game/player.h b/software/game/player.h index 78bc0ec..d85e910 100644 --- a/software/game/player.h +++ b/software/game/player.h @@ -23,7 +23,8 @@ typedef struct{ int coordinates_y; } Player; -void construct_player(Player* player, char* screen_name) { +Player * construct_player(char* screen_name) { + Player * player; player->screen_name = screen_name; player->score = START_SCORE; player->time = START_TIME; @@ -32,8 +33,7 @@ void construct_player(Player* player, char* screen_name) { player->velocity_y = START_VELOCITY_Y; player->coordinates_x = START_COORDINATE_X; player->coordinates_y = START_COORDINATE_Y; - - printf("\nPlayer created with name %s ", player->screen_name); + return player; } void set_player_coordinates(Player* player) {