Tile map editor in BlitzPlus. Need help with collision

Whether you're a newbie or an experienced programmer, any questions, help, or just talk of any language will be welcomed here.

Moderator: Coders of Rage

Post Reply
YenTex
Chaos Rift Newbie
Chaos Rift Newbie
Posts: 31
Joined: Sun Mar 01, 2009 9:38 pm

Tile map editor in BlitzPlus. Need help with collision

Post by YenTex »

Code

Code: Select all

;Platform Map editor NOW WITH MORE COLLISION MAPS
AppTitle "ShadowX Platform Map Editor"
gwidth=800
gheight=600
tsize=40

numtiles=4

Timer = CreateTimer(30) 

showCols = False

Graphics gwidth,gheight,16,2

ClsColor 80,80,200

scr_left = 0
scr_top = 0 

infile = OpenFile("map1.map");Assign infile to loading the map 

If infile <> 0 Then 
	mapx = ReadInt(infile)
	mapy = ReadInt(infile)
Else 
	mapx = 50
	mapy = 20 
EndIf 

Dim map$(mapx,mapy)

If infile <> 0 Then
	;read tile layer
	For y = 0 To mapy-1
		For x = 0 To mapx-1
			map(x,y) = ReadInt(infile)
		Next
	Next
Else
;otherwise wipe map
	For y = 0 To mapy-1
		For x = 0 To mapx - 1
			map(x,y) = 0
		Next
	Next
EndIf

CloseFile infile


img_tiles = LoadAnimImage("tileset.bmp",tsize,tsize,0,numtiles) 

;LOL
;LOL
seltile = 2

SetBuffer BackBuffer()

Color 0,255,255

While Not KeyHit(1)

Cls 

For y = 0 To mapy 
	For x = 0 To mapx 
		tilenum = Int(map(x,y))-1
		If (x*tsize)-scr_left > -tsize And (x*tsize)-scr_left < gwidth And (y*tsize)-scr_top > -tsize And (y*tsize)-scr_top < gheight Then
			;draw tile
			If tilenum > -1 Then DrawImage img_tiles,(x*tsize)-scr_left,(y*tsize)-scr_top,tilenum
		EndIf
	Next
Next
;Scrolling around map w/ keys
If KeyDown(208) And scr_top < (mapy*tsize-gheight) Then scr_top = scr_top+15
If KeyDown(205) And scr_left < (mapx*tsize-gheight )Then scr_left = scr_left+15
If KeyDown(203) And scr_left > -menuwidth Then scr_left = scr_left-15
If KeyDown(200) And scr_top > 0 Then scr_top = scr_top-15

Rect (((MouseX()+scr_left)/tsize)*tsize)-scr_left-1,(((MouseY()+scr_top)/tsize)*tsize)-scr_top-1,tsize+2,tsize+2,0

If seltile > 0 DrawImage img_tiles,(((MouseX()+scr_left)/tsize)*tsize)-scr_left,(((MouseY()+scr_top)/tsize)*tsize)-scr_top,seltile-1
If MouseDown(1)
	map((MouseX()+scr_left)/tsize,(MouseY()+scr_top)/tsize) = seltile
EndIf 
If selmouse < MouseZ() Then seltile = seltile + 1
If selmouse > MouseZ() Then seltile = seltile - 1
selmouse = MouseZ()
If MouseHit(2) Then seltile = seltile + 1
If seltile > numtiles Then seltile = 0
If seltile = -1 Then seltile = numtiles 

;Clear map w/C key 
If KeyHit(46) Then
For y = 0 To mapy-1
	For x = 0 To mapx-1
		map(x,y) = 0
	Next 
Next
EndIf

 
;save map when 's' pressed
;-----------------------------------
If KeyHit(31) Then

;open output file in write mode
fileout = WriteFile("map1.map")

;write map dimensions
WriteInt fileout,mapx
WriteInt fileout,mapy
	
	
;write tile layer
For y = 0 To mapy-1
	For x = 0 To mapx-1
		WriteInt fileout,map(x,y)
	Next
Next

CloseFile fileout
;--------------------------------------


EndIf



Flip
Wend

EndGraphics 
End
I don't know where to begin, can anyone help
User avatar
dandymcgee
ES Beta Backer
ES Beta Backer
Posts: 4709
Joined: Tue Apr 29, 2008 3:24 pm
Current Project: https://github.com/dbechrd/RicoTech
Favorite Gaming Platforms: NES, Sega Genesis, PS2, PC
Programming Language of Choice: C
Location: San Francisco
Contact:

Re: Tile map editor in BlitzPlus. Need help with collision

Post by dandymcgee »

Umm, what exactly do you want help with. Collision in a map editor? Do you mean being able to set tile attributes for collision? Is this map editor your own work or something you're just trying to understand?
Falco Girgis wrote:It is imperative that I can broadcast my narcissistic commit strings to the Twitter! Tweet Tweet, bitches! :twisted:
YenTex
Chaos Rift Newbie
Chaos Rift Newbie
Posts: 31
Joined: Sun Mar 01, 2009 9:38 pm

Re: Tile map editor in BlitzPlus. Need help with collision

Post by YenTex »

dandymcgee wrote:Umm, what exactly do you want help with. Collision in a map editor? Do you mean being able to set tile attributes for collision? Is this map editor your own work or something you're just trying to understand?
I wrote this, thank you.
i solved my problem
User avatar
dandymcgee
ES Beta Backer
ES Beta Backer
Posts: 4709
Joined: Tue Apr 29, 2008 3:24 pm
Current Project: https://github.com/dbechrd/RicoTech
Favorite Gaming Platforms: NES, Sega Genesis, PS2, PC
Programming Language of Choice: C
Location: San Francisco
Contact:

Re: Tile map editor in BlitzPlus. Need help with collision

Post by dandymcgee »

Raiden wrote: I wrote this, thank you.
i solved my problem
Glad you figured it out, sorry I couldn't help. ;)
Falco Girgis wrote:It is imperative that I can broadcast my narcissistic commit strings to the Twitter! Tweet Tweet, bitches! :twisted:
TheLividePianoist
Chaos Rift Newbie
Chaos Rift Newbie
Posts: 15
Joined: Thu Jan 29, 2009 5:48 pm

Re: Tile map editor in BlitzPlus. Need help with collision

Post by TheLividePianoist »

Sorry to blow your spot but I know for a fact that you never wrote that code. That being said if you meant that you did write the code, otherwise sorry. I just don't like seeing other people taking credit for other people's work especially when all they've done was just scratched out certain areas in the code.
User avatar
MadPumpkin
Chaos Rift Maniac
Chaos Rift Maniac
Posts: 484
Joined: Fri Feb 13, 2009 4:48 pm
Current Project: Octopia
Favorite Gaming Platforms: PS1-3, Genesis, Dreamcast, SNES, PC
Programming Language of Choice: C/++,Java,Py,LUA,XML
Location: C:\\United States of America\Utah\West Valley City\Neighborhood\House\Computer Desk

Re: Tile map editor in BlitzPlus. (TheBelovedPenis er whatever)

Post by MadPumpkin »

TheLividePianoist wrote:Sorry to blow your spot but I know for a fact that you never wrote that code. That being said if you meant that you did write the code, otherwise sorry. I just don't like seeing other people taking credit for other people's work especially when all they've done was just scratched out certain areas in the code.
i HATE it when people take credit for others work, personally, i prefer to make everything from scratch, because it makes me feel cool, AND i can legally remove, edit, add(to or from) any thing to do with it...
but think about making your own CPP compiler Dx exactly!! lol so instead i use code::blocks :}, the next best thing!, try to take credit for code::blocks and you'll get shot lol
While Jesus equipped with angels, the Devil's equipped with cops
For God so loved the world that he blessed the thugs with rock
Image
Image
Image
User avatar
Kros
Chaos Rift Regular
Chaos Rift Regular
Posts: 136
Joined: Tue Feb 24, 2009 4:01 pm
Current Project: N/A
Favorite Gaming Platforms: PC, Playstation/2/3
Programming Language of Choice: C++
Location: Oregon,USA
Contact:

Re: Tile map editor in BlitzPlus. Need help with collision

Post by Kros »

Isaac Asimov wrote:Part of the inhumanity of the computer is that, once it is competently programmed and working smoothly, it is completely honest.
YouTube Channel
Post Reply