BlitzCoder Essentials
•
Home Page
•
About BlitzCoder
•
Contributors
•
Terms of Use
•
Email Us
Main Areas
•
BlitzCoder Chat
•
Discussions
•
Articles/Tutorials
•
Code Database
•
Link Database
•
Showcase Area
•
Worklogs
•
Competitions
Special Areas
•
Undocumented
Other Blitz Sites
•
Blitz Basic Home
•
Blitz Showcase
•
BlitzPlay Library
Forum Login
Username:
Password:
•
Register Now!
BlitzCoder Code Archives Page
Main Codes Page
"Map scroll based on large tiled image"
, by begemoth
I included little bit comments.
Please post comments to this code.
Code
;Map scroll with tiles based on image drawing Global ScrW=800 Global ScrH=600 Global Mw=40;gorizontal number of tiles Global Mh=40;vertical number of tiles Global mapsx = Mw*32;map width size Global mapsy = Mw*32;map height size Global tiles=32;tile size Global mapx;positions from which to draw portion of map image Global mapy; Global MapIm Graphics ScrW,ScrH Gosub loadIm createmap(Mw,Mh) SetBuffer BackBuffer() While Not KeyDown(1) control() Flip Wend End ;map create , creates a large image and draws it's portions to the screen Function CreateMap(Mw,Mh) MapIm=CreateImage(mapsx,mapsy,1,2) SetBuffer ImageBuffer(MapIm) For i=0 To Mw*Mh+Mw DrawImage(tile1,x,y) x=x+tiles If x>mapsx x=0 y=y+tiles EndIf Next End Function ;keyboard control left,right etc moves map Function control() If KeyDown(205) Then mapx=mapx+5 If KeyDown(203) Then mapx=mapx-5 If KeyDown(200) Then mapy=mapy-5 If KeyDown(208) Then mapy=mapy+5 If mapx<0 Then mapx=0 If mapy>mapsy-scrh Then mapy=mapsy-scrh If mapy<0 Then mapy=0 If mapx>mapsx-scrw Then mapx=mapsx-scrw DrawBlockRect MapIm,0,0,mapx,mapy,mapx+ScrW,mapy+ScrH End Function .loadim Global tile1=CreateImage(tiles,tiles,1,2) SetBuffer BackBuffer() Color 0,255,0 For i=0 To 32 Plot Rand(32),Rand(32) Next GrabImage tile1,0,0 Return
Copyright(c) 2000-2004, BlitzCoder. All Rights Reserved.
Code software created by Krylar's Kreations