none
Balloon Game Help! RRS feed

  • Question

  • Hi,

    I am working on a game which pops the Balloon when you shoot the Cannon well as I was working on it I couldn't get the Balloon to move and I am really stuck! Please help!

    cannon1_x = 375
    cannon1_y = 350
    balloon1_y = 0
    
    GraphicsWindow.KeyDown = moveCannon
    GraphicsWindow.Width = "800"
    GraphicsWindow.Height = "500"
    GraphicsWindow.Show()
    
    RESOURCE_PATH = Program.Directory + "/resources/"
    CANNON_IMAGE = RESOURCE_PATH + "cannon.png"
    BALLOON_IMG = RESOURCE_PATH + "balloon.png"
    balloon = Shapes.AddImage(BALLOON_IMG)
    cannon = Shapes.AddImage(CANNON_IMAGE)
    Shapes.Move(cannon, cannon1_x, cannon1_y)
    
    While "true"
      Program.Delay(100)
    EndWhile
    
    Sub moveCannon
    
    If GraphicsWindow.LastKey = "D" Then
      cannon1_x = cannon1_x + 10
      Shapes.Move(cannon, cannon1_x, cannon1_y)
      
    ElseIf GraphicsWindow.LastKey = "A" Then
      cannon1_x = cannon1_x - 10
      Shapes.Move(cannon, cannon1_x, cannon1_y)
    EndIf
    EndSub
    
    For moveBalloon = 1 To GraphicsWindow.Width
      Shapes.Move(balloon, moveBalloon, balloon1_y)
      Program.Delay(10)
    EndFor


    I love coding. This is signature is 100% Original. :)

    Wednesday, February 1, 2017 6:40 AM

Answers

  • Forbidden Duck,

    Here's your program with the ball moving. I didn't have your images so I used shapes to make the cannon and balloon. Still needs work. Your main issue was you didn't include the for loop in the subroutine. You have to hit "A" or "D" for it to move. You might want to reference "AlmostThere"'s post on "Adding mouse as controlling method in Game".

    cannon1_x = 375
    cannon1_y = 350
    balloon1_y = 0
    GraphicsWindow.KeyDown = moveCannon
    GraphicsWindow.Width = "800"
    GraphicsWindow.Height = "500"
    GraphicsWindow.Show()
    RESOURCE_PATH = Program.Directory + "\resources\"
    'TextWindow.WriteLine(Resource_path)
    CANNON_IMAGE = RESOURCE_PATH + "cannon.png"
    Balloon=Shapes.AddEllipse(40,40)
    Shapes.Move(Balloon,400,250)
    'BALLOON_IMG = RESOURCE_PATH + "balloon.png"
    'balloon = Shapes.AddImage(BALLOON_IMG)
    Cannon=Shapes.AddRectangle(30,60)
    'cannon = Shapes.AddImage(CANNON_IMAGE)
    Shapes.Move(cannon, cannon1_x, cannon1_y)
    While "true"
      Program.Delay(100)
    EndWhile
    Sub moveCannon
    If GraphicsWindow.LastKey = "D" Then
      cannon1_x = cannon1_x + 10
      Shapes.Move(cannon, cannon1_x, cannon1_y)
     
    ElseIf GraphicsWindow.LastKey = "A" Then
      cannon1_x = cannon1_x - 10
      Shapes.Move(cannon, cannon1_x, cannon1_y)
    EndIf
    For moveBalloon = 1 To GraphicsWindow.Width
      Shapes.Move(balloon, moveBalloon, balloon1_y+moveBalloon)
      Program.Delay(10)
    EndFor
    EndSub


    JR



    Wednesday, February 1, 2017 12:43 PM
    Answerer