Since PicoC has now functions for simple graphics and can detect button presses, why not try to write a small game?
Source - sokoban.c (https://bitbucket.org/hudson/magic-lantern/src/tip/scripts/sokoban.c)
Don't expect fancy graphics; it's just a basic demo from which - I hope - you can learn some nice scripting tricks.
(http://a1ex.magiclantern.fm/bleeding-edge/sokoban.png)
Feel free to add some new levels.
Quote from: a1ex on February 24, 2013, 10:47:55 PM
Since PicoC has now functions for simple graphics and can detect button presses, why not try to write a small game?
Could we please have Pong, complete mit "beep" sound and computer opponent :-) ? It's *the* classic and would really make a great ml demo, I saw you already have the more graphic routines added but not implemented. https://en.wikipedia.org/wiki/Pong
(http://upload.wikimedia.org/wikipedia/commons/thumb/f/f8/Pong.png/286px-Pong.png)
Properly the main reason for adding the drawing routines is, that some who had making a minigame in mind requested it - or am I wrong on that one? (I'm at least one of those).
Original pong isn't such a big deal once one has figured how to get smooth timing ;)
Or, instead of smooth timing, one may assume variable timing for simulation, and sync with the DIGIC clock (which is very accurate).
For Pong, the API lacks a method to detect keys in a non-blocking way (currently get_key is blocking until you press something). Other than that, shouldn't be very hard.
Wow
...And I was always afraid of the day that a EOS offers the possibility to play a game. ;-)
The new picoc functions and picoc in generally are really great and I'm sure that some good and helpful scripts will follow.
Didn't heard of sokoban yet, but it's really nice...
Timing for simple animations is not a problem at all :)
// Animation demo
void main()
{
console_hide();
set_gui_mode(1); // Play
fill_rect(0, 0, 720, 480, COLOR_EMPTY);
int x = 320;
int y = 240;
int r = 10;
int dx = 0;
int dy = 0;
while(1)
{
int key = last_key();
switch(key)
{
case LEFT:
dx--;
break;
case RIGHT:
dx++;
break;
case UP:
dy--;
break;
case DOWN:
dy++;
break;
}
fill_circle(x, y, r, COLOR_EMPTY);
x += dx;
y += dy;
// collisions are not exact
if (x < r) { x = r; dx = -dx; }
else if (x > 720-r) { x = 720-r; dx = -dx; }
if (y < r) { y = r; dy = -dy; }
else if (y > 480-r) { y = 480-r; dy = -dy; }
fill_circle(x, y, r, COLOR_WHITE);
sleep(0.01);
}
}
main();
Wonder how long it will take untill we can play tetris! :D
Great stuff here!
Tetris seems like the game to have. Perfect for the arrow keys and wasting time.
Only problem when thinking about Tetris is that get_key is currently blocking :(
Tetris makes no fun if you have to move Blocks down manually...
F5, see the sticky post ;)
last_key() is not blocking
Just wanted to edit my post! ;)
sorry for old reply, but i discovered the sokoban game in the 600d audio built, and i dont have solution for the last (6) level !!!