STICKS and STONES
This is a little game I knocked up last night.
A little circle accelerates towards the mouse position on screen. While controling this circle you have to
avoid the flying, spinning, growing and shrinking 'sticks' or 'stones'.
To get
points, you have to
click on the sticks or stones as they float across screen. But beware, every second the mouse is over the sticks and stones, the player circle is accelerating towards it on a crazy collision course!
you only have 3 lives to get the highest score possible.
Download here:
www.lukeoc.co.uk/temp/sns.zip
Its no media, and I've posted as code to save download of a big fat file.
Run in windowed 800x600
` sticks and stones
` setup
sync on
sync rate 100
set text font "arial"
set text size 18
start:
go=0
repeat
cls
mx#=mousex():my#=mousey()
ink RGB(255,0,255),0
sx#=screen width()/2:sy#=screen height()/2+60
` title
restore title
for n=1 to 54
ink RGB(255,0,255),0
if n>20 then ink RGB(0,255,0),0
if n>31 then ink RGB(0,128,255),0
read x1#
read y1#
read x2#
read y2#
line x1#,y1#,x2#,y2#
next n
ink RGB(166,166,166),0
if abs(mx#-sx#)<text width("Sticks?")/2 and abs(my#-(sy#+text height("Sticks?")/2))<text height("Sticks?")/2
ink RGB(255,255,255),0
if mouseclick()=1 then go=1:game=1
endif
center text sx#,sy#,"Sticks?"
ink RGB(166,166,166),0
if abs(mx#-sx#)<text width("Stones?")/2 and abs(my#-(sy#+text height("Stones?")/2+40))<text height("Stones?")/2
ink RGB(255,255,255),0
if mouseclick()=1 then go=1:game=0
endif
center text sx#,sy#+40,"Stones?"
sync
until go=1
restore colours
lives=3
score#=0
dim px#(20):dim py#(20):dim pa#(20):dim pr#(20)
dim psx#(20):dim psy#(20)
dim r#(20):dim g#(20):dim b#(20)
dim pvx#(20):dim pvy#(20):dim ps#(20)
` 2d game
if game=0
stones:
` player init
x#=screen width()/2:y#=screen height()/2
position mouse x#,y#
for i=1 to 20
if rnd(1)=0
px#(i)=0-(2*screen width())*(-1)^(rnd(1))
py#(i)=rnd(screen height())
else
px#(i)=rnd(screen width())
py#(i)=0-(2*screen height())*(-1)^(rnd(1))
endif
pa#(i)=rnd(360)
pr#(i)=40+rnd(40)
pvx#(i)=(0.15+rnd(5)/10)*(-1^rnd(1))
pvy#(i)=(0.15+rnd(5)/10)*(-1^rnd(1))
ps#(i)=0
next i
` time
time#=timer()
do
dc#=7
cls
set cursor 0,0
ink RGB(255,255,255),0
score#=int(score#)
print "lives: "+str$(lives)
print "score: "+str$(score#)
mx#=mousex():my#=mousey()
acc#=0.0015*dc#
go=1
if go=1
a#=atanfull(mx#-x#,my#-y#)
vx#=vx#+newxvalue(0,a#,acc#)
vy#=vy#+newzvalue(0,a#,acc#)
endif
x#=x#+vx#*dc#:y#=y#+vy#*dc#
if x#>screen width() then x#=screen width():vx#=0
if x#<0 then x#=0:vx#=0
if y#>screen height() then y#=screen height():vy#=0
if y#<0 then y#=0:vy#=0
vx#=vx#/(1.002^dc#)
vy#=vy#/(1.002^dc#)
` player
circle x#,y#,10
` obstacels
for i=1 to 8
ink RGB(255,255,255),0
if ps#(i)=1 then ink RGB(r#(i),g#(i),b#(i)),0
pa#(i)=pa#(i)+0.1*dc#
circle px#(i),py#(i),pr#(i)*(sin(pa#(i))+1)
px#(i)=px#(i)+pvx#(i)*dc#:py#(i)=py#(i)+pvy#(i)*dc#
if px#(i)<0-2*pr#(i) then px#(i)=screen width()+2*pr#(i):ps#(i)=0
if px#(i)>screen width()+2*pr#(i) then px#(i)=0-2*pr#(i):ps#(i)=0
if py#(i)<0-2*pr#(i) then py#(i)=screen height()+2*pr#(i):ps#(i)=0
if py#(i)>screen height()+2*pr#(i) then py#(i)=0-2*pr#(i):ps#(i)=0
` score
if mouseclick()=1 and ps#(i)=0
if sqrt((mx#-px#(i))^2+(my#-py#(i))^2)<pr#(i)*(sin(pa#(i))+1) then ps#(i)=1:score#=score#+10
if cols>=4 then restore colours:cols=0
read r#(i)
read g#(i)
read b#(i)
inc cols
endif
` die
if sqrt((x#-px#(i))^2+(y#-py#(i))^2)<pr#(i)*(sin(pa#(i))+1)+10
lives=lives-1
goto stones
endif
next i
if lives<0 then goto dead
sync
loop
else
` 2d game
sticks:
` player init
x#=screen width()/2:y#=screen height()/2
position mouse x#,y#
for i=1 to 20
if rnd(1)=0
px#(i)=0-(2*screen width())*(-1)^(rnd(1))
py#(i)=rnd(screen height())
else
px#(i)=rnd(screen width())
py#(i)=0-(2*screen height())*(-1)^(rnd(1))
endif
pa#(i)=rnd(360)
psx#(i)=10+rnd(30)
psy#(i)=100+rnd(100)
pr#(i)=sqrt(psx#(i)^2+psy#(i)^2)
pvx#(i)=(0.15+rnd(5)/10)*(-1^rnd(1))
pvy#(i)=(0.15+rnd(5)/10)*(-1^rnd(1))
ps#(i)=0
next i
do
dc#=7
cls
set cursor 0,0
ink RGB(255,255,255),0
score#=int(score#)
print "lives: "+str$(lives)
print "score: "+str$(score#)
mx#=mousex():my#=mousey()
acc#=0.0015*dc#
go=1
if go=1
a#=atanfull(mx#-x#,my#-y#)
vx#=vx#+newxvalue(0,a#,acc#)
vy#=vy#+newzvalue(0,a#,acc#)
endif
x#=x#+vx#*dc#:y#=y#+vy#*dc#
if x#>screen width() then x#=screen width():vx#=0
if x#<0 then x#=0:vx#=0
if y#>screen height() then y#=screen height():vy#=0
if y#<0 then y#=0:vy#=0
vx#=vx#/(1.002^dc#)
vy#=vy#/(1.002^dc#)
` player
circle x#,y#,10
` obstacels
for i=1 to 9
ink RGB(255,255,255),0
if ps#(i)=1 then ink RGB(r#(i),g#(i),b#(i)),0
pa#(i)=pa#(i)+0.05*dc#
` draw box
px#(i)=px#(i)+pvx#(i)*dc#:py#(i)=py#(i)+pvy#(i)*dc#
ba#=atanfull(psx#(i),psy#(i)):bdist#=sqrt(psx#(i)^2+psy#(i)^2)
x1#=newxvalue(px#(i),pa#(i)+ba#,bdist#):y1#=newzvalue(py#(i),pa#(i)+ba#,bdist#)
x2#=newxvalue(px#(i),pa#(i)-ba#,bdist#):y2#=newzvalue(py#(i),pa#(i)-ba#,bdist#)
x3#=newxvalue(px#(i),pa#(i)+ba#,-bdist#):y3#=newzvalue(py#(i),pa#(i)+ba#,-bdist#)
x4#=newxvalue(px#(i),pa#(i)-ba#,-bdist#):y4#=newzvalue(py#(i),pa#(i)-ba#,-bdist#)
line x1#,y1#,x2#,y2#
line x2#,y2#,x3#,y3#
line x3#,y3#,x4#,y4#
line x4#,y4#,x1#,y1#
if px#(i)<0-2*pr#(i) then px#(i)=screen width()+2*pr#(i):ps#(i)=0
if px#(i)>screen width()+2*pr#(i) then px#(i)=0-2*pr#(i):ps#(i)=0
if py#(i)<0-2*pr#(i) then py#(i)=screen height()+2*pr#(i):ps#(i)=0
if py#(i)>screen height()+2*pr#(i) then py#(i)=0-2*pr#(i):ps#(i)=0
` score
if mouseclick()=1 and ps#(i)=0
dist#=sqrt((mx#-px#(i))^2+(my#-py#(i))^2)
ta#=atanfull((mx#-px#(i)),(my#-py#(i)))
ta#=wrapvalue(ta#-pa#(i))
tx#=newxvalue(px#(i),ta#,dist#):ty#=newzvalue(py#(i),ta#,dist#)
if abs(tx#-px#(i))<psx#(i)+10 and abs(ty#-py#(i))<psy#(i)+10
score#=score#+10:ps#(i)=1
if cols>=4 then restore colours:cols=0
read r#(i)
read g#(i)
read b#(i)
inc cols
endif
endif
` die
dist#=sqrt((x#-px#(i))^2+(y#-py#(i))^2)
ta#=atanfull((x#-px#(i)),(y#-py#(i)))
ta#=wrapvalue(ta#-pa#(i))
tx#=newxvalue(px#(i),ta#,dist#):ty#=newzvalue(py#(i),ta#,dist#)
if abs(tx#-px#(i))<psx#(i)+10 and abs(ty#-py#(i))<psy#(i)+10
lives=lives-1:goto sticks
endif
next i
if lives<0 then goto dead
sync
loop
endif
dead:
repeat
cls
center text sx#,sy#-80,"GAME OVER"
center text sx#,sy#-40,"Final Score - "+str$(score#)
sync
until mouseclick()=1
goto start
colours:
data 0,255,0
data 255,0,255
data 0,128,255
data 255,255,0
title:
data 316,99,268,99
data 268,99,268,134
data 268,134,293,134,
data 293,134,293,166
data 293,166,234,166
data 308,123,353,123
data 329,123,329,179
data 377,122,377,160
data 430,118,397,118
data 397,118,397,144
data 397,144,429,144
data 442,112,442,176
data 442,135,490,135
data 478,135,478,102
data 490,135,490,165
data 538,117,514,117
data 514,117,514,128
data 514,128,534,128
data 534,128,534,143
data 534,143,511,143
data 364,223,364,195
data 364,195,390,195
data 390,195,390,223
data 364,208,390,208
data 400,217,400,200
data 400,200,422,200
data 422,200,422,217
data 454,205,436,205
data 436,205,436,216
data 436,216,459,216
data 459,220,459,190
data 306,247,286,247
data 286,247,286,285
data 286,285,316,285
data 316,285,316,310
data 316,310,274,310
data 321,254,354,254
data 337,254,337,297
data 363,266,404,266
data 404,266,404,286
data 404,286,363,286
data 363,286,363,266
data 414,286,414,255
data 414,255,451,255
data 451,255,451,290
data 484,262,460,262
data 460,262,460,304
data 460,304,487,304
data 460,281,479,281
data 518,246,500,246
data 500,246,500,270
data 500,270,526,270
data 526,270,526,291
data 526,291,511,291
Screenshots
Please give feedback
ENJOY