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
"Tile Map Engine"
, by phoenix
This is a code for a basic tilemap editor. It΄s nothig big. It will ask for a filename to save as if you press delete. And don΄t write "mylevel.dat" write instead "mylevel".
Code
Graphics 800,600 SetBuffer BackBuffer() Dim map(24,18) Type block Field x,y,col End Type While Not KeyHit(1) If KeyHit(211) Then SaveMap() If MouseHit(1) Then MousePos(1) If MouseHit(2) Then MousePos(2) For gridx=0 To 24 For gridy= 0 To 18 Line gridx*32,gridy*32,gridx*32,600 Line gridx*32,gridy*32,800,gridy*32 Next Next Line MouseX()-4,MouseY(),MouseX()+4,MouseY() Line MouseX(),MouseY()-4,MouseX(),MouseY()+4 For b.block=Each block If b\col=0 Then Color 0,255,0 If b\col=1 Then Color 255,0,0 Rect b\x-8,b\y-8,32,32 Next Color 255,255,255 Flip Cls Wend Function MousePos(icol) x=MouseX() y=MouseY() tilex=x/32 tiley=y/32 If icol=0 Then map(tilex,tiley)=0 If icol=1 Then map(tilex,tiley)=1 b.block=New block b\x=tilex*32+8 b\y=tiley*32+8 If icol=0 Then b\col=0 EndIf If icol=1 Then b\col=1 EndIf End Function Function SaveMap() name$=Input("What is your map's name?: ")+".dat" file=WriteFile(name$) For ready=0 To 18 For readx=0 To 24 WriteLine file,map(readx,ready)+"," Next Next End Function
Copyright(c) 2000-2004, BlitzCoder. All Rights Reserved.
Code software created by Krylar's Kreations