mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2025-04-24 19:51:29 +00:00

* Create the Shopping Cart Lock app Will demonstrate tomorrow. Don't merge until I do 😁 * Fixes for HTotoo's comments 😎 * Improved audio the best I can. If nobody has any ideas to further improve high frequencies of the audio, the hardware may not be capable. I still need to check with line-out to better speaker to make sure it's not just the speaker, but it shouldn't be. * Compared against baseband_api.cpp - matched some things better but still playback seems to be missing higher fq sounds * renamed wav files to a more specific / less generic name * indentation + using variables instead of litteral names for wav files to use * indentation * Made a Snake game - enjoy * Code formatting. I always forget. * move to keep sort order * Update external.ld Sorry I should have also asked if there was any reason that address ranges 0xADDA0000--0xADDD0000 were skipped in external.ld. I assumed there wasn't so I changed it to be consecutive using the same 0x10000 step as the other modules. If there is any reason to skip them then we should add a comment to note it. Of course these are all just temporary address values used for linking and get overwritten by a kludgy "search & replace" during the build process. Resolves enhancement request #764 --------- Co-authored-by: gullradriel <gullradriel@no-mail.com> Co-authored-by: Mark Thompson <129641948+NotherNgineer@users.noreply.github.com>
71 lines
1.8 KiB
C++
71 lines
1.8 KiB
C++
/*
|
|
* ------------------------------------------------------------
|
|
* | Made by RocketGod |
|
|
* | Find me at https://betaskynet.com |
|
|
* | Argh matey! |
|
|
* ------------------------------------------------------------
|
|
*/
|
|
|
|
#include "ui_snake.hpp"
|
|
|
|
namespace ui::external_app::snake {
|
|
|
|
#include "snake.cpp"
|
|
|
|
SnakeView::SnakeView(NavigationView& nav)
|
|
: nav_{nav} {
|
|
add_children({&dummy});
|
|
game_timer.attach(&game_timer_check, 1.0 / 5.0);
|
|
}
|
|
|
|
void SnakeView::on_show() {
|
|
}
|
|
|
|
void SnakeView::paint(Painter& painter) {
|
|
(void)painter;
|
|
if (!initialized) {
|
|
initialized = true;
|
|
std::srand(LPC_RTC->CTIME0);
|
|
init_game();
|
|
}
|
|
}
|
|
|
|
void SnakeView::frame_sync() {
|
|
check_game_timer();
|
|
set_dirty();
|
|
}
|
|
|
|
bool SnakeView::on_key(const KeyEvent key) {
|
|
if (key == KeyEvent::Select) {
|
|
if (game_state == STATE_MENU || game_state == STATE_GAME_OVER) {
|
|
game_state = STATE_PLAYING;
|
|
init_game();
|
|
}
|
|
} else if (game_state == STATE_PLAYING) {
|
|
if (key == KeyEvent::Left) {
|
|
if (snake_dx == 0) {
|
|
snake_dx = -1;
|
|
snake_dy = 0;
|
|
}
|
|
} else if (key == KeyEvent::Right) {
|
|
if (snake_dx == 0) {
|
|
snake_dx = 1;
|
|
snake_dy = 0;
|
|
}
|
|
} else if (key == KeyEvent::Up) {
|
|
if (snake_dy == 0) {
|
|
snake_dx = 0;
|
|
snake_dy = -1;
|
|
}
|
|
} else if (key == KeyEvent::Down) {
|
|
if (snake_dy == 0) {
|
|
snake_dx = 0;
|
|
snake_dy = 1;
|
|
}
|
|
}
|
|
}
|
|
set_dirty();
|
|
return true;
|
|
}
|
|
|
|
} // namespace ui::external_app::snake
|