Page 1 of 1

Soft Scroll

Posted: Sun Aug 24, 2008 8:43 pm
by peter
Hi there,

Soft scroll routine for your own games.
Speed by changing of yScr and xScr.

Code: Select all

SCREEN 320,240,16,2
FrameLimit 60

Dim yGraph,xGraph,xScr,yScr
Dim x,y,bx,ax,cx,dx
Dim zG#,b,ch
Dim Map(1200)

s2 = LoadAnimImage("Media/Mine.bmp",16,16,0,8)
s1 = LoadImage    ("Media/Back.png")
ch = PlaySound    ("Media/Kollaps.mod") 
yGraph = 240/16:xGraph = 320/16 

'Fill Play field with 0 and 1 
For y = 0 To 29
For x = 0 To 39 
bx = y*40 + x
Map(bx) = Rand(0,1)  
Next x
Next y

'Scrolling here   
While EscapeKey() = False
DrawImage s1,0,0
dx = xScr /16 
cx = yScr /16 
For y = cx To cx + yGraph
For x = dx To dx + xGraph
bx = y*20 + x
If Map(bx) =1 Then 
DrawImage s2,x*16 - xScr,y*16 - yScr,ax 
EndIf
Next x
Next y 
zG# = zG# + .2: ax = Int(zG#)
If ax =8 Then 
ax =0: zG# =0
EndIf

'Movement here
If LeftKey()  Then xScr = xScr -2 
If RightKey() Then xScr = xScr +2 
If UpKey()    Then yScr = yScr -2 
If DownKey()  Then yScr = yScr +2 
If xScr < 0   Then xScr = 0
If yScr < 0   Then yScr = 0 
If xScr > 320 Then xScr = 320 
If yScr > 240 Then yScr = 240 
Locate 0 ,0 :Print "X:" + xScr  
Locate 64,0 :Print "Y:" + yScr
DrawScreen 
Wend
StopSound ch
DeleteSound ch
End

Re: Soft Scroll

Posted: Sun Aug 24, 2008 9:00 pm
by temu92
Please use [code][/code] tags.

Re: Soft Scroll

Posted: Mon Aug 25, 2008 4:50 pm
by valscion
Quote from Temu92: "Please use [code][/code] tags."

And use them like this:
[code]Your code here, the whole bunch of it.
All CB-code here.
For real.[/code]