none
Can you help on my little game RRS feed

  • Question

  • Im making a follow the leader program with the turtle (One of my fav. features) but I keep getting cannot find Property "MouseDown" in GraphicsWindow the same with KeyDown. Can someone tell me whats wrong and what I did wrong I just wanted to add a clear and restart feature if you take those out it works fine.





    begin:
    GraphicsWindow.Width = 800
    GraphicsWindow.Height = 800
    GraphicsWindow.CanResize = "False"
    GraphicsWindow.Title = "Play follow the leader with the turtle"
    GraphicsWindow.Show()
    GraphicsWindow.ShowMessage("Comming Soon! To play all you need to do is move the mouse anywhere but dont let the turtle get on your mouse for more than 4 sec or else this goes on for 300 rounds"," How to play")
    GraphicsWindow.ShowMessage("Comming Soon! To clear press any key to restart click somewhere", "How to clear screen/restart")
    Turtle.Show()
    MouseX = GraphicsWindow.MouseX
    MouseY = GraphicsWindow.MouseY
    Turtle.Speed = 6

    For i = 1 To 300
      If(OnKeyPress = "True") Then 
        GraphicsWindow.Clear()
      EndIf
      MouseX = GraphicsWindow.MouseX
      MouseY = GraphicsWindow.MouseY
    Turtle.MoveTo(MouseX, MouseY)
    EndFor

    If(OnMouseDown = "True") Then
      Goto begin
    EndIf
    Thursday, October 22, 2009 12:19 AM

Answers

  • To use events, basically you write a subroutine, and tell SB to call that sub everytime the event happens

    'this tells SB to execute the OnMouseDown sub everytime a mouse click is pressed.
    GraphicsWindow.MouseDown = OnMouseDown

    Sub OnMouseDown
      'this clears the GraphicsWindow when you click the mouse
      GraphicsWindow.Clear()
    EndSub

    Here's a modified version of your code

    'setup events
    GraphicsWindow.MouseDown = OMD
    GraphicsWindow.KeyDown = OKD

    '---------------------------------------------------------------------------
    Begin:
    GraphicsWindow.Width = 800
    GraphicsWindow.Height = 800
    GraphicsWindow.CanResize = "False"
    GraphicsWindow.Title = "Play follow the leader with the turtle"
    GraphicsWindow.Show()
    GraphicsWindow.Clear()
    GraphicsWindow.ShowMessage("Comming Soon! To play all you need to do is move the mouse anywhere but dont let the turtle get on your mouse for more than 4 sec or else this goes on for 300 rounds"," How to play")
    GraphicsWindow.ShowMessage("Comming Soon! To clear press any key to restart click somewhere", "How to clear screen/restart")
    Turtle.Show()
    Turtle.Speed = 6

    Status = "Loop"

    '---------------------------------------------------------------------------
    Loop:

    MouseX = GraphicsWindow.MouseX
    MouseY = GraphicsWindow.MouseY

    Turtle.MoveTo(MouseX, MouseY)

    Program.Delay(200)

    If (Status = "Begin") Then
      Goto Begin
    EndIf
    Goto Loop

    '---------------------------------------------------------------------------
    Sub OMD
      Status = "Begin"
    EndSub

    '---------------------------------------------------------------------------
    Sub OKD
      GraphicsWindow.Clear()
      Turtle.Show()
    EndSub
     

    • Proposed as answer by Dudeson Thursday, October 22, 2009 6:47 PM
    • Marked as answer by russjr08 Thursday, October 22, 2009 9:47 PM
    Thursday, October 22, 2009 8:24 AM

All replies

  • To use events, basically you write a subroutine, and tell SB to call that sub everytime the event happens

    'this tells SB to execute the OnMouseDown sub everytime a mouse click is pressed.
    GraphicsWindow.MouseDown = OnMouseDown

    Sub OnMouseDown
      'this clears the GraphicsWindow when you click the mouse
      GraphicsWindow.Clear()
    EndSub

    Here's a modified version of your code

    'setup events
    GraphicsWindow.MouseDown = OMD
    GraphicsWindow.KeyDown = OKD

    '---------------------------------------------------------------------------
    Begin:
    GraphicsWindow.Width = 800
    GraphicsWindow.Height = 800
    GraphicsWindow.CanResize = "False"
    GraphicsWindow.Title = "Play follow the leader with the turtle"
    GraphicsWindow.Show()
    GraphicsWindow.Clear()
    GraphicsWindow.ShowMessage("Comming Soon! To play all you need to do is move the mouse anywhere but dont let the turtle get on your mouse for more than 4 sec or else this goes on for 300 rounds"," How to play")
    GraphicsWindow.ShowMessage("Comming Soon! To clear press any key to restart click somewhere", "How to clear screen/restart")
    Turtle.Show()
    Turtle.Speed = 6

    Status = "Loop"

    '---------------------------------------------------------------------------
    Loop:

    MouseX = GraphicsWindow.MouseX
    MouseY = GraphicsWindow.MouseY

    Turtle.MoveTo(MouseX, MouseY)

    Program.Delay(200)

    If (Status = "Begin") Then
      Goto Begin
    EndIf
    Goto Loop

    '---------------------------------------------------------------------------
    Sub OMD
      Status = "Begin"
    EndSub

    '---------------------------------------------------------------------------
    Sub OKD
      GraphicsWindow.Clear()
      Turtle.Show()
    EndSub
     

    • Proposed as answer by Dudeson Thursday, October 22, 2009 6:47 PM
    • Marked as answer by russjr08 Thursday, October 22, 2009 9:47 PM
    Thursday, October 22, 2009 8:24 AM
  • Thank you it worked your gratitude is very apperciated!
    +1 Point
    Answer Marked
    Thursday, October 22, 2009 9:51 PM
  • Thats good, ive been wondering how the ____ events worked too! Everything else is explained...
    Sunday, October 25, 2009 3:48 PM