I´m desperate because i have tried almost everything ans for some reason everything goes wrong, i´m confused a lot with this, where is my code, if any of you guys can point where in the code i´m doing it bad?
Code: Select all
SCREEN 640, 480, cbsizable
FrameLimit 60
Type ENEMIES
Field obj
Field health As Integer
End Type
Type BULLETS
Field obj
End Type
Type ENEMBULLETS
Field obj
End Type
Gosub load
Repeat
SetWindow "Ship Battle Game 1"
For newenemie.ENEMIES = Each ENEMIES
PointObject newenemie\obj, ship
MoveObject newenemie\obj, -0.5
decreasehealth = False
If decreasehealth = False Then
enemiebullet.ENEMBULLETS=new(ENEMBULLETS)
enemiebullet\obj = CloneObject(bullet)
CloneObjectPosition enemiebullet\obj,newenemie\obj
CloneObjectOrientation enemiebullet\obj,newenemie\obj
MoveObject enemiebullet\obj,24
EndIf
For enbullet.ENEMBULLETS = Each ENEMBULLETS
If Distance2(newenemie\obj,ship)< 500
MoveObject enbullet\obj,6
EndIf
Next enbullet.ENEMBULLETS
For iBullet.BULLETS = Each BULLETS
If ObjectsOverlap (newenemie\obj, ibullet\obj) Then
decreasehealth = True
DeleteObject ibullet\obj
Delete ibullet
EndIf
Next ibullet
If decreasehealth Then newenemie\health -1
If newenemie\health < 1 Then
PlaySound boom,100
DeleteObject newenemie\obj
Delete newenemie
EndIf
Next newenemie.ENEMIES
CloneCameraPosition ship
TranslateObject floor, -1.4, 0 'move the floor
If LeftKey() Then TurnObject ship, 5
If RightKey() Then TurnObject ship,-5
If UpKey() Then speed# = CurveValue(4.6, speed#, 13) 'if up arrow is pressed, speed# will be increased smoothly
If DownKey() Then speed# = CurveValue(-3.5, speed#, 13) '...and if down arrow is pressed, it will be decreased smoothly
speed# = CurveValue (0, speed#, 60) 'this will make sure the ship will eventually stop smoothly if no key is pressed
MoveObject ship, speed# '...and finally, the ship is actually being moved
If KeyDown(cbkeyspace) And reload =0
PlaySound shoot,20
newbullet.BULLETS = New(BULLETS)
newbullet\obj = CloneObject(bullet)
CloneObjectPosition newbullet\obj,ship
CloneObjectOrientation newbullet\obj,ship
MoveObject newbullet\obj,24
reload=7
EndIf
SetWindow "Ship Battle Game 3"
If Rand (1, 100) = 1 Then
newenemie.ENEMIES = New(ENEMIES)
newenemie\obj = CloneObject (enem)
newenemie\health = 1
PositionObject newenemie\obj, Rand(-220,220)+ CameraX(),Rand(-300,300)+ CameraY()
SetupCollision ship,newenemie\obj,2,2,1
EndIf
SetWindow "Ship Battle Game 4"
b=0
For ibullet.BULLETS = Each BULLETS
MoveObject ibullet\obj,6
If Distance2 (ibullet\obj,ship)>400 Then
DeleteObject ibullet\obj
Delete ibullet
EndIf
b=b+1
Next ibullet
If reload >0 Then reload=reload-1
Text 30,30,"Bullets: "+b
Text 0, 0, "Lives: "+lives
Text 30,42,"Coordinates: X"+Int( (ship))+", Y"+Int(ObjectY (ship))
DrawScreen
Until EscapeKey() Or lives = 0
load:
shoot = LoadSound ("Blaster.wav")
boom = LoadSound ("Boom.wav")
enem = LoadObject("enemy2.png")
ShowObject enem, 0
bullet= LoadObject("bullet.png",72)
ShowObject bullet, 0
explosion = LoadObject("explosion.png", 72)
ShowObject explosion, 0
ship = LoadObject("nave.png", 72)
PositionObject ship, 0, 0
floor=MakeObjectFloor()
fundo=LoadImage("fundo.bmp")
PaintObject floor,fundo
ClsColor cbBlack
Color cbRed
For i = 1 To 15
newenemie.ENEMIES = New(ENEMIES)
newenemie\obj = CloneObject (enem)
newenemie\health = 1
PositionObject newenemie\obj, Rand(-500,500)+ CameraX(),Rand(-450,450)+CameraY()
SetupCollision ship, newenemie\obj,2,2,1
Next i
SetWindow "Ship Battle Game"
x=0:y=0
lives =3
Return