TGC Codebase Backup



Shooting 2d by Francesco

6th May 2004 13:08
Summary

Shoot with mouseclick.



Description

Look out for deers!



Code
                                    ` This code was downloaded from The Game Creators
                                    ` It is reproduced here with full permission
                                    ` http://www.thegamecreators.com
                                    
                                    start:

score=0
start=start+1
if file exist("rank")=0 then make file "rank"
if start=1
dim rank(1)
rank(1)=-1
endif
load array "rank",rank(0)



verystart:

sync on : hide mouse : sync rate 0
load bitmap "target.bmp",1
get image 1,2,2,250,250
delete bitmap 1
load bitmap "fire.bmp",3
get image 3,20,20,160,160
delete bitmap 3
load bitmap "pointer.bmp",4
get image 4,0,0,40,40
delete bitmap 4
load bitmap "tree.bmp",5
get image 5,0,0,640,480
delete bitmap 5
load bitmap "deer.bmp",6
get image 6,20,0,114,100,6
delete bitmap 6
load bitmap "blood.bmp",7
get image 7,0,0,113,135
delete bitmap 7
sprite 1,x,50,1
sprite 6,130,370,6
sprite 7,sprite x(6),sprite y(6),7
sprite 5,0,0,5
set sprite 5,0,1
size sprite 1,100,100
sprite 2,mousex(),mousey(),1
size sprite 2,5,5
hide sprite 2
cls
load bitmap "background.bmp",2
set current bitmap 0
sprite 4,mousex()-20,mousey()-20,4
sprite 3,mousex()-35,mousey()-35,3
size sprite 3,80,80
size sprite 7,60,60
hide sprite 3
j#=80
k=370
n#=timer()
return




do
sprite 2,mousex(),mousey(),1
sprite 3,mousex()-35,mousey()-35,3
sprite 1,x,y,1
sprite 4,mousex()-20,mousey()-20,4
sprite 5,0,0,5
sprite 6,j#,k,6
sprite 7,sprite x(6)+29,sprite y(6)+5,7
sprite 8,sprite x(1)+15,sprite y(1)+19,8
if x>540 then ui=1
if ui=1
x=x-rnd(100)/20
else 
x=x+rnd(100)/20
endif
if x<10 then ui=0
if x<10 then p=0
if y>150 then p=1
if p=1
y=y-rnd(100)/20
else 
y=y+rnd(100)/20
endif
if y<10 then p=0

if j#<81
hide sprite 7
pj=0
a=rnd(6000)
else
a=a
endif
if a<60
if j#>150 and hgf=0 then ul=1
if ul=1
j#=j#-0.5
else 
j#=j#+0.5
endif
if j#<80 then ul=0
endif

rem
if sprite collision(2,5)=1
pt=1
else
pt=0
endif

rem
if sprite collision(2,5)=1 and mouseclick()=1
pi=1
else
pi=0
endif

rem
if mouseclick()=1 and sprite collision(2,1)=1 and pl=0 and pt=0
score=score+1
pp=pp+1
show sprite 3
else
hide sprite 3
endif
if pp<60 and pp>0 then score=score : pl=1 : pp=pp+1
if pp=>10 then pp=0 : pl=0

rem
if mouseclick()=1 and sprite collision(2,0)=4 and pf=0 or pi=1 and pf=0
score=score-1
ll=ll+1
show sprite 3
endif
if ll<60 and ll>0 then score=score : pf=1 : ll=ll+1
if ll=>10 then ll=0 : pf=0

rem
if mouseclick()=1 and sprite collision(2,6)=1 and pj=0 and pt=0
score=score+10
show sprite 7
pj=1
show sprite 3
endif


ink 0,0
box 440,10,630,70
set text to italic
set text font "mistral"
set text size 40
ink -255,0
text 445,15,"SCORE: "+str$(score)+""
box 440,90,630,150
ink 0,0
time=abs(((timer()-n#)/1000)-60)
text 445,95,"TIME: "+str$(time)+""
if time=0 then wait 300 : goto end
box 440,200,630,250
ink -255,0
set text size 30
text 445,200,"HIGH SCORE: "+str$(rank(1))+""
sync
cls
copy bitmap 2,0
if start=1 then gosub ranking
loop

ranking:
if score>rank(1)
rank(1)=score
endif
save array "rank",rank(1)
return

end:
for c=1 to 8
if sprite exist(c)=1
delete sprite c
endif
next c
cls -255
set text size 100
text 20,0,"YOUR SCORE: "+str$(score)+""
text 20,200,"HIGH SCORE: "+str$(rank(1))+""
wait 2000
goto start