Unify names
This commit is contained in:
@@ -25,7 +25,7 @@ typedef struct monster_struct
|
|||||||
|
|
||||||
|
|
||||||
static int8_t monster_find (monster_t *monsters, uint8_t num,
|
static int8_t monster_find (monster_t *monsters, uint8_t num,
|
||||||
uint8_t x, uint8_t y)
|
uint8_t x, uint8_t y)
|
||||||
{
|
{
|
||||||
uint8_t i;
|
uint8_t i;
|
||||||
|
|
||||||
|
|||||||
+11
-12
@@ -1,7 +1,7 @@
|
|||||||
/** @file gobble6.c
|
/** @file gobble6.c
|
||||||
@author M.P. Hayes
|
@author M.P. Hayes
|
||||||
@date 29 Sep 2013
|
@date 29 Sep 2013
|
||||||
@brief
|
@brief A simple game where a monster has to capture `things' that run away.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@@ -27,14 +27,13 @@
|
|||||||
|
|
||||||
int main (void)
|
int main (void)
|
||||||
{
|
{
|
||||||
uint16_t tick = 0;
|
uint16_t things_move_tick = 0;
|
||||||
uint16_t navswitch_tick = 0;
|
uint16_t navswitch_tick = 0;
|
||||||
uint16_t monster_flash_tick = 0;
|
uint16_t monster_flash_tick = 0;
|
||||||
bool running = 0;
|
bool running = 0;
|
||||||
bool game_over = 1;
|
bool game_over = 1;
|
||||||
int duration = 0;
|
int duration = 0;
|
||||||
|
|
||||||
|
|
||||||
system_init ();
|
system_init ();
|
||||||
navswitch_init ();
|
navswitch_init ();
|
||||||
led_init ();
|
led_init ();
|
||||||
@@ -47,7 +46,7 @@ int main (void)
|
|||||||
|
|
||||||
pacer_init (LOOP_RATE);
|
pacer_init (LOOP_RATE);
|
||||||
|
|
||||||
tinygl_text ("GOBBLE: PUSH TO START");
|
tinygl_text ("GOBBLE6: PUSH TO START");
|
||||||
|
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
@@ -70,13 +69,13 @@ int main (void)
|
|||||||
navswitch_update ();
|
navswitch_update ();
|
||||||
|
|
||||||
if (navswitch_push_event_p (NAVSWITCH_NORTH))
|
if (navswitch_push_event_p (NAVSWITCH_NORTH))
|
||||||
monster_move (0, -1);
|
things_monster_move (0, -1);
|
||||||
if (navswitch_push_event_p (NAVSWITCH_SOUTH))
|
if (navswitch_push_event_p (NAVSWITCH_SOUTH))
|
||||||
monster_move (0, 1);
|
things_monster_move (0, 1);
|
||||||
if (navswitch_push_event_p (NAVSWITCH_EAST))
|
if (navswitch_push_event_p (NAVSWITCH_EAST))
|
||||||
monster_move (1, 0);
|
things_monster_move (1, 0);
|
||||||
if (navswitch_push_event_p (NAVSWITCH_WEST))
|
if (navswitch_push_event_p (NAVSWITCH_WEST))
|
||||||
monster_move (-1, 0);
|
things_monster_move (-1, 0);
|
||||||
|
|
||||||
/* Pause/resume things running around. */
|
/* Pause/resume things running around. */
|
||||||
if (navswitch_push_event_p (NAVSWITCH_PUSH))
|
if (navswitch_push_event_p (NAVSWITCH_PUSH))
|
||||||
@@ -108,10 +107,10 @@ int main (void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Move the things. */
|
/* Move the things. */
|
||||||
tick++;
|
things_move_tick++;
|
||||||
if (tick >= LOOP_RATE / MOVE_RATE)
|
if (things_move_tick >= LOOP_RATE / MOVE_RATE)
|
||||||
{
|
{
|
||||||
tick = 0;
|
things_move_tick = 0;
|
||||||
|
|
||||||
if (running)
|
if (running)
|
||||||
{
|
{
|
||||||
@@ -126,7 +125,7 @@ int main (void)
|
|||||||
{
|
{
|
||||||
monster_flash_tick = 0;
|
monster_flash_tick = 0;
|
||||||
if (running)
|
if (running)
|
||||||
monster_toggle ();
|
things_monster_toggle ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ static bool thing_position_valid_p (tinygl_point_t pos)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void monster_move (int8_t dx, int8_t dy)
|
void things_monster_move (int8_t dx, int8_t dy)
|
||||||
{
|
{
|
||||||
int8_t other;
|
int8_t other;
|
||||||
tinygl_point_t newpos;
|
tinygl_point_t newpos;
|
||||||
@@ -98,13 +98,12 @@ void monster_move (int8_t dx, int8_t dy)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void monster_toggle (void)
|
void things_monster_toggle (void)
|
||||||
{
|
{
|
||||||
tinygl_pixel_set (things[0].pos, ! tinygl_pixel_get (things[0].pos));
|
tinygl_pixel_set (things[0].pos, ! tinygl_pixel_get (things[0].pos));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void thing_move (uint8_t this)
|
static void thing_move (uint8_t this)
|
||||||
{
|
{
|
||||||
uint8_t i;
|
uint8_t i;
|
||||||
|
|||||||
@@ -9,8 +9,8 @@ void things_create (void);
|
|||||||
|
|
||||||
void things_move (void);
|
void things_move (void);
|
||||||
|
|
||||||
void monster_move (int8_t dx, int8_t dy);
|
void things_monster_move (int8_t dx, int8_t dy);
|
||||||
|
|
||||||
void monster_toggle (void);
|
void things_monster_toggle (void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+11
-11
@@ -1,7 +1,7 @@
|
|||||||
/** @file gobble7.c
|
/** @file gobble7.c
|
||||||
@author M.P. Hayes
|
@author M.P. Hayes
|
||||||
@date 1 Oct 2013
|
@date 1 Oct 2013
|
||||||
@brief
|
@brief A simple game where a monster has to capture `things' that run away.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@@ -18,10 +18,10 @@
|
|||||||
|
|
||||||
#define DISPLAY_RATE 200
|
#define DISPLAY_RATE 200
|
||||||
|
|
||||||
#define MOVE_RATE 10
|
|
||||||
|
|
||||||
#define NAVSWITCH_RATE 50
|
#define NAVSWITCH_RATE 50
|
||||||
|
|
||||||
|
#define THINGS_MOVE_RATE 10
|
||||||
|
|
||||||
#define MONSTER_FLASH_RATE 5
|
#define MONSTER_FLASH_RATE 5
|
||||||
|
|
||||||
|
|
||||||
@@ -40,11 +40,11 @@ static void monster_flash_task (__unused__ void *data)
|
|||||||
{
|
{
|
||||||
/* Flash the monster. */
|
/* Flash the monster. */
|
||||||
if (running)
|
if (running)
|
||||||
monster_toggle ();
|
things_monster_toggle ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void things_task (__unused__ void *data)
|
static void things_move_task (__unused__ void *data)
|
||||||
{
|
{
|
||||||
/* Move the things. */
|
/* Move the things. */
|
||||||
if (running)
|
if (running)
|
||||||
@@ -60,13 +60,13 @@ static void navswitch_task (__unused__ void *data)
|
|||||||
navswitch_update ();
|
navswitch_update ();
|
||||||
|
|
||||||
if (navswitch_push_event_p (NAVSWITCH_NORTH))
|
if (navswitch_push_event_p (NAVSWITCH_NORTH))
|
||||||
monster_move (0, -1);
|
things_monster_move (0, -1);
|
||||||
if (navswitch_push_event_p (NAVSWITCH_SOUTH))
|
if (navswitch_push_event_p (NAVSWITCH_SOUTH))
|
||||||
monster_move (0, 1);
|
things_monster_move (0, 1);
|
||||||
if (navswitch_push_event_p (NAVSWITCH_EAST))
|
if (navswitch_push_event_p (NAVSWITCH_EAST))
|
||||||
monster_move (1, 0);
|
things_monster_move (1, 0);
|
||||||
if (navswitch_push_event_p (NAVSWITCH_WEST))
|
if (navswitch_push_event_p (NAVSWITCH_WEST))
|
||||||
monster_move (-1, 0);
|
things_monster_move (-1, 0);
|
||||||
|
|
||||||
/* Pause/resume things running around. */
|
/* Pause/resume things running around. */
|
||||||
if (navswitch_push_event_p (NAVSWITCH_PUSH))
|
if (navswitch_push_event_p (NAVSWITCH_PUSH))
|
||||||
@@ -104,7 +104,7 @@ int main (void)
|
|||||||
{
|
{
|
||||||
{.func = display, .period = TASK_RATE / DISPLAY_RATE},
|
{.func = display, .period = TASK_RATE / DISPLAY_RATE},
|
||||||
{.func = navswitch_task, .period = TASK_RATE / NAVSWITCH_RATE},
|
{.func = navswitch_task, .period = TASK_RATE / NAVSWITCH_RATE},
|
||||||
{.func = things_task, .period = TASK_RATE / MOVE_RATE},
|
{.func = things_move_task, .period = TASK_RATE / THINGS_MOVE_RATE},
|
||||||
{.func = monster_flash_task, .period = TASK_RATE / MONSTER_FLASH_RATE},
|
{.func = monster_flash_task, .period = TASK_RATE / MONSTER_FLASH_RATE},
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -119,7 +119,7 @@ int main (void)
|
|||||||
tinygl_text_mode_set (TINYGL_TEXT_MODE_SCROLL);
|
tinygl_text_mode_set (TINYGL_TEXT_MODE_SCROLL);
|
||||||
tinygl_text_dir_set (TINYGL_TEXT_DIR_ROTATE);
|
tinygl_text_dir_set (TINYGL_TEXT_DIR_ROTATE);
|
||||||
|
|
||||||
tinygl_text ("GOBBLE: PUSH TO START");
|
tinygl_text ("GOBBLE7: PUSH TO START");
|
||||||
|
|
||||||
task_schedule (tasks, 4);
|
task_schedule (tasks, 4);
|
||||||
|
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ static bool thing_position_valid_p (tinygl_point_t pos)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void monster_move (int8_t dx, int8_t dy)
|
void things_monster_move (int8_t dx, int8_t dy)
|
||||||
{
|
{
|
||||||
int8_t other;
|
int8_t other;
|
||||||
tinygl_point_t newpos;
|
tinygl_point_t newpos;
|
||||||
@@ -98,7 +98,7 @@ void monster_move (int8_t dx, int8_t dy)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void monster_toggle (void)
|
void things_monster_toggle (void)
|
||||||
{
|
{
|
||||||
tinygl_pixel_set (things[0].pos, ! tinygl_pixel_get (things[0].pos));
|
tinygl_pixel_set (things[0].pos, ! tinygl_pixel_get (things[0].pos));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,8 +9,8 @@ void things_create (void);
|
|||||||
|
|
||||||
void things_move (void);
|
void things_move (void);
|
||||||
|
|
||||||
void monster_move (int8_t dx, int8_t dy);
|
void things_monster_move (int8_t dx, int8_t dy);
|
||||||
|
|
||||||
void monster_toggle (void);
|
void things_monster_toggle (void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user