Arduboy Magazine Vol.3

Page 31

Using & Making Images The best way for me to make images for the Arduboy is to use Windows Paint. If I wanted to trace an image I like, I save it, open it on Paint, resize it accordingly and trace it over with the pencil tool. Once done, it gets saved as a PNG file. When I was trying to make graphics using the ToChars tool, I g ot some errors when uploading a 71x71 pixel PNG file. That’s because the pixels need to be in multiples of 8! Hence it being called 8-bit. New Functions Do.. while If you want to display your own name after the Arduboy drop down logo, and only continue after you pressed the ‘A’ button, you can write: do{ } while( !arduboy.pressed(A_BUTTON) ); This function will make your code block (in this case your name displayed on screen) run until its condition is false. In this case our condition is the ‘A’ button, and will run only when the ‘A’ button is pressed (an exclamation mark means ‘not’). Once the condition is false it will exit the loop and move on to the next line of code.

Case After not having success with my if functions to get the backbone of my text game going, I posted it on the forum asking for help, and JO3RI replied with using the Case function. It provides a convenient alternative to the if when dealing with a multiple way branch. switch (gameProgress) { case GAME_INTRO: arduboy.println(“Press A to start!”); if (arduboy.justPressed(A_BUTTON)) gameProgress = GAME_START; break; case GAME_START: arduboy.println(“A: Player 1”); arduboy.println(“B: Player 2”); if (arduboy.justPressed(A_BUTTON)) gameProgress = PLAYER_ONE_WINS; else if (arduboy.justPressed(B_ BUTTON)) gameProgress = PLAYER_TWO_ WINS; break; case PLAYER_ONE_WINS: arduboy.print(“You Win!”); if (arduboy.justPressed(A_BUTTON | B_BUTTON)) gameProgress = GAME_ INTRO; break; case PLAYER_TWO_WINS: arduboy.print(“You Lose!”); if (arduboy.justPressed(A_BUTTON | B_BUTTON)) gameProgress = GAME_ INTRO; break; } In my code, the variable that needs to be checked is the progress of the game, and once the matching label is found, the next line of code will be run.

Hope this has been informative for users who are starting off! Check back next issue for more scribbled notes..

Page 31 of 40