Created
January 31, 2020 12:05
-
-
Save ali1234/f4739c417381da4ba02623326a0c0224 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Update test | |
#include <unistd.h> | |
#include "32blit.hpp" | |
#include "../../../../../../usr/include/zconf.h" | |
uint16_t width = 160; | |
uint16_t height = 120; | |
uint32_t prev_buttons = blit::buttons; | |
uint32_t updates = 0; | |
void init(void) { | |
blit::set_screen_mode(blit::lores); | |
} | |
void update(uint32_t time) { | |
updates++; | |
} | |
void render(uint32_t time) { | |
if ((blit::buttons ^ prev_buttons) & blit::button::A) { | |
blit::set_screen_mode(blit::lores); | |
width = 160; | |
height = 120; | |
} | |
else if ((blit::buttons ^ prev_buttons) & blit::button::B) { | |
blit::set_screen_mode(blit::hires); | |
width = 320; | |
height = 240; | |
} | |
prev_buttons = blit::buttons; | |
static uint32_t renders = 0; | |
blit::fb.pen(blit::rgba(0, 0, 0)); | |
blit::fb.clear(); | |
blit::fb.pen(blit::rgba(255, 255, 255)); | |
for (int n = 0; n < width; n += 20) { | |
blit::fb.rectangle(blit::rect((renders + n) % width, 0, 1, height/2)); | |
blit::fb.rectangle(blit::rect((updates + n) % width, height/2, 1, height/2)); | |
} | |
renders++; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment