Page 1 of 2

[24 Feb 2011] road demo

Posted: Sat Jun 13, 2020 5:32 pm
by lazi
Note: This is an archived post that was originally sent to the Hollywood mailing list on Thu, 24 Feb 2011 23:21:13 +0100

Hi!

Here is a nice road demo. Have fun! (It would be nice to have a hws source deposit in any form, where we can share sources categorized.)

Let me know what do you think about this!

Code: Select all

/*
Road Demonstration Program by Louis Gorenfeld 2010

Hollywood port by Lazi

This program is intended To show concepts described at Lou's
Pseudo 3d Page
http://www.gorenfeld.net/lou/pseudo

It defaults To generating 80 frames during which the road
curves right,
uncurves, and repeats.  It lasts several seconds running
under DOSBox at
12000 cycles and 0 frameskip on a Mac Mini 2.0GHz dual core

I've left much detail off of the road.  You can draw them in
around Line 70!
Happy coding! :)
*/                            

@DISPLAY {width=320, height=200}

BeginDoubleBuffer

Const #RoadLines = 89
      ScrollSpeed = 10
Const #RoadY = -1        ;arbitrary
Const #ResX = 320
Const #ResY = 200
Const #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

; 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

; Draw the road

NextStretch$ = "Straight"

Const #WidthStep = 1

SetFillStyle(#FILLCOLOR)
Box(0,0,#ResX,#ResY-#RoadLines,#BLUE)

TexOffset = 100
SegY =  #RoadLines
DDX = .03    ; This controls the steepness of the curve

CreateBrush(1,320,1,#GRAY)
SelectBrush(1)
Line(0,0,20,0,#WHITE)
Line(300,0,320,0,#WHITE)
EndSelect

CreateBrush(2,320,1,#GRAY)
SelectBrush(2)
Line(0,0,20,0,#RED)
Line(300,0,320,0,#RED)
Line(158,0,162,0,#WHITE)
EndSelect

Function p_road()

; Set up the frame
X = #ResX / 2
DX = 0
HalfWidth = 120
ScreenLine = #ResY

For A = 0 To #RoadLines
        If (ZMap[A] + TexOffset) % 100 > 50
                GrassColor = #GREEN
                RoadColor = #GRAY
                br=1
        ELSE
                GrassColor = #OLIVE
                RoadColor = #SILVER
                br=2
        EndIf

        sx=((X + HalfWidth)-(X - HalfWidth))/320

        DisplayBrush (br,X - HalfWidth, ScreenLine, {scalex=sx,smoothscale=False})

        Line (0, ScreenLine, X - HalfWidth, ScreenLine, GrassColor)
        Line (X + HalfWidth, ScreenLine, #ResX - 1, ScreenLine, GrassColor)
        HalfWidth = HalfWidth - #WidthStep
        ScreenLine = ScreenLine - 1

        If NextStretch$ = "Straight"
                If A > SegY
                       ;DX = DX - DDX
                EndIf
        ElseIf NextStretch$ = "Curved"
                If A < SegY
                       ;DX = DX - DDX
                EndIf
        EndIf
         MX=(MouseX()-160)/160
        X = X + DX + MX
Next

; Wrap positions (fractional):

TexOffset=Wrap(TexOffset + ScrollSpeed, 0, 100)

SegY = SegY - 5  ; Decrease SegY by an arbitrary amount. 
Adjust to taste.
WHILE SegY < 0
        SegY = SegY + #RoadLines
        If NextStretch$ = "Curved"
                NextStretch$ = "Straight"
        ElseIf NextStretch$ = "Straight"
                NextStretch$ = "Curved"
        EndIf
WEND

Flip
EndFunction

Function p_key(msg)
     If IsKeyDown("UP")
        scrollspeed=Min(scrollspeed*1.1,40)
     Else
        scrollspeed=Max(scrollspeed-.5,10)
     EndIf
    
EndFunction

SetInterval(2,p_key,1000/10)
SetInterval(1,p_road,1000/30)

Repeat
    WaitEvent
Forever                   

[24 Feb 2011] Re: road demo

Posted: Sat Jun 13, 2020 5:32 pm
by Severin
Note: This is an archived post that was originally sent to the Hollywood mailing list on Thu, 24 Feb 2011 22:37:00 +0000

Hello

Works great here after I fixed a few formatting problems caused by yam wrapping comments onto 2 lines.

Only little comment I have is it uses the screens mouse co-ordinates instaed of the windows.

Maybe an lha attachment would be better in future?

[25 Feb 2011] Re: road demo

Posted: Sat Jun 13, 2020 5:32 pm
by lazi
Note: This is an archived post that was originally sent to the Hollywood mailing list on Fri, 25 Feb 2011 00:09:40 +0100

Hello Nick
Hello

Works great here after I fixed a few formatting problems caused by yam wrapping comments onto 2 lines.

Only little comment I have is it uses the screens mouse co-ordinates instaed of the windows.
Good point, however I am watching it on fullscreen :) I have a 320x200 screenmode. It looks great on a 19" TFT.
Maybe an lha attachment would be better in future?
Dunno if the list can handle attachments, but I will try.

What about a Pitstop II remake?

[24 Feb 2011] Re: Re: road demo

Posted: Sat Jun 13, 2020 5:32 pm
by xabierpayet
Note: This is an archived post that was originally sent to the Hollywood mailing list on Thu, 24 Feb 2011 23:39:02 +0000 (GMT)

it´s slow in my eeepc uae but work xD

will be nice some 3d acceleration in hollywood or 3d library as OpenGl but rudimentary xD

[24 Feb 2011] Re: road demo

Posted: Sat Jun 13, 2020 5:32 pm
by Severin
Note: This is an archived post that was originally sent to the Hollywood mailing list on Thu, 24 Feb 2011 23:39:19 +0000

Hello
Good point, however I am watching it on fullscreen :) I have a 320x200 screenmode. It looks great on a 19" TFT.
Lucky you, my 20" TFT doesn't handle 320x200, 640x480 is the minimum it will work with :(
Dunno if the list can handle attachments, but I will try.

What about a Pitstop II remake?
Never heard of it but then I'm not a gamer.

[25 Feb 2011] Re: road demo

Posted: Sat Jun 13, 2020 5:32 pm
by lazi
Note: This is an archived post that was originally sent to the Hollywood mailing list on Fri, 25 Feb 2011 10:20:32 +0100

Hello xabier
it?s slow in my eeepc uae but work xD
You are using the wrong device :) AmigaOne-s aren't that powerhorses, but it runs that well.

Try the win32 native from: www.kezdobetu.hu/hollywood/road.exe
will be nice some 3d acceleration in hollywood or 3d library as OpenGl but rudimentary xD
That would be surely great! Let's hope user base will grow that high to make such developments happen.

[25 Feb 2011] Re: road demo

Posted: Sat Jun 13, 2020 5:32 pm
by lazi
Note: This is an archived post that was originally sent to the Hollywood mailing list on Fri, 25 Feb 2011 10:27:22 +0100

Hello xabier
it?s slow in my eeepc uae but work xD
The following lines makes brush scaling which is slow generally.

Try to change it to the following:

Code: Select all

Line (X - HalfWidth, ScreenLine, X + HalfWidth, ScreenLine,#GRAY) 
It should be faster, but no fancy road decoration.:)

[25 Feb 2011] Re: road demo

Posted: Sat Jun 13, 2020 5:32 pm
by Juan Carlos
Note: This is an archived post that was originally sent to the Hollywood mailing list on Fri, 25 Feb 2011 10:20:37 +0000 (GMT)

Thank you for your good example.

Best regards from Juan Carlos.

[25 Feb 2011] Re : road demo

Posted: Sat Jun 13, 2020 5:32 pm
by ArtBlink
Note: This is an archived post that was originally sent to the Hollywood mailing list on Fri, 25 Feb 2011 20:24:04 +0000 (GMT)

Excellent ;-) good jobs

[27 Feb 2011] Re : road demo

Posted: Sat Jun 13, 2020 5:32 pm
by ArtBlink
Note: This is an archived post that was originally sent to the Hollywood mailing list on Sun, 27 Feb 2011 21:26:38 +0000 (GMT)

Hello, I have just see this, replace :

Code: Select all

DisplayBrush (br,X - HalfWidth, ScreenLine, {scalex=sx,smoothscale=False})

Line (0, ScreenLine, X - HalfWidth, ScreenLine, GrassColor)
Line (X + HalfWidth, ScreenLine, #ResX - 1, ScreenLine, GrassColor)
by

Code: Select all

Line (0, ScreenLine, 639 , ScreenLine,GrassColor)DisplayBrush (br,X - HalfWidth, ScreenLine,{scalex=sx,smoothscale=False})
You win tracing time and replace :

Code: Select all

If IsKeyDown("UP")
scrollspeed=Min(scrollspeed*1.1,40)
Else
scrollspeed=Max(scrollspeed-.5,10)
EndIf
By:

Code: Select all

If IsKeyDown("UP")
   If scrollspeed<40 Then scrollspeed=scrollspeed*1.1
Else
   If scrollspeed>0
       scrollspeed=scrollspeed-0.5
       If scrollspeed<0 Then scrollspeed=0
   EndIf
EndIf
Why? because the execution speed of Min() and Max() command is slower than "if" test... and this :

Code: Select all

For A = 0 To #RoadLines
If (ZMap[A] + TexOffset) % 100 > 50
GrassColor = #GREEN
RoadColor = #GRAY
br=1
ELSE
GrassColor = #OLIVE
RoadColor = #SILVER
br=2
EndIf
BY

Code: Select all

For Local A = 0 To #RoadLines
If (ZMap[A] + TexOffset) % 100 > 50
GrassColor = #GREEN
RoadColor = #GRAY
br=1
ELSE
GrassColor = #OLIVE
RoadColor = #SILVER
br=2
EndIf
On 6800x0 AOS3.x you multiply by 2 the execution speed of the boucle just if you indicated LOCAL ;-)on other system, you win approximately 25% of CPU time