i need help! - blitz
hi i probably made a stupid mistake but i cant get the arrow to move or pop the baloon
code
;Set the Graphics mode
Graphics 800,600
AppTitle "Arrow and Bow."
;Set the buffer
SetBuffer BackBuffer()
;Make automidhandle true
AutoMidHandle True
;Consts
;Keys
Const upk = 200
Const downk = 208
Const spacek = 57
Const escapek = 1
;The player,baloon,and arrow speeds
Const playerspeed = 7
Const arrowspeed = 5
Const baloonspeed = 4
;Types
;Player type
Type player
Field y
Field ammo
Field frame
End Type
;Arrow type
Type arrow
Field x
Field y
End Type
;Baloon type
Type baloon
Field x
Field y
Field hits
Field yv
End Type
;Images
;Player image
Global playerimage = LoadAnimImage("player.bmp",96,96,0,2)
;Arrow image
Global arrowimage = LoadImage("arrow.bmp")
;Baloon image
Global baloonimage = LoadImage("baloon.bmp")
;Type initialization
;Make user
Global player.player = New player
;Make baloon
Global baloon.baloon = New baloon
;Initialization!
Text 400,300,"Pop the baloons!"
Delay 2000
Text 420,330,"Get popin!"
Flip
Delay 500
;Initialize the level
InstalizeLevel()
;Set the ammo for the player
player\ammo = 75
;Main loop
While Not KeyDown (escapek)
;Clear the screen
Cls
;mask the images
MaskImage (playerimage,255,0,255)
MaskImage (baloonimage,255,0,255)
;Draw the player
DrawImage (playerimage,30,player\y)
DrawImage (baloonimage,baloon\x,baloon\y)
;Make the player move and pause the game
Keyboard()
;AI
AI()
;Draw the score and ammo
HUD()
UpdateBullets()
Flip
Delay 30
Wend
If ImagesOverlap(image,arrowx,30,baloonimage,baloon\x,baloon\y)
Cls
Print "the game is over"
End If
;;;;;;;;;;;;;;;;;
;;Instalize lvl;;
;;;;;;;;;;;;;;;;;
Function InstalizeLevel()
;Place baloon in the middle
baloon\x = 400
baloon\y = 300
baloon\hits = 1
;Put the player at his spot
player\y = 300
;Set the frame to 0
player\frame = 0
End Function
;;;;;;;;;;;;;;;;;;
;;Key board test;;
;;;;;;;;;;;;;;;;;;
Function Keyboard()
;If player hits up move him up
If KeyDown(upk)
player\y = player\y - playerspeed
;If player hits down move him down
ElseIf KeyDown(downk)
player\y = player\y + playerspeed
EndIf
If KeyHit(spacek)
arrow.arrow = New arrow
arrow\x = 30 ;place bullet at player's x coordinate
arrow\y = player\y ;place bullet at player's y coordinate
EndIf
End Function
;;;;;;
;;AI;;
;;;;;;
Function AI()
If player\y < 33
player\y = 33
EndIf
If player\y > 563
player\y = 563
EndIf
baloon\y = baloon\y - 2
If baloon\y <= 0
baloon\y = 800
EndIf
End Function
;;;;;;;
;;HUD;;
;;;;;;;
Function HUD()
End Function
;Function UpdateBullets() - Moves each bullet on screen
Function UpdateBullets()
;For every bullet, move it up 5 pixels. If it goes offscreen, delete it, otherwise, draw it
For arrow.arrow = Each arrow
arrow\x = arrow\x - arrowspeed ;Move bullet up
;If bullet moves offscreen, delete it, otherwise, draw it onscreen. Draw laserimage if it is a laser, bulletimage if it is a bullet
If arrow\x < 820
Delete arrow
DrawImage arrowimage, 35, player\y ;Draw the bullet
EndIf
Flip
Next ;move to next bullet
Can you please show some screen shots?
I would suggest using alot of functions then just putting the main loop with thoes functions. That would be alot easier to determine what went wrong.
I would suggest using alot of functions then just putting the main loop with thoes functions. That would be alot easier to determine what went wrong.
Well Im not the best with blitz (I havent used it in forever) but for your collision thing you put: arrowx, it should be arrow\x im pretty sure, and try and make the playerspeed a global and see if that works..
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement