Post by cundo on May 29, 2020 16:20:19 GMT
I did this again, since I lost the old code.
You want the original qbasic source code? Here it is
In my code there is an overlap at the top. Can't remember why that happens, but changing and increasing the variable ResY fixes it.
You want the original qbasic source code? Here it is
In my code there is an overlap at the top. Can't remember why that happens, but changing and increasing the variable ResY fixes it.
' Converted from QBASIC to Just BASIC v2 by cundo (May-2020), this is a new convertion
' since I lost the old one.
' Find this code, and discussion at: http://justbasiccom.proboards.com
' ************************
'Road Demonstration Program by Louis Gorenfeld 2010
'This program is intended to show concepts described at Lou's Pseudo 3d Page
'http://www.extentofthejam.com/pseudo
'It defaults to generating 80 frames during which the road curves right,
'uncurves, and repeats.
'I've left much detail off of the road. You can draw them in around line 70!
'Happy coding! :)
NOMAINWIN
RoadLines = 99
ScrollSpeed = 10
RoadY = -1 'arbitrary
ResX = 320
ResY = 200
PlrLine = 8 'What line is the player sprite on?
DIM ZMap(RoadLines)
' Initialize ZMap
FOR A = 1 TO RoadLines
ZMap(A) = RoadY / (A - (ResY / 2))
NEXT A
' Normalize ZMap so the line with the player on it is scale=1 (or would be
' If we had a player sprite :))
b = 1 / ZMap(PlrLine)
b = b * 100 'in percents because QBasic's MOD is lame
FOR A = 1 TO RoadLines
ZMap(A) = ZMap(A) * b
NEXT A
WindowWidth = 320 : WindowHeight = 240
UpperLeftX=int((DisplayWidth-WindowWidth)/2)
UpperLeftY=int((DisplayHeight-WindowHeight)/2)
open "ROAD.BAS" for graphics_nsb as #main
#main "down; size 1; color cyan"
'#main "home"
'#main "posxy x1 y1"
#main "trapclose [quit]"
' Draw the road
X =0
DX =0
DDX =0
HalfWidth =0
SegY =0
NextStretch$ = "Straight"
WidthStep = 1
FOR A = 1 TO ResY - RoadLines
'LINE (0, A)-(ResX - 1, A), 9
#main "line "; 0 ;" "; A;" ";ResX - 1;" ";A
NEXT A
TexOffset = 100
SegY = RoadLines
DX = 0
DDX = .02 ' This controls the steepness of the curve
FOR C = 1 TO 80
' Set up the frame
X = ResX / 2
DX = 0
HalfWidth = 120
ScreenLine = ResY - 1
FOR A = 1 TO RoadLines
scan
IF (ZMap(A) + TexOffset) MOD 100 > 50 THEN
GrassColor$ = "darkgreen"
RoadColor$ = "lightgray"
ELSE
GrassColor$ = "green"
RoadColor$ = "darkgray"
END IF
'LINE (X - HalfWidth, ScreenLine)-(X + HalfWidth, ScreenLine), RoadColor
#main "color ";RoadColor$
#main "line ";X - HalfWidth;" ";ScreenLine;" ";X + HalfWidth;" ";ScreenLine
'LINE (0, ScreenLine)-(X - HalfWidth, ScreenLine), GrassColor
#main "color ";GrassColor$
#main "LINE "; 0;" "; ScreenLine;" ";X - HalfWidth ;" "; ScreenLine
'LINE (X + HalfWidth, ScreenLine)-(ResX - 1, ScreenLine), GrassColor
#main "LINE ";X + HalfWidth;" "; ScreenLine; " "; ResX - 1; " ";ScreenLine
HalfWidth = HalfWidth - WidthStep
ScreenLine = ScreenLine - 1
select case NextStretch$
case "Straight"
IF A > SegY THEN
DX = DX + DDX
END IF
case "Curved"
IF A < SegY THEN
DX = DX + DDX
END IF
end select
X = X + DX
NEXT A
' Wrap positions (fractional):
TexOffset = TexOffset + ScrollSpeed
WHILE TexOffset >= 100
TexOffset = TexOffset - 100
WEND
SegY = SegY - 5 ' Decrease SegY by an arbitrary amount. Adjust to taste.
WHILE SegY < 0
SegY = SegY + RoadLines
select case NextStretch$
case "Curved"
NextStretch$ = "Straight"
case "Straight"
NextStretch$ = "Curved"
end select
WEND
NEXT C
wait
[quit]
close #main : end