Second GBDK Example
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
#include <gb/gb.h> | |
#include "alpha.c" | |
void init(); | |
void checkInput(); | |
void updateSwitches(); | |
void main() { | |
init(); | |
while(1) { | |
checkInput(); // Check for user input (and act on it) | |
updateSwitches(); // Make sure the SHOW_SPRITES and SHOW_BKG switches are on each loop | |
wait_vbl_done(); // Wait until VBLANK to avoid corrupting visual memory | |
} | |
} | |
void init() { | |
DISPLAY_ON; // Turn on the display | |
set_bkg_data(0, 47, alpha); // Load 47 tiles into background memory | |
} | |
void updateSwitches() { | |
HIDE_WIN; | |
SHOW_SPRITES; | |
SHOW_BKG; | |
} | |
void checkInput() { | |
if (joypad() & J_B) { | |
// The B button was pressed! | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment