none
Question on getting a car to drift or skid. Help! RRS feed

  • Question

  • Hi.  I've been writing this racing game based on Sprint 1 by Atari.  It's going great but I hit a snag.  I can't get the car to skid around corners in forth gear.  The car just digs in like it's on tracks on corners.  I got all the code on moving the car from asteroids v2.  Here it is.

    If (CarMove) Then
        If(GraphicsWindow.LastKey = LeftKey) Then
          CarAngle = Math.Remainder(CarAngle - 5, 360)
       ElseIf (GraphicsWindow.LastKey = RightKey) Then
          CarAngle = Math.Remainder(CarAngle + 5, 360)
       EndIf

    EndIf 

    CarX = Math.Remainder(Shapes.GetLeft(Car) + (Math.Cos(Math.GetRadians(CarAngle - 180)) * CarSpeed) + GWinWidth, GWinWidth)
    CarY = Math.Remainder(Shapes.GetTop(Car) + (Math.Sin(Math.GetRadians(CarAngle - 180)) * CarSpeed) + GWinHeight, GWinHeight)
    Shapes.Move(Car, CarX, CarY)

    If any of you can help, I'd sure appreciate it, I really want this sucker to skid just like the real Sprint game.  This is my first post I got small basic a month ago and made a pong game.  Thanks, D.

    Tuesday, March 12, 2013 12:41 AM

Answers

  • Very good! But one problem:

    Car = Shapes.AddImage("C:\Users\Owner\Documents\Computer\Small Basic\Introducing S B\SprintCar3.png")
    Shapes.Move(Car, CarStartX, CarStartY)
    ShiftMessage = Shapes.AddImage("C:\Users\Owner\Documents\Computer\Small Basic\Introducing S B\Shift_1.png")
    Shapes.Move(ShiftMessage, 750, 0)
    Shapes.HideShape(ShiftMessage)
    Gear1Message = Shapes.AddImage("C:\Users\Owner\Documents\Computer\Small Basic\Introducing S B\Gear1.png")
    Shapes.Move(Gear1Message, 650, 0)
    Shapes.HideShape(Gear1Message)
    Gear2Message = Shapes.AddImage("C:\Users\Owner\Documents\Computer\Small Basic\Introducing S B\Gear2.png")
    Shapes.Move(Gear2Message, 650, 0)
    Shapes.HideShape(Gear2Message)
    Gear3Message = Shapes.AddImage("C:\Users\Owner\Documents\Computer\Small Basic\Introducing S B\Gear3.png")
    Shapes.Move(Gear3Message, 650, 0)
    Shapes.HideShape(Gear3Message)
    Gear4Message = Shapes.AddImage("C:\Users\Owner\Documents\Computer\Small Basic\Introducing S B\Gear4.png")

    You're gonna have to post these online :/



    A spark to start a fire is necessary. But mainly you need dry kindling.

    Tuesday, March 12, 2013 3:09 PM
    Answerer

All replies

  • Sure! Would you please post the full code? Thanks!

    A spark to start a fire is necessary. But mainly you need dry kindling.

    Tuesday, March 12, 2013 1:56 AM
    Answerer
  • 'These are calls to sub routines
    Initialize()
    DrawTrack()
    RunGame()
    'This starts out the window, the car, and a bunch of variables
    Sub Initialize
    GraphicsWindow.BackgroundColor = "Black"
    GraphicsWindow.BrushColor = "White"
    GraphicsWindow.Width = 800
    GraphicsWindow.Height = 610
    GraphicsWindow.Left = 100
    GraphicsWindow.Top = 100
    GWinWidth = GraphicsWindow.Width
    GWinHeight = GraphicsWindow.Height
    GraphicsWindow.Title = "Sprint"
    GraphicsWindow.Show()
    CarStartX = 400
    CarStartY = 550
    PylonSpace = 12.5
    PylonStep = 12.5
    PylonSize = 6
    CarAngle = 0
    CarSpeed = 0
    CarSize = 24
    Gear = 0
    Gear1Min = 2
    Gear2Min = 5
    Gear3Min = 8
    Gear4Min = 11
    UpShift2 = "False"
    UpShift3 = "False"
    UpShift4 = "False"
    GearDelay = 100
    Shift = "True"
    CarX = CarStartX
    CarY = CarStartY
    Fps = 25
    LeftKey = "Left"
    UpKey = "Up"
    DownKey = "Down"
    RightKey = "Right"
    AKey = "A"
    ZKey = "Z"
    SKey = "S"
    XKey = "X"
    CKey = "C"
    VKey = "V"
    BKey = "B"
    GameRunning = "True"
    Array = WallPositionH
    Array = WallPositionV
    Array = WallPositionA
    Array = CA
    Car = Shapes.AddImage("C:\Users\Owner\Documents\Computer\Small Basic\Introducing S B\SprintCar3.png")
    Shapes.Move(Car, CarStartX, CarStartY)
    ShiftMessage = Shapes.AddImage("C:\Users\Owner\Documents\Computer\Small Basic\Introducing S B\Shift_1.png")
    Shapes.Move(ShiftMessage, 750, 0)
    Shapes.HideShape(ShiftMessage)
    Gear1Message = Shapes.AddImage("C:\Users\Owner\Documents\Computer\Small Basic\Introducing S B\Gear1.png")
    Shapes.Move(Gear1Message, 650, 0)
    Shapes.HideShape(Gear1Message)
    Gear2Message = Shapes.AddImage("C:\Users\Owner\Documents\Computer\Small Basic\Introducing S B\Gear2.png")
    Shapes.Move(Gear2Message, 650, 0)
    Shapes.HideShape(Gear2Message)
    Gear3Message = Shapes.AddImage("C:\Users\Owner\Documents\Computer\Small Basic\Introducing S B\Gear3.png")
    Shapes.Move(Gear3Message, 650, 0)
    Shapes.HideShape(Gear3Message)
    Gear4Message = Shapes.AddImage("C:\Users\Owner\Documents\Computer\Small Basic\Introducing S B\Gear4.png")
    Shapes.Move(Gear4Message, 650, 0)
    Shapes.HideShape(Gear4Message)
    EndSub

    'This gets the start x and y and total pylons and calls one of four "Draw" sub routines to loop through drawing the wall.
    'It also calls a sub routine to save all the info on the track walls so I can do a collision
    Sub DrawTrack
    'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
    'XXXXXXXXXXXXXX Outside Corners XXXXX
    'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
    'Top Left Corner
    PylonX1 = 0
    PylonY1 = 212.5
    TotalPylons = 3
    PositionNumber = 1
    AngleNumber = 1
    ForwardAngle = "True"
    DrawForwardAngle()
    AngleWallPosition()
    'Bottom Left Corner
    PylonX1 = 0
    PylonY1 = 550
    TotalPylons = 3
    PositionNumber = 2
    AngleNumber = 1
    BackAngle = "True"
    DrawBackAngle()
    AngleWallPosition()
    'Top Right Corner
    PylonX1 = 737.5
    PylonY1 = 162.5
    TotalPylons = 3
    PositionNumber = 3
    AngleNumber = 2
    BackAngle = "True"
    DrawBackAngle()
    AngleWallPosition()
    'Bottom Right Corner
    PylonX1 = 737.5
    PylonY1 = 600
    TotalPylons = 3
    PositionNumber = 4
    AngleNumber = 2
    ForwardAngle = "True"
    DrawForwardAngle()
    AngleWallPosition()
    'Top Left Inside Corner
    PylonX1 = 287.5
    PylonY1 = 162.5
    TotalPylons = 3
    PositionNumber = 5
    AngleNumber = 2
    BackAngle = "True"
    DrawBackAngle()
    AngleWallPosition()
    'Top Right Inside Corner
    PylonX1 = 337
    PylonY1 = 325
    TotalPylons = 12
    PositionNumber = 6
    AngleNumber = 1
    ForwardAngle = "True"
    DrawForwardAngle()
    AngleWallPosition()
    'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
    'XXXXXXXXXXXXXX Outside Walls XXXXXXX
    'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
    'Top Left Horizontal Wall
    PylonX1 = 50
    PylonY1 = 162.5
    TotalPylons = 20
    PositionNumber = 1
    DrawHorizontalWall()
    HorizontalWallPosition()
    'Top Right Horizontal Wall
    PylonX1 = 500
    PylonY1 = 162.5
    TotalPylons = 20
    PositionNumber = 2
    DrawHorizontalWall()
    HorizontalWallPosition()
    'Bottom Horizontal Wall
    PylonX1 = 50
    PylonY1 = 600
    TotalPylons = 56
    PositionNumber = 3
    DrawHorizontalWall()
    HorizontalWallPosition()
    'Left Verticle Wall
    PylonX1 = 0
    PylonY1 = 212.5
    TotalPylons = 28
    PositionNumber = 1
    DrawVerticalWall()
    VerticalWallPosition()
    'Right Verticle Wall
    PylonX1 = 787.5
    PylonY1 = 212.5
    TotalPylons = 28
    PositionNumber = 2
    DrawVerticalWall()
    VerticalWallPosition()
    'Left Inside Verticle Wall
    PylonX1 = 337.5
    PylonY1 = 212.5
    TotalPylons = 9
    PositionNumber = 3
    DrawVerticalWall()
    VerticalWallPosition()
    'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
    'XXXXXXXXXXXXXX Inside Corners XXXXXX
    'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
    'Left Outside Corner
    PylonX1 = 137.5
    PylonY1 = 412.5
    TotalPylons = 1
    PositionNumber = 7
    AngleNumber = 2
    BackAngle = "True"
    DrawBackAngle()
    AngleWallPosition()
    'Left Inside Corner
    PylonX1 = 175
    PylonY1 = 400
    TotalPylons = 2
    PositionNumber = 8
    AngleNumber = 1
    BackAngle = "True"
    DrawBackAngle()
    AngleWallPosition()
    'Right Inside Corner
    PylonX1 = 475
    PylonY1 = 437.5
    TotalPylons = 10
    PositionNumber = 9
    AngleNumber = 2
    ForwardAngle = "True"
    DrawForwardAngle()
    AngleWallPosition()
    'Right Outside Corner
    PylonX1 = 625
    PylonY1 = 437.5
    TotalPylons = 2
    PositionNumber = 10
    AngleNumber = 1
    ForwardAngle = "True"
    DrawForwardAngle()
    AngleWallPosition()
    'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
    'XXXXXXXXXXXXXX Inside Walls XXXXXXXX
    'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
    'Left Top Horizontal Wall
    PylonX1 = 150
    PylonY1 = 300
    TotalPylons = 2
    PositionNumber = 4
    DrawHorizontalWall()
    HorizontalWallPosition()
    'Right Top Horizontal Wall
    PylonX1 = 612.5
    PylonY1 = 300
    TotalPylons = 3
    PositionNumber = 5
    DrawHorizontalWall()
    HorizontalWallPosition()
    'Bottom Horizontal Wall
    PylonX1 = 162.5
    PylonY1 = 437.5
    PositionNumber = 6
    TotalPylons = 38
    DrawHorizontalWall()
    HorizontalWallPosition()
    'Left Outside Verticle Wall
    PylonX1 = 137.5
    PylonY1 = 312.5
    TotalPylons = 9
    PositionNumber = 4
    DrawVerticalWall()
    VerticalWallPosition()
    'Left Inside Verticle Wall
    PylonX1 = 175
    PylonY1 = 312.5
    TotalPylons = 8
    PositionNumber = 5
    DrawVerticalWall()
    VerticalWallPosition()
    'Right Outside Verticle Wall
    PylonX1 = 650
    PylonY1 = 312.5
    TotalPylons = 9
    PositionNumber = 6
    DrawVerticalWall()
    VerticalWallPosition()
    ArraySizeH = Array.GetItemCount(WallPositionH)
    ArraySizeV = Array.GetItemCount(WallPositionV)
    ArraySizeA = Array.GetItemCount(WallPositionA)
    EndSub

    'These four sub routines get the x and y and the total pylons from DrawTrack and kick out a wall in a for loop
    Sub DrawHorizontalWall
    For i = 1 To TotalPylons
    GraphicsWindow.FillRectangle((PylonX1 - PylonSpace) + PylonStep, PylonY1, PylonSize, PylonSize)
    PylonStep = PylonStep + PylonSpace
    EndFor
    PylonStep = PylonSpace
    EndSub

    Sub DrawVerticalWall
    For i = 1 To TotalPylons
    GraphicsWindow.FillRectangle(PylonX1, (PylonY1 - PylonSpace) + PylonStep, PylonSize, PylonSize)
    PylonStep = PylonStep + PylonSpace
    EndFor
    PylonStep = PylonSpace
    EndSub

    Sub DrawForwardAngle
    For i = 1 To TotalPylons
    GraphicsWindow.FillRectangle(PylonX1 + PylonStep, PylonY1 - PylonStep, PylonSize, PylonSize)
    PylonStep = PylonStep + PylonSpace
    EndFor
    PylonStep = PylonSpace
    EndSub

    Sub DrawBackAngle
    For i = 1 To TotalPylons
    GraphicsWindow.FillRectangle(PylonX1 + PylonStep, PylonY1 + PylonStep, PylonSize, PylonSize)
    PylonStep = PylonStep + PylonSpace
    EndFor
    PylonStep = PylonSpace
    EndSub

    'These three sub routines save all the info from DrawTrack so I can do a collision
    Sub HorizontalWallPosition
    For i = 1 To 1
    WallPositionH[PositionNumber]["WallX1"] = PylonX1
    WallPositionH[PositionNumber]["WallX2"] = PylonX1 + PylonSpace * TotalPylons
    WallPositionH[PositionNumber]["WallY1"] = PylonY1
    WallPositionH[PositionNumber]["WallY2"] = PylonY1 + PylonSize
    EndFor
    EndSub

    Sub VerticalWallPosition
    For i = 1 To 1
    WallPositionV[PositionNumber]["WallX1"] = PylonX1
    WallPositionV[PositionNumber]["WallX2"] = PylonX1 + PylonSize
    WallPositionV[PositionNumber]["WallY1"] = PylonY1
    WallPositionV[PositionNumber]["WallY2"] = PylonY1 + PylonSpace * TotalPylons
    EndFor
    EndSub

    Sub AngleWallPosition
    For i = 1 To TotalPylons
    If (i = 1) Then
    WallPositionA[PositionNumber][0]["Dim2Total"] = TotalPylons
    WallPositionA[PositionNumber][0]["AngleNumber"] = AngleNumber
    If (ForwardAngle) Then
    WallPositionA[PositionNumber][0]["ForwardAngle"] = ForwardAngle
    ElseIf (BackAngle) Then
    WallPositionA[PositionNumber][0]["BackAngle"] = BackAngle
    EndIf
    EndIf
    WallPositionA[PositionNumber][i]["WallX1"] = PylonX1 + PylonSpace * i
    WallPositionA[PositionNumber][i]["WallX2"] = PylonX1 + PylonSize + PylonSpace * i
    If (ForwardAngle) Then
    WallPositionA[PositionNumber][i]["WallY1"] = PylonY1 - PylonSpace * i
    WallPositionA[PositionNumber][i]["WallY2"] = PylonY1 + PylonSize - PylonSpace * i
    Else
    WallPositionA[PositionNumber][i]["WallY1"] = PylonY1 + PylonSpace * i
    WallPositionA[PositionNumber][i]["WallY2"] = PylonY1 + PylonSize + PylonSpace * i
    EndIf
    EndFor
    ForwardAngle = "False"
    BackAngle = "False"
    EndSub

    'These 3 sub routines check to see if the car x and y and the wall x and y match. all the wall info is from the 3 different wall position arrays and is accessed through a loop
    Sub CollisionHorizontal
    For i = 1 To ArraySizeH
    If (CarY <= WallPositionH[i]["WallY2"] And CarY >= WallPositionH[i]["WallY1"] And CarX + CarSize >= WallPositionH[i]["WallX1"] And CarX + CarSize <= WallPositionH[i]["WallX2"]) Then
    CH = "True"
    ElseIf (CarY <= WallPositionH[i]["WallY2"] And CarY >= WallPositionH[i]["WallY1"] And CarX >= WallPositionH[i]["WallX1"] And CarX <= WallPositionH[i]["WallX2"]) Then
    CH = "True"
    ElseIf (CarY + CarSize <= WallPositionH[i]["WallY2"] And CarY + CarSize >= WallPositionH[i]["WallY1"] And CarX + CarSize >= WallPositionH[i]["WallX1"] And CarX + CarSize <= WallPositionH[i]["WallX2"]) Then
    CH = "True"
    ElseIf (CarY + CarSize <= WallPositionH[i]["WallY2"] And CarY + CarSize >= WallPositionH[i]["WallY1"] And CarX >= WallPositionH[i]["WallX1"] And CarX <= WallPositionH[i]["WallX2"]) Then
    CH = "True"
    EndIf
    EndFor
    EndSub

    Sub CollisionVertical
    For i = 1 To ArraySizeV
    If (CarX <= WallPositionV[i]["WallX2"] And CarX >= WallPositionV[i]["WallX1"] And CarY >= WallPositionV[i]["WallY1"] And CarY + CarSize <= WallPositionV[i]["WallY2"]) Then
    CV = "True"
    ElseIf (CarX + CarSize >= WallPositionV[i]["WallX1"] And CarX + CarSize <= WallPositionV[i]["WallX2"] And CarY + CarSize >= WallPositionV[i]["WallY1"] And CarY + CarSize <= WallPositionV[i]["WallY2"]) Then
    CV = "True"
    ElseIf (CarX >= WallPositionV[i]["WallX1"] And CarX <= WallPositionV[i]["WallX2"] And CarY + CarSize >= WallPositionV[i]["WallY1"] And CarY + CarSize <= WallPositionV[i]["WallY2"]) Then
    CV = "True"
    EndIf
    EndFor
    EndSub

    Sub CollisionAngle
    For i = 1 To ArraySizeA
    For ii = 1 To WallPositionA[i][0]["Dim2Total"]
    If (WallPositionA[i][0]["AngleNumber"] = 1 And WallPositionA[i][0]["ForwardAngle"]) Then
    If (CarX >= WallPositionA[i][ii]["WallX1"] - CarSize And CarX <= WallPositionA[i][ii]["WallX2"] And CarY >= WallPositionA[i][ii]["WallY1"] - CarSize And CarY + CarSize <= WallPositionA[i][ii]["WallY2"] + CarSize) Then
    CA = "True"
    EndIf
    ElseIf (WallPositionA[i][0]["AngleNumber"] = 1 And WallPositionA[i][0]["BackAngle"]) Then
    If (CarX >= WallPositionA[i][ii]["WallX1"] - CarSize And CarX <= WallPositionA[i][ii]["WallX2"] And CarY >= WallPositionA[i][ii]["WallY1"] - CarSize And CarY <= WallPositionA[i][ii]["WallY2"] + CarSize) Then
    CA = "True"
    EndIf
    ElseIf (WallPositionA[i][0]["AngleNumber"] = 2) Then
    If (CarX + CarSize >= WallPositionA[i][ii]["WallX1"] And CarX + CarSize <= WallPositionA[i][ii]["WallX2"] + CarSize And CarY >= WallPositionA[i][ii]["WallY1"] - CarSize And CarY + CarSize <= WallPositionA[i][ii]["WallY2"] + CarSize) Then
    CA = "True"
    EndIf
    EndIf
    EndFor
    EndFor
    EndSub

    'CollisionCheck runs through 3 different wall type sub routines to check for collision and, if so, sets CarSpeed to 1
    Sub CollisionCheck
    CollisionHorizontal()
    CollisionVertical()
    CollisionAngle()
    If (CH Or CV Or CA) Then
    CarSpeed = 1
    Gear = 0
    UpShift2 = "False"
    UpShift3 = "False"
    UpShift4 = "False"
    Shapes.HideShape(ShiftMessage)
    Shapes.HideShape(Gear1Message)
    Shapes.HideShape(Gear2Message)
    Shapes.HideShape(Gear3Message)
    Shapes.HideShape(Gear4Message)
    EndIf
    EndSub

    'This resets all the collisions after hitting a wall
    Sub ResetCollision
    CH = "False"
    CV = "False"
    CA = "False"
    EndSub

    'Main loop
    Sub RunGame
    GraphicsWindow.KeyDown = OnKeyDown
    GraphicsWindow.KeyUp = OnKeyUp
    While GameRunning
    Program.Delay(1000/Fps)
    DriveCar()
    If (Gear <> 0) Then
    ChangeGear()
    EndIf
    CollisionCheck()
    ResetCollision()
    EndWhile
    EndSub

    'These 2 sub routines give a boolean value to GraphicsWindow.KeyDown and Up for whether the car is moving or not
    Sub OnKeyDown
    CarMove = "True"
    EndSub

    Sub OnKeyUp
    CarMove = "False"
    EndSub

    'This steers and accelerates the car. It changes gears, too.
    Sub DriveCar
    If (CarMove) Then
    'This Sets the angle for steering
    If(GraphicsWindow.LastKey = LeftKey) Then
    CarAngle = Math.Remainder(CarAngle - 5, 360)
    ElseIf (GraphicsWindow.LastKey = RightKey) Then
    CarAngle = Math.Remainder(CarAngle + 5, 360)
    EndIf
    'This sets the gears. The way it works, you have to wait for it to hit the max speed for each gear 1-4, and you can't skip gears.
    If (GraphicsWindow.LastKey = AKey) Then
    Gear = 1
    GearDelay = 100
    ElseIf (GraphicsWindow.LastKey = ZKey) Then
    If (UpShift2) Then
    Gear = 2
    GearDelay = 100
    Else
    Gear = 0
    CarSpeed = 1
    EndIf
    ElseIf (GraphicsWindow.LastKey = SKey) Then
    If (UpShift3) Then
    Gear = 3
    GearDelay = 100
    Else
    Gear = 0
    CarSpeed = 1
    EndIf
    ElseIf (GraphicsWindow.LastKey = XKey) Then
    If (UpShift4) Then
    Gear = 4
    Else
    Gear = 0
    CarSpeed = 1
    EndIf
    EndIf
    Shapes.Rotate(Car, CarAngle)
    EndIf
    'This does the forward and turning motion
    CarX = Math.Remainder(Shapes.GetLeft(Car) + (Math.Cos(Math.GetRadians(CarAngle - 180)) * CarSpeed) + GWinWidth, GWinWidth)
    CarY = Math.Remainder(Shapes.GetTop(Car) + (Math.Sin(Math.GetRadians(CarAngle - 180)) * CarSpeed) + GWinHeight, GWinHeight)
    Shapes.Move(Car, CarX, CarY)
    EndSub

    Sub ChangeGear
    If (Gear = 1) Then
    Shapes.ShowShape(Gear1Message)
    Shapes.HideShape(Gear2Message)
    Shapes.HideShape(Gear3Message)
    Shapes.HideShape(Gear4Message)
    If (GearDelay >= 67) Then
    CarSpeed = Gear1Min
    Shapes.HideShape(ShiftMessage)
    ElseIf (GearDelay <= 67 And GearDelay >= 34) Then
    CarSpeed = Gear1Min + 1
    ElseIf (GearDelay <= 34 And GearDelay >= 1) Then
    CarSpeed = Gear1Min + 2
    Shapes.ShowShape(ShiftMessage)
    UpShift2 = "True"
    UpShift3 = "False"
    UpShift4 = "False"
    EndIf
    ElseIf (Gear = 2) Then
    Shapes.HideShape(Gear1Message)
    Shapes.ShowShape(Gear2Message)
    Shapes.HideShape(Gear3Message)
    Shapes.HideShape(Gear4Message)
    If (GearDelay >= 67) Then
    CarSpeed = Gear2Min
    Shapes.HideShape(ShiftMessage)
    ElseIf (GearDelay <= 67 And GearDelay >= 34) Then
    CarSpeed = Gear2Min + 1
    ElseIf (GearDelay <= 34 And GearDelay >= 1) Then
    CarSpeed = Gear2Min + 2
    Shapes.ShowShape(ShiftMessage)
    UpShift2 = "True"
    UpShift3 = "True"
    UpShift4 = "False"
    EndIf
    ElseIf (Gear = 3) Then
    Shapes.HideShape(Gear1Message)
    Shapes.HideShape(Gear2Message)
    Shapes.ShowShape(Gear3Message)
    Shapes.HideShape(Gear4Message)
    If (GearDelay >= 67) Then
    CarSpeed = Gear3Min
    Shapes.HideShape(ShiftMessage)
    ElseIf (GearDelay <= 67 And GearDelay >= 34) Then
    CarSpeed = Gear3Min + 1
    ElseIf (GearDelay <= 34 And GearDelay >= 1) Then
    CarSpeed = Gear3Min + 2
    Shapes.ShowShape(ShiftMessage)
    UpShift2 = "True"
    UpShift3 = "True"
    UpShift4 = "True"
    EndIf
    ElseIf (Gear = 4) Then
    Shapes.HideShape(Gear1Message)
    Shapes.HideShape(Gear2Message)
    Shapes.HideShape(Gear3Message)
    Shapes.ShowShape(Gear4Message)
    Shapes.HideShape(ShiftMessage)
    CarSpeed = Gear4Min
    EndIf
    GearDelay = GearDelay - 1
    EndSub
    Tuesday, March 12, 2013 2:24 AM
  • I think CarAngle should be saved such as LastCarAngle.  And calculate with LastCarAngle for CarX and CarY.  And update LastCarAngle as CarAngle with Timer.Tick.

    Nonki Takahashi

    Tuesday, March 12, 2013 9:53 AM
    Moderator
  • Very good! But one problem:

    Car = Shapes.AddImage("C:\Users\Owner\Documents\Computer\Small Basic\Introducing S B\SprintCar3.png")
    Shapes.Move(Car, CarStartX, CarStartY)
    ShiftMessage = Shapes.AddImage("C:\Users\Owner\Documents\Computer\Small Basic\Introducing S B\Shift_1.png")
    Shapes.Move(ShiftMessage, 750, 0)
    Shapes.HideShape(ShiftMessage)
    Gear1Message = Shapes.AddImage("C:\Users\Owner\Documents\Computer\Small Basic\Introducing S B\Gear1.png")
    Shapes.Move(Gear1Message, 650, 0)
    Shapes.HideShape(Gear1Message)
    Gear2Message = Shapes.AddImage("C:\Users\Owner\Documents\Computer\Small Basic\Introducing S B\Gear2.png")
    Shapes.Move(Gear2Message, 650, 0)
    Shapes.HideShape(Gear2Message)
    Gear3Message = Shapes.AddImage("C:\Users\Owner\Documents\Computer\Small Basic\Introducing S B\Gear3.png")
    Shapes.Move(Gear3Message, 650, 0)
    Shapes.HideShape(Gear3Message)
    Gear4Message = Shapes.AddImage("C:\Users\Owner\Documents\Computer\Small Basic\Introducing S B\Gear4.png")

    You're gonna have to post these online :/



    A spark to start a fire is necessary. But mainly you need dry kindling.

    Tuesday, March 12, 2013 3:09 PM
    Answerer
  • 'These are calls to sub routines
    Initialize()
    DrawTrack()
    RunGame()
    'This starts out the window, the car, and a bunch of variables
    Sub Initialize
    GraphicsWindow.BackgroundColor = "Grey"
    GraphicsWindow.BrushColor = "White"
    GraphicsWindow.Width = 800
    GraphicsWindow.Height = 610
    GraphicsWindow.Left = 100
    GraphicsWindow.Top = 100
    GWinWidth = GraphicsWindow.Width
    GWinHeight = GraphicsWindow.Height
    GraphicsWindow.Title = "Sprint"
    GraphicsWindow.Hide()
    CarStartX = 400
    CarStartY = 550
    PylonSpace = 12.5
    PylonStep = 12.5
    PylonSize = 6
    CarAngle = 0
    CarSpeed = 0
    CarSize = 24
    Gear = 0
    Gear1Min = 2
    Gear2Min = 5
    Gear3Min = 8
    Gear4Min = 11
    UpShift2 = "False"
    UpShift3 = "False"
    UpShift4 = "False"
    GearDelay = 100
    Shift = "True"
    CarX = CarStartX
    CarY = CarStartY
    Fps = 25
    LeftKey = "Left"
    UpKey = "Up"
    DownKey = "Down"
    RightKey = "Right"
    AKey = "A"
    ZKey = "Z"
    SKey = "S"
    XKey = "X"
    CKey = "C"
    VKey = "V"
    BKey = "B"
    GameRunning = "True"
    Array = WallPositionH
    Array = WallPositionV
    Array = WallPositionA
    Array = CA
    Car = Shapes.AddImage("http://i1192.photobucket.com/albums/aa326/xxxplicite/SprintCar3.png")
    Shapes.Move(Car, CarStartX, CarStartY)
    'Comp1 = Shapes.AddImage("http://i1192.photobucket.com/albums/aa326/xxxplicite/SprintCar4.png")
    'Shapes.Move(Comp1, CarStartX, CarStartY - 50)
    ShiftMessage = Shapes.AddImage("http://i1192.photobucket.com/albums/aa326/xxxplicite/Shift_1.png")
    Shapes.Move(ShiftMessage, 750, 0)
    Shapes.HideShape(ShiftMessage)
    Gear1Message = Shapes.AddImage("http://i1192.photobucket.com/albums/aa326/xxxplicite/Gear1.png")
    Shapes.Move(Gear1Message, 650, 0)
    Shapes.HideShape(Gear1Message)
    Gear2Message = Shapes.AddImage("http://i1192.photobucket.com/albums/aa326/xxxplicite/Gear2.png")
    Shapes.Move(Gear2Message, 650, 0)
    Shapes.HideShape(Gear2Message)
    Gear3Message = Shapes.AddImage("http://i1192.photobucket.com/albums/aa326/xxxplicite/Gear3.png")
    Shapes.Move(Gear3Message, 650, 0)
    Shapes.HideShape(Gear3Message)
    Gear4Message = Shapes.AddImage("http://i1192.photobucket.com/albums/aa326/xxxplicite/Gear4.png")
    Shapes.Move(Gear4Message, 650, 0)
    Shapes.HideShape(Gear4Message)
    EndSub

    'This gets the start x and y and total pylons and calls one of four "Draw" sub routines to loop through drawing the wall.
    'It also calls a sub routine to save all the info on the track walls so I can do a collision
    Sub DrawTrack
    'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
    'XXXXXXXXXXXXXX Outside Corners XXXXX
    'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
    'Top Left Corner
    PylonX1 = 0
    PylonY1 = 212.5
    TotalPylons = 3
    PositionNumber = 1
    AngleNumber = 1
    ForwardAngle = "True"
    DrawForwardAngle()
    AngleWallPosition()
    'Bottom Left Corner
    PylonX1 = 0
    PylonY1 = 550
    TotalPylons = 3
    PositionNumber = 2
    AngleNumber = 1
    BackAngle = "True"
    DrawBackAngle()
    AngleWallPosition()
    'Top Right Corner
    PylonX1 = 737.5
    PylonY1 = 162.5
    TotalPylons = 3
    PositionNumber = 3
    AngleNumber = 2
    BackAngle = "True"
    DrawBackAngle()
    AngleWallPosition()
    'Bottom Right Corner
    PylonX1 = 737.5
    PylonY1 = 600
    TotalPylons = 3
    PositionNumber = 4
    AngleNumber = 2
    ForwardAngle = "True"
    DrawForwardAngle()
    AngleWallPosition()
    'Top Left Inside Corner
    PylonX1 = 287.5
    PylonY1 = 162.5
    TotalPylons = 3
    PositionNumber = 5
    AngleNumber = 2
    BackAngle = "True"
    DrawBackAngle()
    AngleWallPosition()
    'Top Right Inside Corner
    PylonX1 = 337
    PylonY1 = 325
    TotalPylons = 12
    PositionNumber = 6
    AngleNumber = 1
    ForwardAngle = "True"
    DrawForwardAngle()
    AngleWallPosition()
    'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
    'XXXXXXXXXXXXXX Outside Walls XXXXXXX
    'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
    'Top Left Horizontal Wall
    PylonX1 = 50
    PylonY1 = 162.5
    TotalPylons = 20
    PositionNumber = 1
    DrawHorizontalWall()
    HorizontalWallPosition()
    'Top Right Horizontal Wall
    PylonX1 = 500
    PylonY1 = 162.5
    TotalPylons = 20
    PositionNumber = 2
    DrawHorizontalWall()
    HorizontalWallPosition()
    'Bottom Horizontal Wall
    PylonX1 = 50
    PylonY1 = 600
    TotalPylons = 56
    PositionNumber = 3
    DrawHorizontalWall()
    HorizontalWallPosition()
    'Left Verticle Wall
    PylonX1 = 0
    PylonY1 = 212.5
    TotalPylons = 28
    PositionNumber = 1
    DrawVerticalWall()
    VerticalWallPosition()
    'Right Verticle Wall
    PylonX1 = 787.5
    PylonY1 = 212.5
    TotalPylons = 28
    PositionNumber = 2
    DrawVerticalWall()
    VerticalWallPosition()
    'Left Inside Verticle Wall
    PylonX1 = 337.5
    PylonY1 = 212.5
    TotalPylons = 9
    PositionNumber = 3
    DrawVerticalWall()
    VerticalWallPosition()
    'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
    'XXXXXXXXXXXXXX Inside Corners XXXXXX
    'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
    'Left Outside Corner
    PylonX1 = 137.5
    PylonY1 = 412.5
    TotalPylons = 1
    PositionNumber = 7
    AngleNumber = 2
    BackAngle = "True"
    DrawBackAngle()
    AngleWallPosition()
    'Left Inside Corner
    PylonX1 = 175
    PylonY1 = 400
    TotalPylons = 2
    PositionNumber = 8
    AngleNumber = 1
    BackAngle = "True"
    DrawBackAngle()
    AngleWallPosition()
    'Right Inside Corner
    PylonX1 = 475
    PylonY1 = 437.5
    TotalPylons = 10
    PositionNumber = 9
    AngleNumber = 2
    ForwardAngle = "True"
    DrawForwardAngle()
    AngleWallPosition()
    'Right Outside Corner
    PylonX1 = 625
    PylonY1 = 437.5
    TotalPylons = 2
    PositionNumber = 10
    AngleNumber = 1
    ForwardAngle = "True"
    DrawForwardAngle()
    AngleWallPosition()
    'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
    'XXXXXXXXXXXXXX Inside Walls XXXXXXXX
    'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
    'Left Top Horizontal Wall
    PylonX1 = 150
    PylonY1 = 300
    TotalPylons = 2
    PositionNumber = 4
    DrawHorizontalWall()
    HorizontalWallPosition()
    'Right Top Horizontal Wall
    PylonX1 = 612.5
    PylonY1 = 300
    TotalPylons = 3
    PositionNumber = 5
    DrawHorizontalWall()
    HorizontalWallPosition()
    'Bottom Horizontal Wall
    PylonX1 = 162.5
    PylonY1 = 437.5
    PositionNumber = 6
    TotalPylons = 38
    DrawHorizontalWall()
    HorizontalWallPosition()
    'Left Outside Verticle Wall
    PylonX1 = 137.5
    PylonY1 = 312.5
    TotalPylons = 9
    PositionNumber = 4
    DrawVerticalWall()
    VerticalWallPosition()
    'Left Inside Verticle Wall
    PylonX1 = 175
    PylonY1 = 312.5
    TotalPylons = 8
    PositionNumber = 5
    DrawVerticalWall()
    VerticalWallPosition()
    'Right Outside Verticle Wall
    PylonX1 = 650
    PylonY1 = 312.5
    TotalPylons = 9
    PositionNumber = 6
    DrawVerticalWall()
    VerticalWallPosition()
    ArraySizeH = Array.GetItemCount(WallPositionH)
    ArraySizeV = Array.GetItemCount(WallPositionV)
    ArraySizeA = Array.GetItemCount(WallPositionA)
    EndSub

    'These four sub routines get the x and y and the total pylons from DrawTrack and kick out a wall in a for loop
    Sub DrawHorizontalWall
    For i = 1 To TotalPylons
    GraphicsWindow.FillRectangle((PylonX1 - PylonSpace) + PylonStep, PylonY1, PylonSize, PylonSize)
    PylonStep = PylonStep + PylonSpace
    EndFor
    PylonStep = PylonSpace
    EndSub

    Sub DrawVerticalWall
    For i = 1 To TotalPylons
    GraphicsWindow.FillRectangle(PylonX1, (PylonY1 - PylonSpace) + PylonStep, PylonSize, PylonSize)
    PylonStep = PylonStep + PylonSpace
    EndFor
    PylonStep = PylonSpace
    EndSub

    Sub DrawForwardAngle
    For i = 1 To TotalPylons
    GraphicsWindow.FillRectangle(PylonX1 + PylonStep, PylonY1 - PylonStep, PylonSize, PylonSize)
    PylonStep = PylonStep + PylonSpace
    EndFor
    PylonStep = PylonSpace
    EndSub

    Sub DrawBackAngle
    For i = 1 To TotalPylons
    GraphicsWindow.FillRectangle(PylonX1 + PylonStep, PylonY1 + PylonStep, PylonSize, PylonSize)
    PylonStep = PylonStep + PylonSpace
    EndFor
    PylonStep = PylonSpace
    EndSub

    'These three sub routines save all the info from DrawTrack so I can do a collision
    Sub HorizontalWallPosition
    For i = 1 To 1
    WallPositionH[PositionNumber]["WallX1"] = PylonX1
    WallPositionH[PositionNumber]["WallX2"] = PylonX1 + PylonSpace * TotalPylons
    WallPositionH[PositionNumber]["WallY1"] = PylonY1
    WallPositionH[PositionNumber]["WallY2"] = PylonY1 + PylonSize
    EndFor
    EndSub

    Sub VerticalWallPosition
    For i = 1 To 1
    WallPositionV[PositionNumber]["WallX1"] = PylonX1
    WallPositionV[PositionNumber]["WallX2"] = PylonX1 + PylonSize
    WallPositionV[PositionNumber]["WallY1"] = PylonY1
    WallPositionV[PositionNumber]["WallY2"] = PylonY1 + PylonSpace * TotalPylons
    EndFor
    EndSub

    Sub AngleWallPosition
    For i = 1 To TotalPylons
    If (i = 1) Then
    WallPositionA[PositionNumber][0]["Dim2Total"] = TotalPylons
    WallPositionA[PositionNumber][0]["AngleNumber"] = AngleNumber
    If (ForwardAngle) Then
    WallPositionA[PositionNumber][0]["ForwardAngle"] = ForwardAngle
    ElseIf (BackAngle) Then
    WallPositionA[PositionNumber][0]["BackAngle"] = BackAngle
    EndIf
    EndIf
    WallPositionA[PositionNumber][i]["WallX1"] = PylonX1 + PylonSpace * i
    WallPositionA[PositionNumber][i]["WallX2"] = PylonX1 + PylonSize + PylonSpace * i
    If (ForwardAngle) Then
    WallPositionA[PositionNumber][i]["WallY1"] = PylonY1 - PylonSpace * i
    WallPositionA[PositionNumber][i]["WallY2"] = PylonY1 + PylonSize - PylonSpace * i
    Else
    WallPositionA[PositionNumber][i]["WallY1"] = PylonY1 + PylonSpace * i
    WallPositionA[PositionNumber][i]["WallY2"] = PylonY1 + PylonSize + PylonSpace * i
    EndIf
    EndFor
    ForwardAngle = "False"
    BackAngle = "False"
    EndSub

    'These 3 sub routines check to see if the car x and y and the wall x and y match. all the wall info is from the 3 different wall position arrays and is accessed through a loop
    Sub CollisionHorizontal
    For i = 1 To ArraySizeH
    If (CarY <= WallPositionH[i]["WallY2"] And CarY >= WallPositionH[i]["WallY1"] And CarX + CarSize >= WallPositionH[i]["WallX1"] And CarX + CarSize <= WallPositionH[i]["WallX2"]) Then
    CH = "True"
    ElseIf (CarY <= WallPositionH[i]["WallY2"] And CarY >= WallPositionH[i]["WallY1"] And CarX >= WallPositionH[i]["WallX1"] And CarX <= WallPositionH[i]["WallX2"]) Then
    CH = "True"
    ElseIf (CarY + CarSize <= WallPositionH[i]["WallY2"] And CarY + CarSize >= WallPositionH[i]["WallY1"] And CarX + CarSize >= WallPositionH[i]["WallX1"] And CarX + CarSize <= WallPositionH[i]["WallX2"]) Then
    CH = "True"
    ElseIf (CarY + CarSize <= WallPositionH[i]["WallY2"] And CarY + CarSize >= WallPositionH[i]["WallY1"] And CarX >= WallPositionH[i]["WallX1"] And CarX <= WallPositionH[i]["WallX2"]) Then
    CH = "True"
    EndIf
    EndFor
    EndSub

    Sub CollisionVertical
    For i = 1 To ArraySizeV
    If (CarX <= WallPositionV[i]["WallX2"] And CarX >= WallPositionV[i]["WallX1"] And CarY >= WallPositionV[i]["WallY1"] And CarY + CarSize <= WallPositionV[i]["WallY2"]) Then
    CV = "True"
    ElseIf (CarX + CarSize >= WallPositionV[i]["WallX1"] And CarX + CarSize <= WallPositionV[i]["WallX2"] And CarY + CarSize >= WallPositionV[i]["WallY1"] And CarY + CarSize <= WallPositionV[i]["WallY2"]) Then
    CV = "True"
    ElseIf (CarX >= WallPositionV[i]["WallX1"] And CarX <= WallPositionV[i]["WallX2"] And CarY + CarSize >= WallPositionV[i]["WallY1"] And CarY + CarSize <= WallPositionV[i]["WallY2"]) Then
    CV = "True"
    EndIf
    EndFor
    EndSub

    Sub CollisionAngle
    For i = 1 To ArraySizeA
    For ii = 1 To WallPositionA[i][0]["Dim2Total"]
    If (WallPositionA[i][0]["AngleNumber"] = 1 And WallPositionA[i][0]["ForwardAngle"]) Then
    If (CarX >= WallPositionA[i][ii]["WallX1"] - CarSize And CarX <= WallPositionA[i][ii]["WallX2"] And CarY >= WallPositionA[i][ii]["WallY1"] - CarSize And CarY + CarSize <= WallPositionA[i][ii]["WallY2"] + CarSize) Then
    CA = "True"
    EndIf
    ElseIf (WallPositionA[i][0]["AngleNumber"] = 1 And WallPositionA[i][0]["BackAngle"]) Then
    If (CarX >= WallPositionA[i][ii]["WallX1"] - CarSize And CarX <= WallPositionA[i][ii]["WallX2"] And CarY >= WallPositionA[i][ii]["WallY1"] - CarSize And CarY <= WallPositionA[i][ii]["WallY2"] + CarSize) Then
    CA = "True"
    EndIf
    ElseIf (WallPositionA[i][0]["AngleNumber"] = 2) Then
    If (CarX + CarSize >= WallPositionA[i][ii]["WallX1"] And CarX + CarSize <= WallPositionA[i][ii]["WallX2"] + CarSize And CarY >= WallPositionA[i][ii]["WallY1"] - CarSize And CarY + CarSize <= WallPositionA[i][ii]["WallY2"] + CarSize) Then
    CA = "True"
    EndIf
    EndIf
    EndFor
    EndFor
    EndSub

    'CollisionCheck runs through 3 different wall type sub routines to check for collision and, if so, sets CarSpeed to 1
    Sub CollisionCheck
    CollisionHorizontal()
    CollisionVertical()
    CollisionAngle()
    If (CH Or CV Or CA) Then
    CarSpeed = 1
    Gear = 0
    UpShift2 = "False"
    UpShift3 = "False"
    UpShift4 = "False"
    Shapes.HideShape(ShiftMessage)
    Shapes.HideShape(Gear1Message)
    Shapes.HideShape(Gear2Message)
    Shapes.HideShape(Gear3Message)
    Shapes.HideShape(Gear4Message)
    EndIf
    EndSub

    'This resets all the collisions after hitting a wall
    Sub ResetCollision
    CH = "False"
    CV = "False"
    CA = "False"
    EndSub

    'Main loop
    Sub RunGame
    GraphicsWindow.Show()
    GraphicsWindow.KeyDown = OnKeyDown
    GraphicsWindow.KeyUp = OnKeyUp
    While GameRunning
    Program.Delay(1000/Fps)
    DriveCar()
    If (Gear <> 0) Then
    ChangeGear()
    EndIf
    CollisionCheck()
    ResetCollision()
    EndWhile
    EndSub

    'These 2 sub routines give a boolean value to GraphicsWindow.KeyDown and Up for whether the car is moving or not
    Sub OnKeyDown
    CarMove = "True"
    EndSub

    Sub OnKeyUp
    CarMove = "False"
    EndSub

    'This steers and accelerates the car. It changes gears, too.
    Sub DriveCar
    If (CarMove) Then
    'This Sets the angle for steering
    If(GraphicsWindow.LastKey = LeftKey) Then
    CarAngle = Math.Remainder(CarAngle - 5, 360)
    ElseIf (GraphicsWindow.LastKey = RightKey) Then
    CarAngle = Math.Remainder(CarAngle + 5, 360)
    EndIf
    'This sets the gears. The way it works, you have to wait for it to hit the max speed for each gear 1-4, and you can't skip gears.
    If (GraphicsWindow.LastKey = AKey) Then
    Gear = 1
    GearDelay = 100
    ElseIf (GraphicsWindow.LastKey = ZKey) Then
    If (UpShift2) Then
    Gear = 2
    GearDelay = 100
    Else
    Gear = 0
    CarSpeed = 1
    EndIf
    ElseIf (GraphicsWindow.LastKey = SKey) Then
    If (UpShift3) Then
    Gear = 3
    GearDelay = 100
    Else
    Gear = 0
    CarSpeed = 1
    EndIf
    ElseIf (GraphicsWindow.LastKey = XKey) Then
    If (UpShift4) Then
    Gear = 4
    Else
    Gear = 0
    CarSpeed = 1
    EndIf
    EndIf
    Shapes.Rotate(Car, CarAngle)
    EndIf
    'This does the forward and turning motion
    CarX = Math.Remainder(Shapes.GetLeft(Car) + (Math.Cos(Math.GetRadians(CarAngle - 180)) * CarSpeed) + GWinWidth, GWinWidth)
    CarY = Math.Remainder(Shapes.GetTop(Car) + (Math.Sin(Math.GetRadians(CarAngle - 180)) * CarSpeed) + GWinHeight, GWinHeight)
    Shapes.Move(Car, CarX, CarY)
    EndSub

    Sub ChangeGear
    If (Gear = 1) Then
    Shapes.ShowShape(Gear1Message)
    Shapes.HideShape(Gear2Message)
    Shapes.HideShape(Gear3Message)
    Shapes.HideShape(Gear4Message)
    If (GearDelay >= 67) Then
    CarSpeed = Gear1Min
    Shapes.HideShape(ShiftMessage)
    ElseIf (GearDelay <= 67 And GearDelay >= 34) Then
    CarSpeed = Gear1Min + 1
    ElseIf (GearDelay <= 34 And GearDelay >= 1) Then
    CarSpeed = Gear1Min + 2
    Shapes.ShowShape(ShiftMessage)
    UpShift2 = "True"
    UpShift3 = "False"
    UpShift4 = "False"
    EndIf
    ElseIf (Gear = 2) Then
    Shapes.HideShape(Gear1Message)
    Shapes.ShowShape(Gear2Message)
    Shapes.HideShape(Gear3Message)
    Shapes.HideShape(Gear4Message)
    If (GearDelay >= 67) Then
    CarSpeed = Gear2Min
    Shapes.HideShape(ShiftMessage)
    ElseIf (GearDelay <= 67 And GearDelay >= 34) Then
    CarSpeed = Gear2Min + 1
    ElseIf (GearDelay <= 34 And GearDelay >= 1) Then
    CarSpeed = Gear2Min + 2
    Shapes.ShowShape(ShiftMessage)
    UpShift2 = "True"
    UpShift3 = "True"
    UpShift4 = "False"
    EndIf
    ElseIf (Gear = 3) Then
    Shapes.HideShape(Gear1Message)
    Shapes.HideShape(Gear2Message)
    Shapes.ShowShape(Gear3Message)
    Shapes.HideShape(Gear4Message)
    If (GearDelay >= 67) Then
    CarSpeed = Gear3Min
    Shapes.HideShape(ShiftMessage)
    ElseIf (GearDelay <= 67 And GearDelay >= 34) Then
    CarSpeed = Gear3Min + 1
    ElseIf (GearDelay <= 34 And GearDelay >= 1) Then
    CarSpeed = Gear3Min + 2
    Shapes.ShowShape(ShiftMessage)
    UpShift2 = "True"
    UpShift3 = "True"
    UpShift4 = "True"
    EndIf
    ElseIf (Gear = 4) Then
    Shapes.HideShape(Gear1Message)
    Shapes.HideShape(Gear2Message)
    Shapes.HideShape(Gear3Message)
    Shapes.ShowShape(Gear4Message)
    Shapes.HideShape(ShiftMessage)
    CarSpeed = Gear4Min
    EndIf
    GearDelay = GearDelay - 1
    EndSub
    Tuesday, March 12, 2013 9:30 PM
  • Like this?

    Like this?  what do i do with Timer.Tick?  This will make it skid?

    If (CarMove) Then
    If(GraphicsWindow.LastKey = LeftKey) Then
      LastCarAngle = Math.Remainder(CarAngle - 5, 360)
    ElseIf (GraphicsWindow.LastKey = RightKey) Then
      LastCarAngle = Math.Remainder(CarAngle + 5, 360)
    EndIf

    EndIf

    CarX = Math.Remainder(Shapes.GetLeft(Car) + (Math.Cos(Math.GetRadians( LastCarAngle - 180)) * CarSpeed) + GWinWidth, GWinWidth)
     CarY = Math.Remainder(Shapes.GetTop(Car) + (Math.Sin(Math.GetRadians( LastCarAngle - 180)) * CarSpeed) + GWinHeight, GWinHeight)
    Shapes.Move(Car, CarX, CarY)

    Tuesday, March 12, 2013 9:35 PM
  • OK. I wrote a sample for you: HNB875.

    I didn't use Timer.Tick because DriveCar subroutine is called every Fps.

    Please see lines with comment "' nonkit".


    Nonki Takahashi

    Monday, March 18, 2013 11:54 PM
    Moderator