none
Help with maze game? RRS feed

  • Question

  • Hello,

    I have recently started out in small basic and i am understanding things more and more.

    I am just not understanding how to make it whenever you touch the sides, it resets you back to the start, and when you touch the orange rectangle, you will win.

    Can anyone help me?

    Here is my code so far:

    R1()
      Sub R1
        GraphicsWindow.Show()
        GraphicsWindow.MouseMove = OnMouseMove
      GraphicsWindow.BackgroundColor = "black"
      GraphicsWindow.Width = 800
      GraphicsWindow.Height = 600
      GraphicsWindow.CanResize = 0
      GraphicsWindow.fontsize= 40
      GraphicsWindow.Title = "Maze Game!
      GraphicsWindow.BrushColor = "cyan"
      GraphicsWindow.PenColor = "cyan"
      Info = Shapes.AddText("")
      A = Shapes.AddRectangle(200, 650)
      B = Shapes.AddRectangle(100, 550)
      C = Shapes.AddRectangle(100, 600)
      D = Shapes.AddRectangle(250, 600)
      E = Shapes.AddRectangle(250, 100)
      Shapes.Move(A, 0, 0)
      Shapes.Move(B, 300, 0)
      Shapes.Move(C, 500, 40)
      Shapes.Move(D, 600, 40)
      Shapes.Move(E, 600, 0)
      GraphicsWindow.BrushColor = "DarkOrange"
      GraphicsWindow.PenColor = "DarkOrange"
      F = Shapes.AddRectangle( 50, 40)
      Shapes.Move(F, 550, 0)
    EndSub
    Sub Win 
      GraphicsWindow.ShowMessage("Congats! You Win!!" "WINNER!")
      Program.End()
    EndSub
    Sub Lose
      GraphicsWindow.ShowMessage("Restart","Try again")
      EndSub
      Sub OnMouseMove
      x = GraphicsWindow.MouseX
      y = GraphicsWindow.MouseY
    Endsub


    Wednesday, November 13, 2013 10:17 PM

Answers

  • Well, first of all, to make it easier to see if your mouse hits a wall, when you set up all of the rectangles, use variables. Example, x=200, y=650 A=Shapes.add rectangle (x,y)

    No movï es da casti. Movï es da movïo.

    Wednesday, November 13, 2013 10:34 PM
  • Then, you can use mousex and mousey. (If mouse x is >x and mouse x <whatever) this will do bounds checking. Play around with it..

    No movï es da casti. Movï es da movïo.

    Wednesday, November 13, 2013 10:36 PM

All replies

  • Well, first of all, to make it easier to see if your mouse hits a wall, when you set up all of the rectangles, use variables. Example, x=200, y=650 A=Shapes.add rectangle (x,y)

    No movï es da casti. Movï es da movïo.

    Wednesday, November 13, 2013 10:34 PM
  • Then, you can use mousex and mousey. (If mouse x is >x and mouse x <whatever) this will do bounds checking. Play around with it..

    No movï es da casti. Movï es da movïo.

    Wednesday, November 13, 2013 10:36 PM
  • Thanks for this, it's really helped me.
    Thursday, November 14, 2013 3:41 PM
  • Hi zandraken14, Daniel is having some problems with his Microsoft account, and has to wait 30 days before he can log back in. He says, "No Problem". For helping you out :)

    ardiezc_quazhulu was here.

    Friday, November 15, 2013 2:00 AM
  • Hi, my account is all fixed. No problem :)

    No movï es da casti. Movï es da movïo.

    Sunday, November 17, 2013 6:42 PM