Xboxerdude
Member
- Joined
- Jul 6, 2008
- Sythe Gold
- 0
- Messages
- 41
;Collision Program
;Kevin AnusFart
;Sets the graphics
Graphics 800,600
SetBuffer BackBuffer()
AutoMidHandle True
SeedRnd (MilliSecs())
;loads the star background
backgroundimageCLOSE = LoadImage("stars.bmp")
;loads the other stars
backgroundimageFAR = LoadImage("starsfarther.bmp")
;sets up the the handles to appropiate key numbers
Const upkey = 200, downkey = 208, leftkey =203, rightkey = 205
;This sets the constants
Const movex = 5
Const movey = 5
;This sets up the type for the first enemy ship
Type enemyship
Field x,y
Field xv,yv
Field image
End Type
;this is the type for the explosion
Type explosion
Field image
Field frame
End Type
;this is the type for the player controlled ship
Type playership
Field x,y
Field collision
Field image
End Type
;this sets yp the first enemy ship in its starting position and sets its movement
Global enemy.enemyship = New enemyship
enemy\x = 400
enemy\y = 200
enemy\xv = Rand(-5,5)
enemy\yv = Rand(-5,5)
enemy\image = LoadImage("enemyship.bmp")
;loads the explosion image
Global ex.explosion = New explosion
ex\image = LoadAnimImage("explosion1.bmp",64,64,0,8)
ex\frame = 0
;this sets up the starting posistion for
Global player.playership = New playership
player\x = 400
player\y = 400
player\collision = 0
player\image = LoadImage("ship.bmp")
While Not KeyDown(1)
Cls
;Tiles the stars to move and overlap
TileImage backgroundimageFAR,0,scrolly
TileImage backgroundimageCLOSE,0,scrolly*2
;this is the paralaxing
scrolly = scrolly + 1
;This is also for the paralaxing
If scrolly >= ImageHeight(backgroundimageCLOSE)
scrolly = 0
EndIf
;sets up the hud
Text 0,20, "Collisions: " + player\collision
Text 0,40, "Player Ship X: " + player\x
Text 0,60, "Player Ship Y: " + player\y
Text 0,80, "Enemy Ship X: " + enemy\x
Text 0,100, "Enemy Ship Y: " + enemy\y
;initates enemy on wall funciton
testEnemyonwall()
;intiates testkeys function
testkeys()
;checks for the image over lap
If (ImagesOverlap(player\image,player\x,player\y,enemy\image,enemy\x,enemy\y))
;explode ship function
explodeship()
;dealy
Delay 50
;resets to next level
player\collision = player\collision + 1
player\x = 400
player\y = 400
enemy\x = 400
enemy\y = 200
enemy\xv = Rand(-5,5)
enemy\yv = Rand(-5,5)
EndIf
;moves the first enemy
enemy\x = enemy\x + enemy\xv
enemy\y = enemy\y + enemy\yv
;draws all of the images
DrawImage enemy\image,enemy\x,enemy\y
DrawImage player\image,player\x,player\y
;flip
Flip
Delay 20
Wend
End
;bounces the enemy's if they hit the wall
Function testenemyonwall()
If enemy\x < 0
enemy\xv = -enemy\xv
EndIf
If enemy\x > 800
enemy\xv = -enemy\xv
EndIf
If enemy\y < 0
enemy\yv = -enemy\yv
EndIf
If enemy\y > 600
enemy\yv = -enemy\yv
EndIf
End Function
;this is for controlling the ship using the arrow keys
Function testkeys()
If KeyDown(upkey)
player\y = player\y -movey
EndIf
If KeyDown(downkey)
player\y = player\y + movey
EndIf
If KeyDown(leftkey)
player\x = player\x - movex
EndIf
If KeyDown(Rightkey)
player\x = player\x + movex
EndIf
End Function
;this fucntion sets up the ship to explode
Function Explodeship()
ex\frame = 0
;this causes the ship[ to explode through the frames
While ex\frame <=7
Cls
DrawImage ex\image,player\x,player\y,ex\frame
Delay 50
ex\frame = ex\frame + 1
Flip
Wend
End Function
;Kevin AnusFart
;Sets the graphics
Graphics 800,600
SetBuffer BackBuffer()
AutoMidHandle True
SeedRnd (MilliSecs())
;loads the star background
backgroundimageCLOSE = LoadImage("stars.bmp")
;loads the other stars
backgroundimageFAR = LoadImage("starsfarther.bmp")
;sets up the the handles to appropiate key numbers
Const upkey = 200, downkey = 208, leftkey =203, rightkey = 205
;This sets the constants
Const movex = 5
Const movey = 5
;This sets up the type for the first enemy ship
Type enemyship
Field x,y
Field xv,yv
Field image
End Type
;this is the type for the explosion
Type explosion
Field image
Field frame
End Type
;this is the type for the player controlled ship
Type playership
Field x,y
Field collision
Field image
End Type
;this sets yp the first enemy ship in its starting position and sets its movement
Global enemy.enemyship = New enemyship
enemy\x = 400
enemy\y = 200
enemy\xv = Rand(-5,5)
enemy\yv = Rand(-5,5)
enemy\image = LoadImage("enemyship.bmp")
;loads the explosion image
Global ex.explosion = New explosion
ex\image = LoadAnimImage("explosion1.bmp",64,64,0,8)
ex\frame = 0
;this sets up the starting posistion for
Global player.playership = New playership
player\x = 400
player\y = 400
player\collision = 0
player\image = LoadImage("ship.bmp")
While Not KeyDown(1)
Cls
;Tiles the stars to move and overlap
TileImage backgroundimageFAR,0,scrolly
TileImage backgroundimageCLOSE,0,scrolly*2
;this is the paralaxing
scrolly = scrolly + 1
;This is also for the paralaxing
If scrolly >= ImageHeight(backgroundimageCLOSE)
scrolly = 0
EndIf
;sets up the hud
Text 0,20, "Collisions: " + player\collision
Text 0,40, "Player Ship X: " + player\x
Text 0,60, "Player Ship Y: " + player\y
Text 0,80, "Enemy Ship X: " + enemy\x
Text 0,100, "Enemy Ship Y: " + enemy\y
;initates enemy on wall funciton
testEnemyonwall()
;intiates testkeys function
testkeys()
;checks for the image over lap
If (ImagesOverlap(player\image,player\x,player\y,enemy\image,enemy\x,enemy\y))
;explode ship function
explodeship()
;dealy
Delay 50
;resets to next level
player\collision = player\collision + 1
player\x = 400
player\y = 400
enemy\x = 400
enemy\y = 200
enemy\xv = Rand(-5,5)
enemy\yv = Rand(-5,5)
EndIf
;moves the first enemy
enemy\x = enemy\x + enemy\xv
enemy\y = enemy\y + enemy\yv
;draws all of the images
DrawImage enemy\image,enemy\x,enemy\y
DrawImage player\image,player\x,player\y
;flip
Flip
Delay 20
Wend
End
;bounces the enemy's if they hit the wall
Function testenemyonwall()
If enemy\x < 0
enemy\xv = -enemy\xv
EndIf
If enemy\x > 800
enemy\xv = -enemy\xv
EndIf
If enemy\y < 0
enemy\yv = -enemy\yv
EndIf
If enemy\y > 600
enemy\yv = -enemy\yv
EndIf
End Function
;this is for controlling the ship using the arrow keys
Function testkeys()
If KeyDown(upkey)
player\y = player\y -movey
EndIf
If KeyDown(downkey)
player\y = player\y + movey
EndIf
If KeyDown(leftkey)
player\x = player\x - movex
EndIf
If KeyDown(Rightkey)
player\x = player\x + movex
EndIf
End Function
;this fucntion sets up the ship to explode
Function Explodeship()
ex\frame = 0
;this causes the ship[ to explode through the frames
While ex\frame <=7
Cls
DrawImage ex\image,player\x,player\y,ex\frame
Delay 50
ex\frame = ex\frame + 1
Flip
Wend
End Function

