Regarding to curving, I made a simple program to calculate and draw "road pavements" by using bezier curve formulation between two points..
Its written in basic, but maybe it gives an idea how to draw a road..
What does this program do? It calculates the points between starting and ending coordinates of the road with a bezier point in between to give curling effect.
On the screen, you'll see the start, end and bezier coordinates as black spot.
The program moves the bezier point itself, randomly. Also you can change the starting and bezier coordinates by keyboard with these keys :
Q and W
: X coordinate of the starting point
A and S
: X coordinate of the bezier point
Z and X
: Y coordinate of the bezier point
The calculation formula is like this
While T changes from 0 to 1, the X,Y coordinates changes from starting (SX,SY) to ending (EX,EY) by curling thru bezier (BX,BY) coordinates.
The video is cheated with overclocing the Oricutron unfortunately. Normal program runs so slowly as its in basic. The formulation is too hard for me to create it in machine code but its a start
Code: Select all
80 Z=126:GOSUB 200
100 IF K$="Q" THEN SX=SX-1:Q=1
110 IF K$="W" THEN SX=SX+1:Q=1
120 IF K$="A" THEN BX=BX-1:Q=1
130 IF K$="S" THEN BX=BX+1:Q=1
140 IF K$="Z" THEN BY=BY-1:Q=1
150 IF K$="X" THEN BY=BY+1:Q=1
153 IF RND(1)<RTHEN BX=BX-1:Q=1:GOTO 160
154 IF RND(1)<RTHEN BX=BX+1:Q=1:GOTO 160
155 IF RND(1)<RTHEN BY=BY-1:Q=1:GOTO 160
156 IF RND(1)<RTHEN BY=BY+1:Q=1
160 IF SX<2 OR SX>39 THEN SX=X1
162 IF BX<2 OR BY>39 THEN BX=X3
164 IF BY<1 OR BY>24 THEN BY=Y3
170 IF Q=0 THEN GOTO 90
175 X4=X1:Y4=Y1:X5=X2:Y5=Y2:X6=X3:Y6=Y3:Z=32:GOSUB 200
180 X4=SX:Y4=SY:X5=EX:Y5=EY:X6=BX:Y6=BY:Z=126:GOSUB 200
190 GOTO 90
200 FOR T=0 TO 1 STEP .05
230 PLOT X,Y,Z
241 IF Z=126 THEN Z=127
245 PLOT X4,Y4,Z
246 PLOT X5,Y5,Z
247 PLOT X6,Y6,Z