Main Menu

WIP : A Good Spy's Last Day

Started by hartnell, May 08, 2008, 04:51:40 AM

Previous topic - Next topic

hartnell

Here's the beginnings of my scrolling road tile engine for a spy hunter clone called "A Good Spy's Last Day."

The next step is to get it to load horizontal lines from an array at different times.


OpenScreen 480,640,32,True
SetFPS 60

Global rOff = 0 ; road offset
Global roadSpeed = 4

Dim road(14,20)

Dim roadSection(1,14)

For i = 0 to GetArrayElements(road(),1)
roadSection(1,i) = ReadData()
Next

For y = 0 to GetArrayElements(road(),2)
For x = 0 to GetArrayElements(road(),1)
road(x,y) = roadSection(1,x)
Next
Next


road(5,2) = 0

PSub newRoad()
For y = GetArrayElements(road(),2)-1 to 1
For x = 0 to GetArrayElements(road(),1)
road(x,y) = road(x,y-1)
Next
Next

For x = 0 to GetArrayElements(road(),1)
road(x,0) = roadSection(1,x)
Next
EndPSub

PSub displayRoad()
    For y = 0 to GetArrayElements(road(),2)
        For x = 0 to GetArrayElements(road(),1)
        Select road(x,y)
        Case 1
        tileColor = $242424
        Case 2
        tileColor = $009600
        Case 3
        tileColor = $B66D24
        Default
        tileColor = $FF00FF
        EndSelect
               BoxC x*32, y*32+rOff-32, x*32+32, y*32+rOff, True, tileColor
        Next
    Next
EndPSub 

PSub updateRoad()
rOff = rOff + roadSpeed
If rOff = 32
rOff = 0
For y = GetArrayElements(road(),2) to 1 step -1
For x = 0 to GetArrayElements(road(),1)
road(x,y) = road(x,y-1)
Next
Next

For x = 0 to GetArrayElements(road(),1)
road(x,0) = roadSection(1,x)
Next
EndIf
EndPSub

Do
Cls 0
displayRoad()
updateRoad()
Sync
Loop

; starting road section

Data 2, 2, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 2, 2

; wide to narrow

Data 2, 2, 2, 3, 1, 1, 1, 1, 1, 1, 1, 3, 2, 2, 2

Data 2, 2, 2, 2, 3, 1, 1, 1, 1, 1, 3, 2, 2, 2, 2

; narrow

Data 2, 2, 2, 2, 2, 3, 1, 1, 1, 3, 2, 2, 2, 2, 2


-- Shawn