Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
X-Racer
#1
It's rude, it's crude, it's a classic that works most of the time. 
X-Racer is a text mode racing game where you are in a timed trial to get to the finish line.

Avoid the barriers and the sides or you are going to crash. The game is key driven but doesn't wait for you to press the enter key for long.

space bar -  to accelerate
     <       -  turn (screen) left
     >       -  turn (screen) right
     b        - to brake

(there's still a few problems with the code but if you don't explode at the start of the race you might be able to race to the end) 

Code: (Select All)
'X-racer is an old school racing game using text graphics only
'press spacebar to get that engine going and < or > to steer  b to brake!
_Title "X-RACER"
track$ = "####OOO................OOO####"
n = 13
trend = 0
obstacle = 10
Randomize Timer
Dim b$(2010)
Dim nn(2010)
start:
ask$ = "."
spd = 1
Do
    Cls
    For x = 1 To 2010
        A$ = String$(n, 32)
        b$(x) = A$ + track$
        If x > 100 And x Mod obstacle Then
            If Rnd * 100 < obstacle Then Mid$(b$(x), n + Int(3 + Rnd * 18), 1) = "O"
        End If

        n = n + Int(Rnd * 2) - Int(Rnd * 2) + trend
        If n < 2 Then n = 2
        If n > 35 Then n = 35
        nn(x) = n
        If Rnd * 100 < 3 Then
            Select Case Int(Rnd * 3)
                Case 0
                    trend = 0
                Case 1
                    trend = -1

                Case 2
                    trend = 1
            End Select
        End If
    Next x
    b$(1995) = A$ + "####O============O####"
    b$(1991) = A$ + "####O============O####"
    b$(1992) = A$ + "####O            O####"
    b$(1993) = A$ + "####O   FINISH   O####"
    b$(1994) = A$ + "####O            O####"
    b$(1995) = A$ + "####O============O####"
    For x = 1996 To 2010
        b$(x) = A$ + "####O            O####"
    Next x
    dp = nn(1) + 11
    op = dp
    For x = 1 To 2010
        _Limit 20
        If x > 10 Then Color 12: _PrintString (dp, 10), "X": Color 15
        _PrintString (op, 9), "."
        Print b$(x);
        If x > 12 Then
            If Mid$(b$(x - 13), dp, 1) = "O" Then GoTo crash
        End If
        op = dp
        If x Mod 20 = 0 Then
            Print " - "; x * 5
        Else
            Print
        End If
        If x > 10 Then
            gg = 0
            Do
                _Limit 60
                gg = gg + 1
                kk$ = InKey$
            Loop Until kk$ <> "" Or gg = 30 - spd
        End If
        If x = 12 Then t1 = Timer
        Select Case kk$
            Case ".", ">"
                op = dp
                dp = dp + 1

            Case ",", "<"
                op = dp
                dp = dp - 1.
            Case " "
                spd = spd + 1
                If spd > 28 Then spd = 28
            Case "b"
                spd = spd - 2
                If spd < 1 Then spd = 1
        End Select
        mph$ = "MPH : " + Str$(spd * 10)
        _PrintString (1, 2), mph$
    Next x
    t2 = Timer
    Print
    Print "Finished Course !"
    Print
    Print "Finish Time "; t2 - t1
    Input "Play again (Y or N) ", ask$
    ask$ = UCase$(ask$)
    If ask$ = "N" Then GoTo alldone
Loop
End
crash:
For c = 1 To 6
    _Limit 8
    Color 12
    For cx = dp - c To dp + c
        For cy = 10 - c To c + 10
            If Rnd * 6 < 3 Then _PrintString (cx, cy), "@"
        Next cy
    Next cx
Next c
Color 15
Print "YOU CRASHED"
Input "Play again (Y or N) ", ask$
ask$ = UCase$(ask$)
If ask$ = "N" Then GoTo alldone
GoTo start
alldone:
End
Reply


Messages In This Thread
X-Racer - by James D Jarvis - 12-22-2022, 06:28 PM
RE: X-Racer - by Pete - 12-22-2022, 07:15 PM
RE: X-Racer - by James D Jarvis - 12-22-2022, 07:44 PM
RE: X-Racer - by Pete - 12-22-2022, 07:47 PM
RE: X-Racer - by mnrvovrfc - 12-23-2022, 12:15 PM
RE: X-Racer - by James D Jarvis - 12-23-2022, 09:44 PM
RE: X-Racer - by mnrvovrfc - 12-23-2022, 11:08 PM
RE: X-Racer - by James D Jarvis - 12-24-2022, 05:55 PM



Users browsing this thread: 1 Guest(s)