This game is probably the simplest game ever invented, it`s for DBC and it has exaclty 20 lines of code.
You have a button that always runs away from the mouse, and you have to click it. Every level up, the button gets smaller and faster. I made it to level 7... How about you?
Code:
rem *****************************************************
rem * Challange : Make a game in 20 lines of code *
rem *****************************************************
rem * * * * * * * * * * * * * * * * * * * * * * * * * * *
rem *****************************************************
rem * <PRESS> *
rem *****************************************************
rem * author : The Comet *
rem * date : 07,02,2008 *
rem *****************************************************
rem setup screen
sync on
sync rate 30
backdrop on
color backdrop 0
show mouse
rem generate button
create bitmap 1,80,25
for x=0 to 80
grbl=0
for y=0 to 25
ink rgb(255,grbl,grbl),0
dot x,y:inc grbl,10
next y
next x
set text font "arabic_charset"
set text size 20
ink rgb(0,255,0),0
center text 40,5,"PRESS"
get image 1,0,0,80,25
delete bitmap 1
sprite 1,rnd(screen width()),rnd(screen height()),1
rem main loop
start:
dist=30
speed=2
scale=300
ink rgb(255,255,255),0
level=1
clicks=0
do
rem if mouse gets close, move button away
x=sprite x(1)
y=sprite y(1)
mx=mousex()
my=mousey()
if mx>x and mx<x+sprite width(1) and my>y and my<y+sprite height(1)
if x<screen width()/2 then inc x,speed
if x>screen width()/2 then dec x,speed
if y<screen height()/2 then inc y,speed
if y>screen height()/2 then dec y,speed
else
if mx>x-dist and mx<x+sprite width(1)+dist and my>y-dist and my<y+sprite height(1)+dist
if mx<x+(sprite width(1)/2) then inc x,speed
if mx>x+(sprite width(1)/2) then dec x,speed
if my<y+(sprite height(1)/2) then inc y,speed
if my>y+(sprite height(1)/2) then dec y,speed
endif
endif
if x>screen width()-sprite width(1)-20 then x=screen width()-sprite width(1)-20
if x<20 then x=20
if y>screen height()-sprite height(1)-20 then y=screen height()-sprite height(1)-20
if y<20 then y=20
sprite 1,x,y,1
scale sprite 1,scale
rem mouse clicks button
if mouseclick()=1 and click=0
click=1
if mx>x and mx<x+sprite width(1) and my>y and my<y+sprite height(1)
repeat:until mouseclick()=0
inc clicks
do
center text 320,70,"You Clicked the button in " + str$(clicks) + " clicks! Press mouse to continue..."
center text 320,100,"Level Up!!"
if mouseclick()=1 then exit
sync
loop
inc dist,15
inc speed,2
scale=scale/4*3
clicks=0
inc level
sprite 1,rnd(screen width()),rnd(screen height()),1
else
inc clicks
endif
endif
if mouseclick()=0 and click=1 then click=0
rem scores
text 5,5,"Level:" + str$(level)
text 100,5,"Clicks:" + str$(clicks) + " of " + str$(speed)
rem lose if you clicked more than 60
if clicks>speed:time=0
do
center text 320,60,"LOSER!"
inc time
if time>100
goto start
endif
sync
loop
endif
rem refresh screen
sync
rem end of main loop
loop
compressed code:
rem *****************************************************
rem * Challange : Make a game in 20 lines of code *
rem *****************************************************
rem * * * * * * * * * * * * * * * * * * * * * * * * * * *
rem *****************************************************
rem * <PRESS> *
rem *****************************************************
rem * author : The Comet *
rem * date : 07,02,2008 *
rem *****************************************************
rem setup screen
sync on:sync rate 30:backdrop on:color backdrop 0:show mouse
rem generate button
create bitmap 1,80,25:for x=0 to 80:grbl=0:for y=0 to 25:ink rgb(255,grbl,grbl),0:dot x,y:inc grbl,10:next y:next x:set text font "arabic_charset":set text size 20:ink rgb(0,255,0),0:center text 40,5,"PRESS":get image 1,0,0,80,25
delete bitmap 1:sprite 1,rnd(screen width()),rnd(screen height()),1
rem main loop
start:
dist=30:speed=2:scale=300:ink rgb(255,255,255),0:level=1:clicks=0:do
rem if mouse gets close, move button away
x=sprite x(1):y=sprite y(1):mx=mousex():my=mousey():if mx>x and mx<x+sprite width(1) and my>y and my<y+sprite height(1)
if x<screen width()/2:inc x,speed:endif:if x>screen width()/2:dec x,speed:endif:if y<screen height()/2:inc y,speed:endif:if y>screen height()/2:dec y,speed:endif
else
if mx>x-dist and mx<x+sprite width(1)+dist and my>y-dist and my<y+sprite height(1)+dist
if mx<x+(sprite width(1)/2):inc x,speed:endif:if mx>x+(sprite width(1)/2):dec x,speed:endif:if my<y+(sprite height(1)/2):inc y,speed:endif:if my>y+(sprite height(1)/2):dec y,speed:endif
endif:endif
if x>screen width()-sprite width(1)-20:x=screen width()-sprite width(1)-20:endif:if x<20:x=20:endif:if y>screen height()-sprite height(1)-20:y=screen height()-sprite height(1)-20:endif:if y<20:y=20:endif:sprite 1,x,y,1:scale sprite 1,scale
rem mouse clicks button
if mouseclick()=1 and click=0:click=1:if mx>x and mx<x+sprite width(1) and my>y and my<y+sprite height(1):repeat:until mouseclick()=0:inc clicks
do:center text 320,70,"You Clicked the button in " + str$(clicks) + " clicks! Press mouse to continue...":center text 320,100,"Level Up!!":if mouseclick()=1 then exit
sync:loop:inc dist,15:inc speed,2:scale=scale/4*3:clicks=0:inc level:sprite 1,rnd(screen width()),rnd(screen height()),1
else:inc clicks:endif:endif:if mouseclick()=0 and click=1 then click=0
rem scores
text 5,5,"Level:" + str$(level):text 100,5,"Clicks:" + str$(clicks) + " of " + str$(speed)
rem lose if you clicked more than 60
if clicks>speed:time=0:do:center text 320,60,"LOSER!":inc time:if time>100:goto start:endif:sync:loop:endif
rem refresh screen
sync
rem end of main loop
loop
super compressed code:
sync on:sync rate 30:backdrop on:color backdrop 0:show mouse
create bitmap 1,80,25:for x=0 to 80:grbl=0:for y=0 to 25:ink rgb(255,grbl,grbl),0:dot x,y:inc grbl,10:next y:next x:set text font "arabic_charset":set text size 20:ink rgb(0,255,0),0:center text 40,5,"PRESS":get image 1,0,0,80,25
delete bitmap 1:sprite 1,rnd(screen width()),rnd(screen height()),1
start:
dist=30:speed=2:scale=300:ink rgb(255,255,255),0:level=1:clicks=0:do
x=sprite x(1):y=sprite y(1):mx=mousex():my=mousey():if mx>x and mx<x+sprite width(1) and my>y and my<y+sprite height(1)
if x<screen width()/2:inc x,speed:endif:if x>screen width()/2:dec x,speed:endif:if y<screen height()/2:inc y,speed:endif:if y>screen height()/2:dec y,speed:endif
else
if mx>x-dist and mx<x+sprite width(1)+dist and my>y-dist and my<y+sprite height(1)+dist
if mx<x+(sprite width(1)/2):inc x,speed:endif:if mx>x+(sprite width(1)/2):dec x,speed:endif:if my<y+(sprite height(1)/2):inc y,speed:endif:if my>y+(sprite height(1)/2):dec y,speed:endif
endif:endif
if x>screen width()-sprite width(1)-20:x=screen width()-sprite width(1)-20:endif:if x<20:x=20:endif:if y>screen height()-sprite height(1)-20:y=screen height()-sprite height(1)-20:endif:if y<20:y=20:endif:sprite 1,x,y,1:scale sprite 1,scale
if mouseclick()=1 and click=0:click=1:if mx>x and mx<x+sprite width(1) and my>y and my<y+sprite height(1):repeat:until mouseclick()=0:inc clicks
do:center text 320,70,"You Clicked the button in " + str$(clicks) + " clicks! Press mouse to continue...":center text 320,100,"Level Up!!":if mouseclick()=1 then exit
sync:loop:inc dist,15:inc speed,2:scale=scale/4*3:clicks=0:inc level:sprite 1,rnd(screen width()),rnd(screen height()),1
else:inc clicks:endif:endif:if mouseclick()=0 and click=1 then click=0
text 5,5,"Level:" + str$(level):text 100,5,"Clicks:" + str$(clicks) + " of " + str$(speed)
if clicks>speed:time=0:do:center text 320,60,"LOSER!":inc time:if time>100:goto start:endif:sync:loop:endif
sync
loop
(File attached)
Please post some comments...
Oooooops!!! I accidentally formated drive c.