If ImagesCollide(img_bullet,b\x,b\y,0,img_enemy,a\x,a\y,0) Then
this is the entier code:
Code: Select all
AppTitle"oneman army"
Graphics 800,600,16,2
timer = CreateTimer(30)
x = 320
y = 400
amx = 3
aspeed = 3
chdir = False
ex = 400
ey = 320
ammo = 1000
life = 1
level = 0
kill = 0
SetBuffer BackBuffer()
img_bg = LoadImage("ground.jpg")
snd_shoot = LoadSound("shoot.wav")
snd_kill = LoadSound("kill.wav")
img_bullet = LoadImage("bullet.png")
Type bullet
Field x
Field y
End Type
img_player = LoadImage("player.png")
Type player
Field x
Field y
End Type
img_enemy = LoadImage("enemy.png")
Type enemy
Field x
Field y
End Type
While Not KeyHit(1)
TileImage img_bg,1,1
If KeyHit(57) Then
DrawImage img_bullet,x,y
PlaySound(snd_shoot)
b.bullet = New bullet
b\x = x
b\y = y - 5
ammo = ammo - 1
EndIf
For b.bullet = Each bullet
b\y = b\y - 5
DrawImage img_bullet,b\x,b\y
If b\y < 0 Then Delete b
Next
If chdir = True Then
amx = -amx
EndIf
chdir = False
numenemy = 0
For a.enemy = Each enemy
numenemy = numenemy + 1
a\x = a\x + amx
If a\x > 620 Then chdir = True
If a\x < 20 Then chdir = True
Next
If ImagesCollide(img_bullet,b\x,b\y,0,img_enemy,a\x,a\y,0) Then
PlaySound(snd_kill)
Delete a
Delete b
kills = kills + 1
EndIf
If KeyDown(203) Then x = x - 3
If KeyDown(205) Then x = x + 3
If KeyDown(200) Then y = y - 3
If KeyDown(208) Then y = y + 3
DrawImage img_player,x,y
DrawImage img_enemy,ex,ey
Text 5,500,"ammo: " + ammo
Text 5,520,"life: " + life
Text 5,540,"kills: " + kills
Text 5,560,"level: " + level
WaitTimer(timer)
Flip
Wend
End