2011-08-11 15:42:30 +00:00
|
|
|
/*
|
2011-08-12 21:08:45 +00:00
|
|
|
* coded by Thammi from Pentagon Village
|
2011-08-11 15:42:30 +00:00
|
|
|
*/
|
|
|
|
|
2011-08-11 15:35:17 +00:00
|
|
|
#include <sysinit.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#include "basic/basic.h"
|
|
|
|
#include "basic/random.h"
|
|
|
|
#include "lcd/display.h"
|
|
|
|
#include "usetable.h"
|
|
|
|
|
|
|
|
void randomizeCoin(int* x, int* y);
|
|
|
|
|
|
|
|
void ram() {
|
|
|
|
int key;
|
|
|
|
|
|
|
|
int d = 0;
|
|
|
|
int x = RESX / 2;
|
|
|
|
int y = RESY / 2;
|
|
|
|
|
|
|
|
int p = 0;
|
|
|
|
int q, r;
|
|
|
|
|
|
|
|
randomizeCoin(&q, &r);
|
|
|
|
|
|
|
|
lcdClear();
|
|
|
|
|
|
|
|
while (1) {
|
|
|
|
// display
|
|
|
|
lcdSetPixel(q, r, p % 3);
|
|
|
|
lcdSetPixel(x, y, 1);
|
|
|
|
lcdDisplay();
|
|
|
|
|
|
|
|
// wait
|
|
|
|
|
|
|
|
delayms(20);
|
|
|
|
|
|
|
|
// input
|
|
|
|
|
|
|
|
key=getInputRaw();
|
|
|
|
|
|
|
|
switch(key) {
|
|
|
|
case BTN_RIGHT:
|
|
|
|
d = 3;
|
|
|
|
break;
|
|
|
|
case BTN_LEFT:
|
|
|
|
d = 2;
|
|
|
|
break;
|
|
|
|
case BTN_UP:
|
|
|
|
d = 0;
|
|
|
|
break;
|
|
|
|
case BTN_DOWN:
|
|
|
|
d = 1;
|
|
|
|
break;
|
|
|
|
case BTN_ENTER:
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// step
|
|
|
|
|
|
|
|
if(d > 1) {
|
|
|
|
x = (RESX + x + (d & 1) * 2 - 1) % RESX;
|
|
|
|
} else {
|
|
|
|
y = (RESY + y + d * 2 - 1) % RESY;
|
|
|
|
}
|
|
|
|
|
|
|
|
p += 1;
|
|
|
|
|
|
|
|
// collision
|
|
|
|
|
|
|
|
if(x == q && y == r) {
|
|
|
|
p += 99;
|
|
|
|
randomizeCoin(&q, &r);
|
|
|
|
} else if(lcdGetPixel(x, y)) {
|
|
|
|
lcdClear();
|
2011-08-12 19:41:06 +00:00
|
|
|
lcdPrint("You failed,");
|
|
|
|
lcdNl();
|
|
|
|
lcdPrint(nickname);
|
|
|
|
lcdPrint("!");
|
|
|
|
lcdNl();
|
2011-08-11 15:35:17 +00:00
|
|
|
lcdNl();
|
|
|
|
lcdPrintInt(p);
|
|
|
|
lcdPrintln(" points");
|
|
|
|
lcdDisplay();
|
|
|
|
|
|
|
|
while(getInputRaw() != BTN_ENTER);
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
void randomizeCoin(int* x, int* y) {
|
|
|
|
// WARNING: if you are really got at this the game freezes :D
|
|
|
|
for(;;) {
|
|
|
|
*x = getRandom() % RESX;
|
|
|
|
*y = getRandom() % RESY;
|
|
|
|
|
|
|
|
if(!lcdGetPixel(*x, *y)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|