Tap away 30 numbers game (iPad for now)
Posted: Sat Mar 21, 2015 8:52 pm
This game came from playing with my Bluelines demo.
30 sprites (numbers) fly around the screen and you must tap them in order (1 to 30) to remove them from the screen as fast as possible. If you tap the wrong number the game ends.
See if you can beat my best score. 53 seconds! I'll post a screenshot when I can.
- Dav
30 sprites (numbers) fly around the screen and you must tap them in order (1 to 30) to remove them from the screen as fast as possible. If you tap the wrong number the game ends.
See if you can beat my best score. 53 seconds! I'll post a screenshot when I can.
- Dav
Code: Select all
'Tap away 30 numbers game
'Tap them in order, from 1 to 30
'Tap the numbers as fast as possible
'Can you beat my score? 53 seconds!
'Coded by Dav, March/2015
graphics
shadow on
option base 1
best=999999 'no real score yet
'----
start:
'----
'get screen size
sw=screen_width() ! sh=screen_height()
'dont show screen writes
refresh off
'draw a background image
draw size 2
for a = 1 to 1975 step 10
x2= cos(a*360) * (sh/2)
y2= sin(a*360) * (sh/2)
r=rnd(255) ! g=rnd(255) ! b=rnd(255)
draw color r/255,g/255,b/255
draw line sw/2,sh/2 to sw/2+x2,sh/2+y2
next a
'grab image it as a sprite
sprite "s" scan 0,0,sw,sh
sprite "s" at -2000,-2000
sprite "s" show
sprites = 30 'number of sprites in game
'make all number sprites
draw color 1,1,1
draw font size 54
for t = 1 to sprites
'draw & scan them as sprite
fill color rnd(255)/255,rnd(255)/255,.5
fill rect 0,0 to 100,100
draw rect 0,0 to 100,100
draw text str$(t) at 20,20
sprite t scan 0,0,101,101
sprite t at -100,-100
sprite t show
next t
graphics clear 0,0,0 'clear screen
'place sprites randomly on screen
for t = 1 to sprites
sprite t at rnd(sw-100), rnd(sh-100)
next t
refresh on 'turn on screen writes
a=150000 'zoom value for background
speed = 15 'speed of sprites on screen
'my best score was on speed 16
dim x(sprites), y(sprites)
dim xd(sprites), yd(sprites)
dim xs(sprites), ys(sprites)
'show best score so far
if best<>999999 then
draw font size 24
draw color 1,1,1
b$="Best="&str$(best)&" "
dx=sw-(text_width(b$))
draw text b$ at dx,1
end if
'ready custom buttons
set buttons custom
set buttons font size 36
draw font size 54
draw color 1,0,0
fill color 1,1,0
timer reset
num=1 'number to touch (start at 1)
do
'show timer count
tim=integ(time())
button "time" text str$(tim) at 1,1
'show background sprite turning
sprite "s" alpha 40/100 ! a=a+1
sprite "s" at sw/2,sh/2 scale a/1000 angle a/100
'get users touch
get touch 0 as _x,_y
'check all sprites for hit (top to bottom)
for t = sprites to 1 step-1 ! t$=t
'if unser tapped a sprite...
if sprite_hit(t$,_x,_y) then
'if it's a correct number...
if t=num then
'play correct sound
notes set "9:tc6e6f6g6" ! notes play
'fly sprite up and away
do
get sprite t pos xx,yy
sprite t at xx+rnd(10),yy-10 angle u/100
pause .003 ! u=u+1
until yy<-100
'wait till sound stops playing
do!until notes_time() => notes_length()
sprite t$ hide
num=num+1 'goto the next number...
break
else
'user hit wrong number
notes set "123:wc1" ! notes play
'show number hit...
'sprite t$ order sprites+1
for g= 1 to 300 step 10
sprite t$ at _x,_y scale g/50 'angle g
pause .03
next g
sprite t$ hide
'drop all sprites down
gosub dropsprites
tx$="Wrong Number!"
dx=sw/2-(text_width(tx$)/2)
draw text tx$ at dx,sh/2
notes set "111:h(d3fa)(dga#)(dfa)"
notes play ! 'pause 3
do !a=a+1
sprite "s" at sw/2,sh/2 scale a/1000 angle a/100
until notes_time() => notes_length()
goto start
end if
end if
'move sprites...
'right side
if x(t) > sw-116 then
xd(t)=0 ! xs(t)=rnd(speed)
end if
'left side
if x(t) < 16 then
xd(t)= -1 ! xs(t)=rnd(speed)
end if
'bottom
if y(t) > sh-116 then
yd(t)= 0 ! ys(t)=rnd(speed)
end if
'top
if y(t) < 16 then
yd(t) = -1 ! ys(t)=rnd(speed)
end if
if yd(t) then
y(t)=y(t)+ys(t)
else
y(t)=y(t)-ys(t)
end if
if xd(t) then
x(t)=x(t)+xs(t)
else
x(t)=x(t)-xs(t)
end if
sprite t at x(t),y(t)
next t
'done them all?
if num>sprites then goto done
if screen_width()<>sw then
sw = screen_width()
sh = screen_height()
end if
until 0
'play loser sound
notes set "111:h(d3fa)(dga#)(dfa)"
notes play
do!a=a+1
sprite "s" at sw/2,sh/2 scale a/1000 angle a/100
until notes_time() => notes_length()
goto start
done:
'play fanfare
notes set "90:i(eg#b)r(df#a)w(eg#b)"
notes play
'show winner notice
tx$="You did it! Yeah!"
dx=sw/2-(text_width(tx$)/2)
do !a=a+1
r=rnd(255)/255 ! g=rnd(255)/255
b=rnd(255)/255 ! draw color r,g,b
draw text tx$ at dx,sh/2
sprite "s" alpha 50/100
sprite "s" at sw/2,sh/2 scale a/1000 angle a/100
until notes_time() => notes_length()
if tim<best then best=tim
goto start
dropsprites:
'drops all number down off screen
for g = 1 to sprites
if sprite_visible(str$(g)) then
notes set "126:c4" ! notes play
do
get sprite g pos xx,yy
sprite g at xx,yy+14
pause .001
until yy > sh
end if
next g
draw color 1,1,1
return