Total newb working on a map building engine

Blitz3D Forums/Blitz3D Beginners Area/Total newb working on a map building engine

IsaacJS2(Posted 2005) [#1]
Hello all. This is my first program, so if I'm making some elementary school mistake try not to laugh too hard. Or hit. Or yell... :-)

Anyway, I'd like to work my way up to a turn-based RPG strategy game in 2D and I'm taking it a piece at a time. I figured the first thing to master is a random map creator like the old school games used to use since that's how I want my game to work. This is my first attempt, and once I get this *very basic* version running, I'll start trying to improve it. But for now, I'm getting the dreaded "Memory Access Violation" error. From what I've found here in the forums, it appears that Blitz isn't loading my graphics correctly or I'm mishandling the TileImage variable somehow. That's my guess, but I don't see the glitch (yet). Note the TileImage command is where the debugger says "Image Does Not Exist."

Any one see what I'm missing? I'm using BIDE and the png files are in the same folder as the Blitz3d code. I have also tried adding the full folder description instead of just "picture.png" but that made no difference.

Thanks for any help.

==========================================================


;Draw map image and test world creation algorithm for tweaking

Global x=0 ;set coordinates x and y to 0 and make it a global variable
Global y=0
Global DrawMapImage
Global LandArea

StartWorld() ;start program

Function StartWorld()
Graphics 800,600 ;Set video mode

Setbuffer Backbuffer() ;Draw these images to the backbuffer

Grassmap=LoadImage("Grass 1.png") ;Load Images...
Oceanmap=LoadImage("Ocean 2.png")
Forestmap=LoadImage("Forest 1.png")
Desertmap=LoadImage("Desert Sand 1.png")
Icemap=LoadImage("Ice 1b.png")
CreateWorld() ;Call Function CreateWorld
End Function
;

Function CreateWorld() ;Function begin
LandArea=Rnd(0,4) ;Pick a random number between 0 and 4
Select LandArea ;Decide which land map tile was chosen randomly above

Case 0 ;If Grass chosen, set DrawMapImage accordingly
DrawMapImage=Grassmap ;and go to function to draw this image to
DrawMapTile() ;backbuffer screen
;Repeat as needed...
Case 1
DrawMapImage=Oceanmap
DrawMapTile()

Case 2
DrawMapImage=Forestmap
DrawMapTile()

Case 3
DrawMapImage=Desertmap
DrawMapTile()

Case 4
DrawMapImage=Icemap
DrawMapTile()

End Select ;Stop decision loop

Select y ;If screen full from top to bottom, then wait for user input
Case 576
Vwait ; Wait for screen refresh
Flip ; Put backbuffer image onto front screen and show image
key=Waitkey()

Select key
Case 28 ;If Enter key pressed do the following
CLS ;Clear screen
FreeImage Grassmap ;Free the following images from memory...
FreeImage Oceanmap ;Repeat as needed...
FreeImage Forestmap
FreeImage Desertmap
FreeImage Icemap
x=0 ;Reset coordinates to 0
y=0
StartWorld() ;Start program over again

Default ;If any other key is pressed
End ;End program
End Select
End Select
End Function
;

Function DrawMapTile() ;Declaring DrawMapTile function
TileImage DrawMapImage,x,y ;Draw whatever image is stored in DrawMapImage
;variable at coordinates x,y
;MAV occurring HERE! Debugger says image does not exist...

x=x+64 ;increment value x (horizontal) by 64 so we can control image placement

Select x ;If x reaches edge of screen - a value of 768
Case 768
y=y+64 ;increment vertical y variable by 64
x=0 ;and put x back to zero, starting us over from left to right, next row
Default ;If x equals anything other than 768
CreateWorld() ;Call CreateWorld and draw next row of images

End Select
End Function


puki(Posted 2005) [#2]
Run it with 'Debug' on - what does it tell you?

EDIT:
Oh, he did.


puki(Posted 2005) [#3]
I think it lies with the first call to CreateWorld(). I'm still looking at it.

EDIT:
Yep, when I remove the very first call to CreateWorld() (after Icemap=LoadImage...) there is no error. There is no need to call the function as technically CreateWorld() follows the program flow from StartWorld().

However, test it yourself to see if this is where the problem lies - coz, for me the program just ends naturally without any erros, but I see no graphic output.

EDIT:
Personally, I wouldn't put StartWorld() in a function and I wouldn't recall it the way you do - you are duplicating.


IsaacJS2(Posted 2005) [#4]
<<<
Yep, when I remove the very first call to CreateWorld() there is no error. There is no need to call the function as technically CreateWorld() follows the program flow from StartWorld().

However, test it yourself to see if this is where the program lies - coz, for me the program just ends naturally without any erros, but I see no graphic output.
>>>


I get the same thing when I try it here. But I didn't think the function would run without being called(?) Or at least that if it did run the fuction automatically that Blitz wouldn't care if I called it explicity or not? I had guessed that calling StartWorld might not be necessary, but not CreateWorld.

I expected it to loop back and forth from CreateWorld (which decides which type of map tile to display) to DrawMapTile (which is supposed to do the drawing part) until the screen is full. Then it stops at this point so I can see what I've got, and hitting enter would make it repeat the process while hitting any other key would end program. At least, that was the plan. :-( So you're saying this isn't needed?

I'm not clear on how this would cause the program to skip the image loading process, which *appears* to be the problem. The debugger seems to be saying that the images I'm calling for in DrawImage aren't there even though I loaded them during CreateWorld.

I think I see why we're not getting output. I made a last minute change to the program, and I see that I ended up putting the graphics mode call in StartWorld which--I think--erases the screen and wipes out everything. Maybe this is the problem... hmmm.

Thanks for the help.


IsaacJ


puki(Posted 2005) [#5]
Yeh, actually it needs calling - I was a bit quick of the mark - I just spotted the MAV went away - but when I tested DrawMapTile() in fact the program was never getting there - so sorry about that.

I'm still nosing at it.

EDIT:
By the time the program gets to DrawMapTile() the value of DrawMapImage appears to be 0 - it should not - that image will not exist.


puki(Posted 2005) [#6]
Yep, the problem for me is DrawMapImage is arriving in DrawMapTile() with a value of 0.

You've not set them as Global.


IsaacJS2(Posted 2005) [#7]
Hey, no problem. I see a few other mistakes now that I couldn't get my head around earlier. I'll post again in a bit, but I think I'm getting close. I'm guessing that Blitz treats the image labels as any other variable, and that it isn't passing them to the drawing function. Either I have to find a way to make them global, or a way to pass them to the function. Am I correct about any of that?

BTW, thanks for the assist! :-) I'm still learning. Haven't done much programming in years. Not since Color Basic on the old TRS80! Even some of the basic commands do different things now, which has thrown me a little here and there.


IsaacJ


puki(Posted 2005) [#8]
Set them as Global - it will work - I just sorted it


Grassmap, Oceanmap, Forestmap, Desertmap and Icemap need to be defined as Global first.


IsaacJS2(Posted 2005) [#9]
Your post beat my last one. But now I have something weird. Before, when I assigned labels to the images, I originally tried a global command in the fuction to make them global. But Blitz said I had to declare global variables in the main program and gave no other complaints. I meant to try declaring the label variables as global first to see if that would do the trick, but ... duh ... I forgot.

When I try this correction now, I get the same error anyway! But when I do it in debug mode, I get a picture without errors of any kind. (?) Weird. The only thing is that I expected the program to wait for me to hit a key before ending, which it isn't. Maybe Waitkey() doesn't work as I thought?

I'll keep playing with it before I post again. :-)


IsaacJ


IsaacJS2(Posted 2005) [#10]
You beat me again... ;-)

You got it to work without errors? Mine only worked when in debug mode. Hmmm...


IsaacJ


puki(Posted 2005) [#11]
True, I ran it in debug mode - there is still a problem.


IsaacJS2(Posted 2005) [#12]
Sorry, I lied before. I didn't get an error message, just no output except when I run in debug mode. Then, it seems that my random number command isn't working because it always gives me the grassland tile and nothing else. For some reason, it is always picking case 0. Maybe I have misunderstood how one of these commands works.

Here is my latest version of the code for anyone that wants to look. Thanks again!

======================================================

;Draw map image and test world creation algorithm for tweaking

Global x=0 ;set coordinates x and y to 0 and make it a global variable
Global y=0
Global DrawMapImage
Global LandArea

Global Grassmap
Global Oceanmap
Global Forestmap
Global Desertmap
Global Icemap


Graphics 800,600 ;Set video mode
Setbuffer Backbuffer() ;Draw these images to the backbuffer


StartWorld() ;start main program

Function StartWorld()

Grassmap=LoadImage("Grass 1.png") ;Load Images...
Oceanmap=LoadImage("Ocean 2.png")
Forestmap=LoadImage("Forest 1.png")
Desertmap=LoadImage("Desert Sand 1.png")
Icemap=LoadImage("Ice 1b.png")
CreateWorld() ;Call Function CreateWorld
End Function
;

Function CreateWorld() ;Function begin
LandArea=Rnd(0,4) ;Pick a random number between 0 and 4
Select LandArea ;Decide which land map tile was chosen randomly above

Case 0 ;If Grass chosen, set DrawMapImage accordingly
DrawMapImage=Grassmap ;and go to function to draw this image to
DrawMapTile() ;backbuffer screen
;Repeat as needed...
Case 1
DrawMapImage=Oceanmap
DrawMapTile()

Case 2
DrawMapImage=Forestmap
DrawMapTile()

Case 3
DrawMapImage=Desertmap
DrawMapTile()

Case 4
DrawMapImage=Icemap
DrawMapTile()

End Select ;Stop decision loop

Select y ;If screen full from top to bottom, then wait for user input
Case 576
Vwait ; Wait for screen refresh
Flip ; Put backbuffer image onto front screen and show image
key=Waitkey()

Select key
Case 28 ;If Enter key pressed do the following
CLS ;Clear screen
FreeImage Grassmap ;Free the following images from memory...
FreeImage Oceanmap ;Repeat as needed...
FreeImage Forestmap
FreeImage Desertmap
FreeImage Icemap
x=0 ;Reset coordinates to 0
y=0
StartWorld() ;Start program over again

Default ;If any other key is pressed
End ;End program
End Select
End Select
End Function
;

Function DrawMapTile() ;Declaring DrawMapTile function
TileImage DrawMapImage,x,y ;Draw whatever image is stored in DrawMapImage
;variable at coordinates x,y
;MAV occurring HERE! Image does not exist...

x=x+64 ;increment value x (horizontal) by 64 so we can control image placement

Select x ;If x reaches edge of screen - a value of 768
Case 768
y=y+64 ;increment vertical y variable by 64
x=0 ;and put x back to zero, starting us over from left to right, next row
Default ;If x equals anything other than 768
CreateWorld() ;Call CreateWorld and draw next row of images

End Select
End Function


puki(Posted 2005) [#13]
Same here - I see the images in debug, but a blank screen when not in debug mode.


puki(Posted 2005) [#14]
The program seems to be looping somewhere.

EDIT:
I am still suspicious of your calling of StartWorld()

EDIT:
Nope maybe that is not the problem.


puki(Posted 2005) [#15]
Wait a minute - I reckon the image handles are constantly changing coz you keep calling the loading of the images.

EDIT:
Maybe not.


ratking(Posted 2005) [#16]
1) Your comments mostly are useless: "set coordinates x and y to 0 and make it a global variable" is pseudocode for "global x=0 : global y=0". Comments should describe, _why_ you do something, not what you do.
IMHO.

2) Your *map-variables are indeed not global and should either be passed (as an array or so) or be global. For CreateWorld(), they all are just 0. EDIT: I see you corrected this.

3) Your "Select y : Case 675" should be replaced by a while-loop over the whole function ("While y < 675"), until the DrawMapTile(). Your program just adds 64 to y once and exits. Select/Case isn't just the right thing.

4) LandArea doesn't have to be Global.

5) It's little bit crude calling StartWorld() inside CreateWorld() ...

6) "Select x : Case 768" - should be an If-statement.

7) With 3) in mind, you don't have to call CreateWorld() inside DrawMapTile(). It returns automatically.


puki(Posted 2005) [#17]
Nice one "wurst" - I have to admit I am trying to look at this and watch television at the same time.


ratking(Posted 2005) [#18]
Thanks, "puki" ... whaddya watchin'?

Well, here comes Number

8) "TileImage" isn't what you want, IsaacJS2. It's "DrawImage".

This should do nicely:

;Draw map image and test world creation algorithm for tweaking

Global x=0
Global y=0

Global Grassmap
Global Oceanmap
Global Forestmap
Global Desertmap
Global Icemap

SeedRnd MilliSecs()

Global game = True

While game
	StartWorld ; initialize
	game = PlayGame() ; show the tiles
Wend

End

; ****************************


Function StartWorld()

	Graphics 800,600 ;Set video mode

	x=0 ;Reset coordinates to 0
	y=0

	SetBuffer BackBuffer() ;Draw these images to the backbuffer

	Grassmap=LoadImage("Grass 1.png") ;Load Images...
	Oceanmap=LoadImage("Ocean 2.png")
	Forestmap=LoadImage("Forest 1.png")
	Desertmap=LoadImage("Desert Sand 1.png")
	Icemap=LoadImage("Ice 1b.png")
	
End Function

Function PlayGame%()
	
	While y < 576
			
		Select Rand(0,4)
	
			Case 0 ;If Grass chosen, set DrawMapImage accordingly
			DrawMapImage=Grassmap ;and go to function to draw this image to

			;Repeat as needed...
			Case 1
			DrawMapImage=Oceanmap
			
			Case 2
			DrawMapImage=Forestmap
			
			Case 3
			DrawMapImage=Desertmap
			
			Case 4
			DrawMapImage=Icemap
			
		End Select

		DrawImage DrawMapImage,x,y
	
		x=x+64
		If x >= 768 Then
			y=y+64
			x=0
		EndIf
		
	Wend

	Text 20, 20, "Hit Enter for new terrain. Any other key returns to desktop."

	VWait
	Flip ; Put backbuffer image onto front screen and show image
	key = WaitKey()

	If KeyHit(28)
		Cls
		FreeImage Grassmap ;Free the following images from memory...
		FreeImage Oceanmap ;Repeat as needed...
		FreeImage Forestmap
		FreeImage Desertmap
		FreeImage Icemap
		Return True ; start over again. this is ugly code und should be changed
	Else
		Return False
	EndIf			

End Function



puki(Posted 2005) [#19]
Well, I was watching 'The 100 Greatest Pop Videos' on telly and also playing Football Manager 2005 on another computer and surfing the net on this one. Also it is 1.00am in the morning and I am a bit sleepy.

Glad you could help - I was kind of on the right track, but not concentrating.

EDIT:
I still don't like that StartWorld() function. Purely coz I don't see the point of re-setting the screen mode and reloading the graphics in a loop.

"IsaacJS2" why is the program looping like that?

EDIT:
Doesn't matter - I need a snooze.


ratking(Posted 2005) [#20]
I have no idea.
BTW, I just see that IsaacJS2 confuses ASCII-codes and Scancodes. I fix that. And the loop thing.


puki(Posted 2005) [#21]
Gee, "wurst" - it is 2:27am where you are. You are doing well for this time of the morning - unless you have been asleep all day.


ratking(Posted 2005) [#22]
I keep editing this wonderful piece of code - I wouldn't call that "doing well".

I just love correcting other's work (when it's easy like this one).


IsaacJS2(Posted 2005) [#23]
Sorry I screwed so many things up, Wurst. Like I said, this is the very first time I've ever coded anything at all in Blitz. As in, day #1, program #1. I thought this was a newbs area so it would be OK. :-) I apologize for being green, but everyone has to start somewhere, right? And I'm at the very beginning of the learning process.

Still, thanks for the help and taking the time to post. I will try your revisions a little later and appreciate the effort. I thought a turn based game would be a good project to dig into, especially since I can take it in steps. I can try to perfect a world map first, then scrolling around on the map, constructing buildings, unit creation, etc. and take them all as small, seperate exercises. Later, when I'm ready to put all those pieces together, I'll already have working code to go from. Then I'll be ready for something fast paced, maybe upgrade the first game to 3D...and so on.

Sounded like a pretty good plan to me anyway. :-)

Thanks again.


IsaacJ


IsaacJS2(Posted 2005) [#24]
Puki and Wurst,

I set the program to loop so it draws row one of the images to the screen, then moves to row 2 when that row is full, then row 3... until the whole screen is mostly full. That is why it keeps counting up numbers with the x,y coordinates and resets them. I thought that when it reached the furthest position on the screen this would let the program know to switch to the next row. Since my pictures are 64x64 I'm adding 64 to the coordinates each pass until it reaches the highest number that will fit at the resolution I'm using. (Or so I thought) Does this make sense? I'm certainly willing to try a better method if anyone has one.


Should I have done something differently? Or did I do something wrong there and that's what's confusing you? Like I said, this is for a turn based RPG which has to draw a map of the game world. Later, I want to make it bigger than the view screen so I can scroll around like you would do in a regular strategy game.


EDIT
It seems like you're not sure what it is I'm trying to do. I am trying to fill the screen with a complete map composed of smaller images, then make the program pause so I can see the map and insure it did what I wanted. If I hit enter, I want it to start over again so I can see what sort of maps come up the second time without having to restart the program from scratch. From there, I want to fine tune the program to make intelligent decisions about where to place the terrain blocks instead of making them completely random. This is how older turn-based RPG/Strategy games used to do. Hope this clarifies things.

As to the comments being useless, they are useful to me at this point. They were simply copied alongside the actual code and reinforce what I am learning in my own head. Guess I assumed everyone would know what I meant to do from when I spoke of "Map Creation", but I shouldn't have done that. Like I said, this is literally day #1 for me. :-)


IsaacJ


IsaacJS2(Posted 2005) [#25]
I'm actually getting the exact same error with Wurst's example code as wy original code. Only this time, with the DrawImage command he used instead of the TileImage command I used. My revised code (posted above) doesn't produce any errors, but nor does it give any output except when it is run in debug mode. I expected to get a full screen, but only seem to be getting a single row of pictures. I'll have to keep playing with it to see what is wrong with that, but does anyone know why I'm getting results in Debug Mode and not when Run it regularly? The only thing I can think of is that maybe the debugger is showing me the backbuffer when it ends the program, which could mean I'm using Flip incorrectly. Just a thought.



BTW, sorry if I annoyed anyone by posting my less-than-wonderful code. :-( I have never written a Blitz3D program before, so I have no experience to judge my mistakes against and thought I would seek out some advice in the newbs forum. Did I post in the wrong place?

Thanks for the help already given though.


IsaacJ


puki(Posted 2005) [#26]
Hi "IsaacJS2" - I just woke up. Heh, you live in the USA so we are kind of on different timezones. My brain will wake up in about 2 hours or so, so I'll take another snifter at it. However, the Grand Prix will be on.

Yeh, it was kind of odd that it worked in debug mode.


ratking(Posted 2005) [#27]
My code works. With Debug and without.

If this really is day #1 for you, you should start with the regular "Hello world!" and do some tutorials. There is the Blitz3D-Help and there is Google. Just to get to know the language.
Sure, Learning By Doing is nice, but you really should know the basics before starting such a project.

To your problem: You get a result in Debug because it doesn't end properly with an "End". The program ignores the "Select y: Case 576", because y never reaches 576. Just replace "TileImage" with "DrawImage" ("TileImage" draws one tile over the whole screen, as one can clearly learn in the Blitz3D-help) to see that it produces only one line of tiles.
In Debug, a quitmessage is displayed, letting you see the result until you click it away. Without Debug, the message isn't shown and the program ends immediately.


Ross C(Posted 2005) [#28]
Hey man, try this code out. It's a slightly different coded approach, but alot more straight forward.

It will load all the tile images into an array. Then fill the map array wil random tile numbers. These tiles number will directly relate to the tile images in the TILES() array. I've tried to comment the best i can, so if you've got any questions, then fire away :o)

;Draw map image and test world creation algorithm for tweaking

Graphics 800,600
SetBuffer BackBuffer()

Global NoOfTiles = 4 ; set the number of tiles to 4, 5 including 0
Global TileWidth = 64 ; set the Tile height
Global TileHeight = 64 ; set the Tile width

; You have globals for each tiles. I have changed them and given them a number each.
; Now, these will describe each tile. They are not needed, but give you an idea of what number
; is related to a tile image. What i will do, is store each tile in a one dimensional array.
; Grassmap = 0
; Oceanmap = 1
; Forestmap = 2
; Desertmap = 3
; Icemap = 4

; Create an array to hold the tile images in
Dim tiles(NoOfTiles)
; Load the tiles into the array
LoadTiles()


; dim the map array. This is so you can fill it with tiles. It is set to 11 x 8 because that's how
; many tiles will fit into the current screen of 800 x 600. 

Global MapWidth = 11 ; this is actually 12, but because we're using 0, set to 11
Global MapHeight = 8 ; As above

Dim map(MapWidth,MapHeight)

; This function will fill the array with numbers, between 0 and 4. Each number represents a tile image
; 
GenerateMap()


SeedRnd MilliSecs()

Global game = True

While Not Keyhit(1) ; this will end the program by pressing ESCAPE key

	Cls

	If KeyHit(28) Then GenerateMap() ; if the enter key is pressed, the map is randomised again
	
	DrawTiles()
	Text 0,0, "Hit Enter for a new terrain"
		
	Flip ; Always try and flip at the end of the main loop. It's easier to debug if you only have one
	     ; Flip in the code
Wend

End

; ****************************


Function LoadTiles()


	Tiles(0) = LoadImage("Grass 1.png") ;Load Images...
	Tiles(1) = LoadImage("Ocean 2.png")
	Tiles(2) = LoadImage("Forest 1.png")
	Tiles(3) = LoadImage("Desert Sand 1.png")
	Tiles(4) = LoadImage("Ice 1b.png")
	
End Function

Function GenerateMap()

	; fill the array with random tiles. This will simply put a random number in each slot of the array
	; which will be used to select a tile from the TILES() array.
	For x = 0 To MapWidth
		For y = 0 To MapHeight
			map(x,y) = Rand(0,NoOfTiles) ; select random number
		Next
	Next
	
End Function

Function DrawTiles()

	; the drawimage command may look complicated, but if you split it up, what you have is:
	;DrawImage Tiles (  Map(x,y)) << Now, what your doing, is retrieving the tile number from the map
	;                                array, so blitz will take this number and this line will become:
	;DrawImage Tiles (  3 )  << So blitz will draw the 3rd image in the Tiles() array
	
	; 0 + (x * TileWidth) <<< basically, take the current x tile position, and multiply it by the tile
	;                         width to get the onscreen drawing X co-ord. The same applies for the Y
	;                         Co-ord.
	
	For x = 0 To MapWidth
		For y = 0 To MapHeight
			DrawImage Tiles(Map(x,y)), 0 + (x * TileWidth), 0 + (y * TileHeight)
		Next
	Next
	
End Function



puki(Posted 2005) [#29]
Yeh, I like the look of "Ross C's" code - it is structured more the way I like - easier to follow and to debug no doubt.


Ross C(Posted 2005) [#30]
It's always best to load everything in before the main game/loop starts. Try and avoid loading things in during gameplay or during main runtime.


ratking(Posted 2005) [#31]
1) The code doesn't work. It just shows one line of tiles, all the same. Because there is "NoOfTiles" and "NumberOfTiles", while the latter is 0, and because there is a variable "loop" in "DrawTiles()", which isn't used. It should be "y" instead. EDIT: Okay, this works now. =)

2) NumberOfTiles should be _really_ the number of tiles, so the name isn't just confusing. Same goes for MapWidth and MapHeight. Use "MapWidth-1" later instead.

3) The program hasn't any abort condition. ("game" is always True)


Ross C(Posted 2005) [#32]
Your too slow ;o) Edited it before ya! And your other points are purely preference. Putting a minus one every time you want to use the variable is more confusing id say, but again, it's down to your preference. Thanks for posting tho.


ratking(Posted 2005) [#33]
Why not calling it "MapWidthMinusOne"? Would make more sense, eh.


Ross C(Posted 2005) [#34]
Well, typing that variable agian and again, you'd probably end up with typing errors and creating a new variable by accident. It's all down to whatever you prefer. I know when i'm dealing with arrays, that 0 always is used as a number. If Isaac decides he wants it the other way, then so be it :o)

The code just demonstrates a better way to lay it out.


IsaacJS2(Posted 2005) [#35]
Thanks a lot, Ross C! This looks very helpful and you didn't even complain! :-) I'll look it over and see how your approach works. Wurst's code generated errors on my machine, but yours works for me and does what I wanted it to do originally.

I really appreciate you taking the time to do this. And thanks to everyone else.



IsaacJ


ratking(Posted 2005) [#36]
>Well, typing that variable agian and again, you'd probably end up with typing errors and creating a new variable by accident. It's all down to whatever you prefer. <

Using "MapWidth" as what it is (the width of the map, and not as the width of the map minus 1) guarantees better maintainability of the source code, that's what I'm trying to say. Giving variables convenient names is just a way preventing bugs.

IsaacJS2, please consider my advice from above.
Avoid sourcecode you don't understand. My piece of code totally works (on my PC). You must do something wrong with it.
BTW: where did I "complain"? :(


Ross C(Posted 2005) [#37]
No worries man :o) As wurst says, try not go in too deep with code :o)