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 4DGL-uLCD-SE MMA8452
Diff: compost_pile.cpp
- Revision:
- 1:4421c1e849e9
- Parent:
- 0:95264f964374
--- a/compost_pile.cpp Mon Mar 29 21:17:26 2021 -0400 +++ b/compost_pile.cpp Fri Apr 09 20:44:48 2021 +0000 @@ -9,6 +9,7 @@ //================================================================== #include "compost_pile_private.h" +#include "player_public.h" COMPOST compost_record[NUM_PILE]; int tallest_pile_height; @@ -16,25 +17,48 @@ // See the comments in compost_pile_public.h void compost_pile_init() { - + COMPOST initialCompost; + initialCompost.y = 127; + initialCompost.width = 11; + initialCompost.height = 2; + for (int i = 0; i < NUM_PILE; i++) { + compost_record[i] = initialCompost; + compost_record[i].x = i*11+6; + } + tallest_pile_height = 2; + draw_compost(); } COMPOST compost_get_info(int index){ - + return(compost_record[index]); } void compost_add(int index) { - + if (index < NUM_PILE) { + compost_record[index].height += 8; + } + if (compost_record[index].height > tallest_pile_height) { + tallest_pile_height = compost_record[index].height; + } + if (player_get_info().y > 127 - tallest_pile_height) { + player_moveUp(); + } } void draw_compost(void){ - + COMPOST c; + for (int i = 0; i < NUM_PILE; i++) { + c = compost_record[i]; + uLCD.filled_rectangle(c.x, c.y-c.height, c.x+c.width, c.y, GREEN); + } + return; } -int get_compost_tallest_height() { - +int get_compost_tallest_height(void){ + return tallest_pile_height; } -int get_compost_height(int index) { -} \ No newline at end of file +int get_compost_height(int index){ + return compost_record[index].height; +}