none
Trails 2.0 RRS feed

  • Question

  • Thanks to everyone's input, ive gotten a code that makes a trail and moves swiftly and everything I wanted. The only problem now is that I need something to pop up if the player hits their own trail or hits the wall..I just want this in a simple way but so it gets the job done.  Just some code to add on to my original code. Not a whole different code. It would help a lot!! Thanks!
    GraphicsWindow.BackgroundColor= "Black"
    GraphicsWindow.Height="900"
    GraphicsWindow.Width="900"
    GraphicsWindow.BrushColor= colour
    GraphicsWindow.PenColor= "White"
    player= Shapes.AddEllipse(15,40)
    x=0
    y=0
    Moving= "true"
    Start:
    If (Moving="true") Then
    X= x+delX
    Y= y+delY
    GraphicsWindow.TextInput=MoveCycle
    Shapes.Move(player,x,y)
    EndIf
    w = 15 
    h = 40
    GraphicsWindow.BrushColor= colour
    GraphicsWindow.FillEllipse(x+15/2-4, y+40/2-4, 12, 12)
    Program.Delay(100)
    Goto Start
    Sub MoveCycle
      key=GraphicsWindow.LastKey
      
      
      If (key="D") Then 
        delX= 25
        delY= 0 
       Shapes.Rotate(player,90) 
      ElseIf (key= "A") Then
        delX= -25
        delY= 0
        Shapes.Rotate(player,90)
      ElseIf (key="S") Then
        delY= 25
        delX= 0
        Shapes.Rotate(player,0)
      ElseIf (key="W") Then
        delY= -25
        delX= 0
        Shapes.Rotate(player,0)
        EndIf
      EndSub

    Thursday, November 22, 2012 7:53 PM

Answers

  • Unfortunately in order to detect hitting the blobs you need to be able to detect them.  Either by storing the coordinates on each one added and testing if the head is over one or possibly using GetPixel to detect  the colour where a blob is.  So more prototyping and code changes - sorry no 5 line fix that does magic!

    Consider the following as a possibility (option 2 above) - obviously more work to use it, but the blobs are detected.

    If (Moving="true") Then
      X= x+delX
      Y= y+delY
      GraphicsWindow.TextInput=MoveCycle
      Shapes.Move(player,x,y)
      If (GraphicsWindow.GetPixel(x+15/2+2,y+40/2+2) = "#FF0000") Then '"#FF0000" is Red if your blobs are colour = "Red"
        Sound.PlayClickAndWait()
      EndIf
    EndIf

    Or perhaps, just detect a colour that is not Black:

    If (GraphicsWindow.GetPixel(x+15/2+2,y+40/2+2) <> "#000000") Then


    Thursday, November 22, 2012 8:43 PM
    Moderator