Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

2D All the way! / Tile Map problems

Author
Message
Derekioh
15
Years of Service
User Offline
Joined: 1st Feb 2009
Location:
Posted: 18th Jun 2011 20:22
Hey There!

I must say its been a while since I've worked on a DBP project and I have a question for the great forum of this community. I had a tile mapping system working for a basic testing purpose (attached in the 'before' folder) and it worked fine. Then I tried editing it and actually putting my own work into it and it won't load anything but one tile and my character is gone (atached in the 'after' folder). I will figure out the character thing later, but I was wondering if someone could look at it and tell me whats wrong?

controls: arrows keys for movement, hold z to run, and esc to enter main menu (which can exit the program).

The problem is in the Tile Engine File

Thanks

PS. - in case you are wondering, yes, this is a recreation of crono trigger

Attachments

Login to view attachments
Derekioh
15
Years of Service
User Offline
Joined: 1st Feb 2009
Location:
Posted: 19th Jun 2011 17:25
can anyone help?

Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 20th Jun 2011 08:57
I took a quick glance at it. It looks like the tiles aren't being positioned properly and all default to 0,0. Did a variable used for calculating the space/offset between tiles get erased or overwritten? What changes did you make to the 'before' code?

Also, the executable would give me an array out of bounds error if I moved too much with the keys, but compiling the code myself didn't give the error.

Derekioh
15
Years of Service
User Offline
Joined: 1st Feb 2009
Location:
Posted: 20th Jun 2011 18:52 Edited at: 20th Jun 2011 18:53
Actually, I did create variables for offsetting the tiles. it's on line 398-423 in the 'after' code, in the function TileEngine_Scroll_Screen(): (tileWidth = 32, tileHieght = 32, TileNumX, TileNumY)



And as for the changes, All I did was add another FOR LOOP for the pasting images for the 4 layers of tiles. I also made a function to load the image file and the tile map file. Oh and the variables that went along with the tile map file.

As for the array out of bounds error, I dont know why it worked for you, but its probably because I had a commented out section for the 'before' code that handled the collsion stuff allowing the character to never leave the area.

Van B
Moderator
21
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 20th Jun 2011 20:05 Edited at: 20th Jun 2011 20:18
I think that the globals are being ignored, because they are never compiled. The constants work because the compiler simply replaces the values, but a global might be better off being initiated in the main source file. So if you take all your globals and initiate them in a subroutine in your main file, I think you'll get results.

Also, I'm sure that the array error is in the part that checks which image to paste for the map - probably going out of range. I would consider switching those constants for globals, and have just 1 big variables subroutine in your main source.

Health, Ammo, and bacon and eggs!
Derekioh
15
Years of Service
User Offline
Joined: 1st Feb 2009
Location:
Posted: 21st Jun 2011 05:45 Edited at: 21st Jun 2011 05:46
okay, I'll try that and tell my results

EDIT:

wait do you mean the variables in the paste image code to also be global?

Van B
Moderator
21
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 21st Jun 2011 09:46
Well that might be affecting it - but I would suggest doing a range check with the indices your using to get the tile image from the array, so it can never go out of the arrays bounds.

Like:
if x>-1 and y>-1 and x<256 and y<256
Paste image tile(x,y).image,etc,etc
endif

Health, Ammo, and bacon and eggs!
Derekioh
15
Years of Service
User Offline
Joined: 1st Feb 2009
Location:
Posted: 21st Jun 2011 18:19
oh, I totally didnt think of that! Ill try that, thanks. but when I put the variables to globals, its giving me a dividing by zero on line 768, the problem is I can't find that line and I cant seem to pin point it right...hmmm. I'll keep trying to figure that one out

Derekioh
15
Years of Service
User Offline
Joined: 1st Feb 2009
Location:
Posted: 21st Jun 2011 20:09 Edited at: 21st Jun 2011 20:11
okay so I put all the globals to a sub routine and fixed the array error, but now it pastes one tile to screen where the character is suppose to be! any ideas?

EDIT:

here is the udated code. changes in the varaibles file and TIle Engine

Attachments

Login to view attachments
Van B
Moderator
21
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 21st Jun 2011 22:05
It appears that every tile is image 1, just texted the image and each one is 1, but the positioning is right - maybe it's not reading the data properly.

Health, Ammo, and bacon and eggs!
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 22nd Jun 2011 01:57
This is where I'd start ripping out all the irrelevant guts from the source so I can focus solely on the tilemap routine separately without worrying about any extra junk that clutters my thinking.

Van B
Moderator
21
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 22nd Jun 2011 09:52
Yeah, I'd do the same - maybe set the map to random but valid images - work out if it is the file loading that is the problem.

Health, Ammo, and bacon and eggs!
Derekioh
15
Years of Service
User Offline
Joined: 1st Feb 2009
Location:
Posted: 28th Jul 2011 17:35
Okay, I will try isolating it more. sorry for the late response, I just got back from vacation. But thatnk you for the help and I'll post more in the next day or so.

Login to post a reply

Server time is: 2024-04-25 22:02:23
Your offset time is: 2024-04-25 22:02:23