CREATE : 1-D Pacman - Written by 14 yo Adam Askenazi
Click for Video
Adam Askenazi has demonstrated remarkable creativity and technical skill by developing a 1D PacMan game for the Scamp embedded computer.
This project showcases both the versatility of the Scamp and Adam’s ability to push the boundaries of minimalist game design. He has created an engaging and inventive adaptation that highlights the power of constrained computing. |
I received the following email from Manor Askenazi sharing the achievement of his son Adam. Adam is clearly a very bright young man.
Hi John,
Just wanted to send over this little bit of fan email: the Scamp3e board is the perfect platform for showing off Forth's minimal nature!
As background: a while back I was explaining the concept of a stack to my 14 year old son (Adam), which led to an introduction to Forth, which ultimately led to some coding on a Scamp3e :-)
To motivate the Forth coding we figured out a way to use the LEDs to implement a very rudimentary version of this surprisingly playable 1D Pac-Man game:
writeup: https://arstechnica.com/gaming/2024/01/1d-pac-man-is-the-best-game-ive-played-in-2024-so-far/
actual game: https://abagames.github.io/crisp-game-lib-11-games/?pakupaku
Obviously, Adam needed guidance, but he did write all the code himself (including the comments) and I tried not to "over-correct" his code (also, neither of us code Forth professionally :-)
Anyway, I attached the resulting code as well as a video of him running the game.
Thanks again for making the Scamp3e!
Best regards,
Manor.
--
Manor Askenazi, Ph.D.
Managing Member
Biomedical Hosting LLC
Just wanted to send over this little bit of fan email: the Scamp3e board is the perfect platform for showing off Forth's minimal nature!
As background: a while back I was explaining the concept of a stack to my 14 year old son (Adam), which led to an introduction to Forth, which ultimately led to some coding on a Scamp3e :-)
To motivate the Forth coding we figured out a way to use the LEDs to implement a very rudimentary version of this surprisingly playable 1D Pac-Man game:
writeup: https://arstechnica.com/gaming/2024/01/1d-pac-man-is-the-best-game-ive-played-in-2024-so-far/
actual game: https://abagames.github.io/crisp-game-lib-11-games/?pakupaku
Obviously, Adam needed guidance, but he did write all the code himself (including the comments) and I tried not to "over-correct" his code (also, neither of us code Forth professionally :-)
Anyway, I attached the resulting code as well as a video of him running the game.
Thanks again for making the Scamp3e!
Best regards,
Manor.
--
Manor Askenazi, Ph.D.
Managing Member
Biomedical Hosting LLC
Source code written by Adam:
\ 1-D Pacman by Adam Askenazi
variable me \ Player location
variable badguy \ Badguy location
variable count \ Counter that controls blinking
variable berry \ Berry location
variable showme \ Whether the player is shown (blinking)
variable showbadguy \ Whether the badguy is shown (blinking)
variable showberry \ Whether the berry is being shown (eaten)
variable berrycount \ Counter for when the berry returns
variable bguycounter \ Counter for the enemy speed cycle
variable bguymax \ Enemy speed cycle value
\ Turn off all leds
: ledsoff ( -- )
0
leds
;
\ Returns a random number that has only one bit turned on
: Shifts ( -- n )
1
15
random
and
for
2 *
next
;
\ Returns a location for the berry
: Berryplace ( -- n )
begin
Shifts berry !
berry @ me @ =
if
0
else
1
then
until
berry @
;
\ Returns a location for the Badguy
: Badguyplace ( -- n )
Shifts
256 <
if
1
else
32768
then
;
\ Renders enemy, player and berry using leds
: Render ( -- )
0
showme @
if
me @
or
then
showbadguy @
if
badguy @
or
then
showberry @
if
berry @
or
then
leds
;
\ One dimensional Pacman game
: Pacman ( -- )
cr
." Use the comma button to go left, period button to go right "
2000 bguycounter !
2000 bguymax !
1 showme !
1 showbadguy !
1 showberry !
128 me !
2000 count !
Badguyplace badguy !
Berryplace berry !
begin
( Blink control )
count @
dup
dup
1000 <
if
500 >
if
0 showme !
1 showbadguy !
else
0 showme !
0 showbadguy !
then
else
1500 <
if
1 showme !
0 showbadguy !
else
1 showbadguy !
1 showme !
then
then
( Counter Control )
dup
0=
if
drop
2001
then
1 -
count !
bguymax @ 500 >
if
bguycounter @
0=
if
bguymax @ 20 - bguymax !
bguymax @ bguycounter !
then
else
bguycounter @
0=
if
bguymax @ bguycounter !
then
then
bguycounter @ 1 - bguycounter !
( Me Movement code )
key?
if ( Key Check )
key
dup 44 =
if ( Left Check )
drop
me @ 32768 =
if ( Ending Check )
1 me !
else
me @ 2 * me !
then ( Ending Check )
else
dup 46 =
if ( Right Check )
drop
me @ 1 =
if ( Right end Check )
32768 me !
else
me @ 32768 =
if ( Mistake Check )
16384 me !
else
me @ 2 / me !
then ( Mistake Check )
then ( Right end Check )
else
drop 0
then ( Right Check )
then ( Left Check )
then ( Key Check )
( Berry Eating )
me @ berry @ =
if
0 showberry !
10000 berrycount !
then
( Badguy chasing )
showberry @
if
bguycounter @ 0=
if
badguy @ me @ u>
if
badguy @ 2 u/ badguy !
then
badguy @ me @ u<
if
badguy @ 2 * badguy !
then
badguy @ me @ =
if
cr
." You lose :( "
cr
." Press Q to exit and Press R to restart "
ledsoff
exit
then
then
else
bguycounter @ 0=
if
badguy @ me @ u<
if
badguy @ 1 <>
if
badguy @ 2 u/ badguy !
then
then
badguy @ me @ u>
if
badguy @ 32768 <>
if
badguy @ 2 * badguy !
then
then
badguy @ me @ =
if
cr
." You win!!! "
cr
." Press Q to exit and Press R to restart "
65535 leds
exit
then
then
then
( Berry counter )
showberry @ 0=
if
berrycount @ 1 - berrycount !
berrycount @ 0=
if
Berryplace berry !
1 showberry !
then
then
( Leds )
Render
0 ( Forever loop )
until
ledsoff
;
\ Runs Pacman and controls post-game quit and restart
: Runner ( -- )
begin
Pacman
begin
key
dup
113 =
if
ledsoff
drop
exit
then
114 =
until
0
until
;