02-19-2024, 12:34 AM
Quote:If I may, I'd like to use this as a starter for a train game or similar (yes, I know it's been done, but it should be a good exercise).
+1 Absolutely, this is starter code to lay the tracks so to speak to who knows what app?
Would you believe I don't know of a train game. I look forward to seeing what you can do with this, thanks.
Oh wait I do know of the Peace Train:
Code: (Select All)
_Title "Peace Train" 'from old post 2019-03-24 mod B+ 2019-03-26
' play this: https://www.youtube.com/watch?v=UkTQri3a4Gg
Randomize Timer
Screen _NewImage(800, 600, 32)
_ScreenMove 200, 20
'background B+ mod
Dim Shared scape&
LoadLandscape
scapeWidth = _Width(scape&)
scapeHeight = _Height(scape&)
'PRINT scapeWidth, scapeHeight
'train stuff Code Hunter and Fellippe?
Dim temp As String
Dim Shared Pattern As String
Dim Shared Train(7, 10) As String
Dim Shared Coal(10) As String
Dim Smoke1 As String
Dim Smoke2 As String
Dim Smoke3 As String
Dim Smoke4 As String
Smoke1 = Space$(16) + "@@@@"
Smoke2 = Space$(16) + " @ @ "
Smoke3 = Space$(16) + " @@ @@ @ @ @ "
Smoke4 = Space$(16) + " @@ @@ @ @ @ "
LoadTrain
col = 1
row = 7
p = 6
le = scapeWidth - 800
While 1
Cls
' background stuff
If le + 800 > scapeWidth Then
te = scapeWidth - le
_PutImage (0, 0)-(te, scapeHeight), scape&, 0, (scapeWidth - te, 0)-(scapeWidth, scapeHeight)
_PutImage (te, 0)-(800, scapeHeight), scape&, 0, (0, 0)-(800 - te, scapeHeight)
Else
_PutImage (0, 0)-(800, scapeHeight), scape&, 0, (le, 0)-(le + 800, scapeHeight)
End If
'_PRINTSTRING (5, 5), STR$(le)
le = le - 1
If le < 0 Then le = scapeWidth
'train stuff
Color _RGBA32(255, 255, 255, 200), _RGBA32(0, 0, 0, 0)
For j = 0 To 9
'_PRINTSTRING (0, 16 * j + 112), MID$(Train(p, j + 1), i, 80)
_PrintString (64, 16 * j + 442), Mid$(Train(p, j + 1), 1, 84)
Next
'If i < Len(Smoke4) Then
' If fcount Mod 30 < 15 Then
' _PrintString (0, 96 + 300), Mid$(Smoke1, i, 80)
' _PrintString (0, 64 + 300), Space$(8) + Mid$(Smoke1, i, 80)
' _PrintString (0, 32 + 300), Space$(24) + Mid$(Smoke3, i, 80)
' Else
' _PrintString (0, 80 + 280), Space$(4) + Mid$(Smoke1, i, 80)
' _PrintString (0, 48 + 280), Space$(12) + Mid$(Smoke2, i, 80)
' _PrintString (0, 32 + 280), Space$(24) + Mid$(Smoke4, i, 80)
' End If
'End If
fcount = fcount + 1
If fcount = 60 Then fcount = 0
If fcount Mod 6 = 0 Then
col = col + 1: i = i + 1
If col = Len(Pattern) + 1 Then col = 1
If i > Len(Train(1, 1)) - 80 Then i = 1
p = Val(Mid$(Pattern, col, 1))
End If
peace 167, 579, 18, a
peace 215, 579, 18, a + _Pi / 2
peace 263, 579, 18, a + _Pi
peace 311, 579, 18, a + _Pi * 1.5
peace 530, 591, 6, a + _Pi * .25
peace 578, 591, 6, a + _Pi * .75
peace 634, 591, 6, a + _Pi * 1.25
peace 682, 591, 6, a + _Pi * 1.75
peace 90, 585, 12, a + _Pi * .66
peace 386, 585, 12, a + _Pi * 1.66
peace 128, 419, 12, -a + _Pi * .1
peace 175, 386, 10, -a - _Pi * .3
peace 281, 351, 9, -a + _Pi * .5
peace 328, 321, 10, -a + _Pi * .7
peace 401, 318, 7, -a + _Pi * .9
peace 477, 307, 9, -a + _Pi * 1.1
peace 562, 317, 6, -a + _Pi * 1.5
a = a - _Pi / 36
For i = 1 To 5
peace 608, 518, 28, 0
Next
_Display
_Limit 90 '<<< EDIT
Wend
Sub LoadLandscape
cur& = _Dest
xmax = 800 * 6: ymax = 600
scape& = _NewImage(xmax, ymax, 32)
_Dest scape&
For i = 0 To ymax
midInk 0, 0, 128, 128, 128, 200, i / ymax
Line (0, i)-(xmax, i)
Next
'the land
startH = ymax - 200
rr = 70: gg = 70: bb = 90
For mountain = 1 To 6
Xright = 0
y = startH
Color _RGB(rr, gg, bb)
While Xright < xmax - 50
' upDown = local up / down over range, change along Y
' range = how far up / down, along X
upDown = (Rnd * .8 - .4) * (mountain * .5)
range = Xright + rand%(15, 25) * 2.5 / mountain
If range > xmax - 50 Then range = xmax - 50
lastx = Xright - 1
For x = Xright To range
test = y + upDown
If Abs(test - startH) < .1 * startH Then y = test
Line (lastx, y)-(x, ymax), , BF 'just lines weren't filling right
lastx = x
Next
Xright = range
Wend
x = lastx + 1
While x <= xmax
y = y + (startH - y) / 40
Line (lastx, y)-(x, ymax), , BF 'just lines weren't filling right
lastx = x
x = x + 1
Wend
rr = rand%(rr - 15, rr): gg = rand%(gg - 15, gg): bb = rand%(bb - 25, bb)
If rr < 0 Then rr = 0
If gg < 0 Then gg = 0
If bb < 0 Then bb = 0
startH = startH + rand%(5, 20)
Next
_Dest cur&
End Sub
Function rand% (lo%, hi%)
rand% = Int(Rnd * (hi% - lo% + 1)) + lo%
End Function
Sub midInk (r1%, g1%, b1%, r2%, g2%, b2%, fr##)
Color _RGB(r1% + (r2% - r1%) * fr##, g1% + (g2% - g1%) * fr##, b1% + (b2% - b1%) * fr##)
End Sub
Sub LoadTrain
Dim t As String
For j = 1 To 10
Read t: Coal(j) = t
Next
For i = 1 To 6
For j = 1 To 10
Read t: Train(i, j) = t + Coal(j)
Next
Next
For i = 1 To Len(t)
' Reverse: "312465"
t = Mid$("564213", i, 1)
Pattern = Pattern + t + t
Next
Exit Sub
Data " "
Data " "
Data " _________________ "
Data " _| \_____A "
Data " =| | "
Data " -| | "
Data "__|________________________|_"
Data "|__________________________|_"
Data " |_D__D__D_| |_D__D__D_| "
Data " \_/ \_/ \_/ \_/ "
Data " ==== ________ ___________"
Data " _D _| |_______/ \__I_I_____===__|_________|"
Data " |(_)--- | H\________/ | | =|___ ___| "
Data " / | | H | | | | ||_| |_|| "
Data " | | | H |__--------------------| [___] | "
Data " | ________|___H__/__|_____/[][]~\_______| | "
Data " |/ | |-----------I_____I [][] [] D |=======|__"
Data "__/ =| o |=-O=====O=====O=====O \ ____Y___________|__"
Data " |/-=|___|= || || || |_____/~\___/ "
Data " \_/ \__/ \__/ \__/ \__/ \_/ "
Data " ==== ________ ___________"
Data " _D _| |_______/ \__I_I_____===__|_________|"
Data " |(_)--- | H\________/ | | =|___ ___| "
Data " / | | H | | | | ||_| |_|| "
Data " | | | H |__--------------------| [___] | "
Data " | ________|___H__/__|_____/[][]~\_______| | "
Data " |/ | |-----------I_____I [][] [] D |=======|__"
Data "__/ =| o |=-~O=====O=====O=====O\ ____Y___________|__"
Data " |/-=|___|= || || || |_____/~\___/ "
Data " \_/ \__/ \__/ \__/ \__/ \_/ "
Data " ==== ________ ___________"
Data " _D _| |_______/ \__I_I_____===__|_________|"
Data " |(_)--- | H\________/ | | =|___ ___| "
Data " / | | H | | | | ||_| |_|| "
Data " | | | H |__--------------------| [___] | "
Data " | ________|___H__/__|_____/[][]~\_______| | "
Data " |/ | |-----------I_____I [][] [] D |=======|__"
Data "__/ =| o |=-~~\ /~~\ /~~\ /~~\ ____Y___________|__"
Data " |/-=|___|=O=====O=====O=====O |_____/~\___/ "
Data " \_/ \__/ \__/ \__/ \__/ \_/ "
Data " ==== ________ ___________"
Data " _D _| |_______/ \__I_I_____===__|_________|"
Data " |(_)--- | H\________/ | | =|___ ___| "
Data " / | | H | | | | ||_| |_|| "
Data " | | | H |__--------------------| [___] | "
Data " | ________|___H__/__|_____/[][]~\_______| | "
Data " |/ | |-----------I_____I [][] [] D |=======|__"
Data "__/ =| o |=-~~\ /~~\ /~~\ /~~\ ____Y___________|__"
Data " |/-=|___|= O=====O=====O=====O|_____/~\___/ "
Data " \_/ \__/ \__/ \__/ \__/ \_/ "
Data " ==== ________ ___________"
Data " _D _| |_______/ \__I_I_____===__|_________|"
Data " |(_)--- | H\________/ | | =|___ ___| "
Data " / | | H | | | | ||_| |_|| "
Data " | | | H |__--------------------| [___] | "
Data " | ________|___H__/__|_____/[][]~\_______| | "
Data " |/ | |-----------I_____I [][] [] D |=======|__"
Data "__/ =| o |=-~~\ /~~\ /~~\ /~~\ ____Y___________|__"
Data " |/-=|___|= || || || |_____/~\___/ "
Data " \_/ \O=====O=====O=====O_/ \_/ "
Data " ==== ________ ___________"
Data " _D _| |_______/ \__I_I_____===__|_________|"
Data " |(_)--- | H\________/ | | =|___ ___| "
Data " / | | H | | | | ||_| |_|| "
Data " | | | H |__--------------------| [___] | "
Data " | ________|___H__/__|_____/[][]~\_______| | "
Data " |/ | |-----------I_____I [][] [] D |=======|__"
Data "__/ =| o |=-~~\ /~~\ /~~\ /~~\ ____Y___________|__"
Data " |/-=|___|= || || || |_____/~\___/ "
Data " \_/ \_O=====O=====O=====O/ \_/ "
End Sub
Sub lyne (x0, y0, lngth, ra, thic, c As _Unsigned Long)
Dim x As Integer, y As Integer, l As Integer
While l < lngth
l = l + 1: x = x0 + l * Cos(ra): y = y0 + l * Sin(ra)
For radius = 0 To thic / 2
Circle (x, y), radius, c, BF
Next
Wend
End Sub
Sub peace (x0, y0, r, raRot) ' 12 is about smallest
thic = r / 5.5
For rr = r - thic To r Step 1
Circle (x0, y0), rr
Next
lyne x0, y0, r - .5 * thic, _Pi * 1.5 + raRot, thic, &H11FFFFFF
lyne x0, y0, r - .5 * thic, _Pi * .5 + raRot, thic, &H11FFFFFF
lyne x0, y0, r - .5 * thic, _Pi * .25 + raRot, thic, &H11FFFFFF
lyne x0, y0, r - .5 * thic, _Pi * .75 + raRot, thic, &H11FFFFFF
End Sub
b = b + ...