Code: Select all
REM 3D looking - sliding - linegrid
REM Basic 3.3 / iPhone 4 / iOS 5.0.1
REM v3.00 by DrChip
REM ported from:
REM http://www.local-guru.net/blog/2010/9/2 ... processing
REM change s to inc./dec. speed
REM change arc TO spead the lines apart
REM or closer.
REM touch screen in the center, left and
REM right to simulate turning -
REM its not smooth yet.
REM added comments, direction, color, spread, touch screen for direction toggle, speed and cleaned a bit. etc...
REM fixed horizon movement and added ipad or iphone auto support
REM smoother!
REM ported from my misoft basic collection to sB 5.7 / iPhone 6+
REM enjoy!
REM buttons
' ⬆️
'⬅️ :shock: ➡️
' ⬇️
init:
sw=SCREEN_WIDTH()
sh=SCREEN_HEIGHT()
ox=sw/3
oy=sh/2
GRAPHICS
GOSUB drawpad
' screen area
scw = SCREEN_WIDTH()
sch = SCREEN_HEIGHT()
' center screen
'-.05 left TO 1.05 right, .5 center
csw = scw*.5
csh = sch/2
' grid vars
s = 5 'speed of lines 1-5
c1 = 0 ' default color red
c2 = 1 ' default color green
c3 = 0 ' default color blue
arcc = 80 ' spread of verical lines 10-150
hh = 3 'horizon line height
bh = 3 'bottom line height
direction = 1 ' default direction (forward)
horizon = .5 ' default center
IF scw > 700 THEN
hlines = 24 ' 18 for iphone 6+
vlines = 40 ' 20 for iphone 6+
idevice$ = "iPad"
ELSE
hlines = 24' 24 for ipad
vlines = 20 ' 40 for ipad
idevice$ = "iPhone"
END IF
'loop grid calculations and display
LOOP:
' remove old lines
GRAPHICS CLEAR 0,0,0 ' remove old lines
REFRESH OFF
DRAW COLOR 1,1,1
DRAW TEXT "X Toggle Direction⬅️left ➡️right" AT 0,0
DRAW TEXT "Device: "&idevice$ AT 0,40
'horizon = horizon + .05
pressed=0
IF BUTTON_PRESSED("press") AND pressed=0 THEN
'horizon = -.05
direction = -direction
pressed=1
END IF
IF BUTTON_PRESSED("left") AND pressed=0 THEN
horizon = horizon - .05
csw = scw*horizon
pressed=1
END IF
IF BUTTON_PRESSED("right") AND pressed=0 THEN
horizon = horizon + .05
csw = scw*horizon
pressed=1
END IF
pressed=0
'floor movement
f = f + direction
' set green color
DRAW COLOR c1,c2,c3
' horizon lines
DRAW SIZE hh
DRAW LINE 0,csh TO scw,csh 'hh
'bottom line
DRAW SIZE bh
DRAW LINE 0,sch TO scw,sch 'bh
' draw grid lines
FOR i =0 TO vlines '(lines left to right x2)
DRAW LINE csw + i*10,csh TO csw + i*arcc+i, sch
DRAW LINE csw - i*10,csh TO csw - i*arcc,sch
NEXT i
'horizontal lines (mid screen to bottom)
FOR i = 1 TO hlines
o = ((2*i + 1)/s)*(f%s) 'MOD(f,s)
DRAW LINE 0*i, csh + i*i + o TO scw*i, csh+ i*i + o
NEXT i
REFRESH ON
GOTO LOOP
drawpad:
'BUTTON "up" TEXT "⬆️" AT 45+ox,15+oy
BUTTON "press" TEXT "X" AT 45+ox,50+oy
'BUTTON "down" TEXT "⬇️" AT 45+ox,85+oy
BUTTON "left" TEXT "⬅️" AT 0+ox,50+oy
BUTTON "right" TEXT "➡️" AT 90+ox,50+oy
RETURN