-
Notifications
You must be signed in to change notification settings - Fork 5
example.Cookies
Filippo edited this page Nov 23, 2019
·
1 revision
import femto.mode.Direct;
import femto.Game;
import femto.State;
import femto.input.Button;
import femto.palette.Psygnosia;
import femto.font.TIC80;
class Score extends femto.Cookie {
Score(){
super();
begin("test"); // name of the cookie, up to 8 chars
}
int score; // properties you want to save
}
class Main extends State {
static final var save = new Score(); // previous value is automatically restored
static final var screen = new Direct(TIC80.font()); // the screenmode we want to draw with
public static void main(String[] args){
Game.run( TIC80.font(), new Main() );
}
void init(){
screen.clear(0);
}
void update(){
if( Button.A.justPressed() ){
save.score = Math.random(0, 1000); // update the score
save.saveCookie(); // save it to eeprom
}
screen.setTextPosition( 0, 0 );
screen.textColor++;
screen.println("Score: "+save.score); // print the current score
}
}