Code: Select all
FrameLimit 60
SCREEN 400,350
Type AMMUS
Field obj
EndType
Type ZOMBI
Field obj
Field x
Field y
Field hp
EndType
Type HEALTTI
Field obj
Field hpplussa
EndType
FrameLimit 40 'rajoita nopeutta
kursori=LoadObject("media\target.bmp")
ukko=LoadObject("Media\soldier.bmp",72)
zomb1=LoadObject("Media\guy.bmp",72)
pati=LoadObject("Media\bullet.bmp")
hetti = LoadObject("Media\tatti.bmp")
ShowObject pati,OFF
ShowObject zomb1,OFF
ShowObject hetti,OFF
hp = 200
spawn = 4
score = 0
späwn = 0
Repeat
ShowMouse OFF
PositionObject kursori, MouseWX(), MouseWY()
PointObject ukko, kursori
If KeyDown(17) Then TranslateObject ukko, 0, 3
If KeyDown(31) Then TranslateObject ukko, 0, -3
If KeyDown(30) Then TranslateObject ukko, -3, 0
If KeyDown(32) Then TranslateObject ukko, 3, 0
'Ammu-systeemi. Vain, jos ase on ladattu
If MouseDown(1) And reload=0 Then
luoti.AMMUS = New(AMMUS) 'luo uusi ammus
luoti\obj=CloneObject(pati) 'tee klooni
'asetetaan pati samaan paikkaan
CloneObjectPosition luoti\obj,ukko
'käännetään pati samaan suuntaan
RotateObject luoti\obj, ObjectAngle(ukko)+Rand(-2,2)
reload=5 'aseen lataus
EndIf
'päivitä aseen lataaminen
If reload>0 Then reload=reload-1
If späwn > 0 Then
b.HEALTTI = New(HEALTTI)
b\obj = CloneObject(hetti)
b\hpplussa = Rand(10, 30)
PositionObject b\obj, Rand(-200,200), Rand(-175,175)
späwn - 1
EndIf
If Spawn > 0 Then
z.ZOMBI = New(ZOMBI)
z\obj = CloneObject(zomb1)
z\x = Rand(-1000,1000)
z\y = Rand(-1000,1000)
z\hp = 3
PositionObject z\obj, z\x, z\y
spawn - 1
EndIf
For z.ZOMBI = Each ZOMBI
If z\x < 200 Then z\x = Rand(-1000,1000)
If z\x > 200 Then z\x = Rand(-1000,1000)
PointObject z\obj, ukko
MoveObject z\obj, 2
If ObjectsOverlap(z\obj, ukko) Then hp - 1
If Timer()>spawneri+2500 Then
spawn + 1
spawneri = Timer()
EndIf
If Timer()>späwneri+10000 Then
späwn + 1
späwneri = Timer()
EndIf
For f.HEALTTI = Each HEALTTI
If ObjectsOverlap(ukko, f\obj) Then hp + f\hpplussa : DeleteObject f\obj : Delete f
Next f
For luoti.AMMUS = Each AMMUS
MoveObject luoti\obj,2
If ObjectsOverlap(luoti\obj, z\obj) Then z\hp - 1 : Delete luoti : DeleteObject luoti\obj
Next luoti
If z\hp < 1 Then
DeleteObject z\obj
Delete z
score + 1
z.ZOMBI = New(ZOMBI)
z\obj = CloneObject(zomb1)
z\x = Rand(-1000,1000)
z\y = Rand(-1000,1000)
If z\x < 200 Then z\x = Rand(-1000,1000)
If z\x > 200 Then z\x = Rand(-1000,1000)
z\hp = 3
PositionObject z\obj, z\x, z\y
EndIf
Next z
If hp < 0 Then Goto loppu
Text 0,0,"HP: " +hp+ " Tapot: "+score
SetWindow ""+FPS()
DrawScreen
Forever
loppu:
scroll = 200
Repeat
For z.ZOMBI = Each ZOMBI
ShowObject z\obj, OFF
ShowObject ukko, OFF
ShowObject kursori, OFF
Next z
Text 100,160,"Sait "+score+" tappoa!"
scroll-1
If scroll < 0 Then End
DrawScreen
Forever