Soft Scroll

Do you have something to share with us? A tip for newbies, perhaps? Post it here.
Post Reply
peter
Active Member
Posts: 123
Joined: Mon Oct 22, 2007 2:31 pm

Soft Scroll

Post by peter » Sun Aug 24, 2008 8:43 pm

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
Attachments
Media.rar
(131.07 KiB) Downloaded 271 times
Last edited by peter on Mon Aug 25, 2008 7:53 pm, edited 3 times in total.

User avatar
temu92
Web Developer
Web Developer
Posts: 1226
Joined: Mon Aug 27, 2007 9:56 pm
Location: Gamindustri
Contact:

Re: Soft Scroll

Post by temu92 » Sun Aug 24, 2008 9:00 pm

Please use [code][/code] tags.

User avatar
valscion
Moderator
Moderator
Posts: 1587
Joined: Thu Dec 06, 2007 8:46 pm
Location: Espoo
Contact:

Re: Soft Scroll

Post by valscion » Mon Aug 25, 2008 4:50 pm

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]
cbEnchanted, uudelleenkirjoitettu runtime. Uusin versio: 0.4.1 — Nyt myös sorsat GitHubissa!
NetMatch - se kunnon nettimättö-deathmatch! Avoimella lähdekoodilla varustettu
vesalaakso.com

Post Reply