Code: Select all
FrameLimit 40
SCREEN 800,600
Type zombi
Field obj
Field hp
Field dmg
Field speed
Field score
Field id
EndType
Type bullets
Field obj
Field hp
Field dmg
Field speed
Field id
EndType
Type upgs
Field obj
Field hp
Field id
EndType
gun_sound=LoadSound("media\gun_pistol1.wav")
upg_sound=LoadSound("media\PowerUp.wav")
enemy_sound=LoadSound("media\zombie groan.wav")
map=LoadMap("media\cdm2.til","media\tileset.bmp")
hero=LoadObject("media\hero.bmp",32)
zombi=LoadObject("media\Zombi.bmp",32)
bullet=LoadObject("media\bullet.bmp",32)
upg=LoadObject("media\bullet.bmp")
topower=LoadObject("media\fireball.bmp")
tospeed=LoadObject("media\bigbullet.bmp")
medikit=LoadObject("media\Hp.bmp")
ShowObject topower,OFF
ShowObject tospeed,OFF
ShowObject bullet,OFF
ShowObject Zombi,OFF
ShowObject Hp,OFF
SetupCollision hero,map,1,4,2
hp=100
powupg=5
speedupg=3
Repeat
If hp>0 Then
CloneCameraPosition hero
MoveObject hero,UpKey()*6-DownKey()*4
TurnObject hero,LeftKey()*5-RightKey()*5
If KeyDown(CBKEYz) And reload<0
PlaySound gun_pistol1,40
newBullet.BULLETS= New(BULLETS)
newBullet\obj=CloneObject(bullet)
newbullet\dmg=powupg
newbullet\speed=speedupg
CloneObjectPosition newBullet\obj,hero
CloneObjectOrientation newbullet\obj,hero
MoveObject newBullet\obj,24
reload=15
SetupCollision newbullet\obj,map,1,4,2
EndIf
reload-1
For iBullet.BULLETS= Each BULLETS
If CountCollisions(ibullet\obj) Then ibullet\hp-32
MoveObject iBullet\obj,6
Next iBullet
If uusi>220
newupg.upgS= New(upgS)
newupg\obj=CloneObject(upg)
newupg\hp=100
newupg\id=Rand(1,3)
If Newupg\id=1 Then PaintObject newupg\obj,topower
If Newupg\id=2 Then PaintObject Newupg\obj,tospeed
If Newupg\id=3 Then PaintObject Newupg\obj,medikit
For y=1 To MapWidth()
For x=1 To MapWidth()
If GetMap2(2,x,y)=0 Then PositionObject newupg\obj,Rand(-600,500),Rand(-600,600)
Next x
Next y
uusi=0
EndIf
uusi+1
For iupg.upgS= Each upgS
If ObjectsOverlap(iupg\obj,hero) Then iupg\hp=-1
If iupg\hp<0 Then
PlaySound PowerUp
If iupg\id=1 Then powupg+5
If iupg\id=1 Then speedupg+4
If iupg\id=3 Then hp+50
DeleteObject iupg\obj
Delete iupg
EndIf
Next iupg
If luo>130
newzombi.zombiS= New(zombiS)
newzombi\obj=CloneObject(zombi)
For y=1 To MapWidth()
For x=1 To MapWidth()
If GetMap2(2,x,y)=0 Then PositionObject newzombi\obj,Rand(-600,500),Rand(-600,600)
Next x
Next y
newzombi\id=Rand(1,2)
If newzombi\id =1
newzombi\hp=Rand(90,110):newzombi\dmg=Rand(1,3):newzombi\speed=Rand(2,3):newzombi\score=Rand(10,20)
EndIf
SetupCollision newzombi\obj,map,1,4,2
luo=0
EndIf
luo+1
For izombi.zombiS= Each zombiS
sidle=Rand(-20,20)
If CountCollisions(izombi\obj) Then MoveObject izombi\obj,0,sidle
PointObject izombi\obj,hero
If ObjectsOverlap(izombi\obj,hero) Then hp-izombi\dmg
For ibullet.bullets=Each bullets
If ObjectsOverlap(ibullet\obj,izombi\obj) Then izombi\hp-ibullet\dmg Then ibullet\hp=-5
If Distance2(iBullet\obj,hero)>600 Or ibullet\hp<0 Then
DeleteObject iBullet\obj
Delete iBullet
EndIf
Next ibullet
MoveObject izombi\obj,izombi\speed
If izombi\hp<0 Then
PlaySound zombie groan
score+izombi\score
DeleteObject izombi\obj
Delete izombi
EndIf
Next izombi
EndIf
DrawGame
Text 10,10,"HP "+hp
Text 10,20,"score "+score
If hp<0 Then Text 350,300,"GAME OVER"
DrawScreen
Forever