Archived

This topic is now archived and is closed to further replies.

Interesting Problem...

This topic is 5972 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello, My problem is I have a tilebased engine where the map is specifed by something like this: char *world[21] = { "111111111111111111111111111111"... etc... and when I read it I use a for loop with two indexes to call each of the xpos and ypos inside the map, the number read by the for loops is then blitted off the bitmap and placed on the back buffer... the problem is I now have two digit numbers in the map and the game will only recognize one digit numbers (for obvious reasons)... so if I were to place a "121111... in the char *world array, the game would read it as "okay, lets make frame 1... okay now add 32 and make frame 2..." when really I want the game to think "okay, wait, thats frame 12, okay, blit frame 12, right then, now add 32 and blit frame 1, okay..." I''ve been brainstorming this problem and with my limited coding knowlegde I thought about maybe adding something special in front of the two digit numbers that would tell the game that it was a two digit number and to read the next two number instead of one, but wouldn''t that mess up the indexes in my for loop so that they''d come out one short? or maybe not because the cell is twice as big and...oh now I''m really confused... -Jesse

Share this post


Link to post
Share on other sites
Hey guys,
Nevermind, I figured it out. The solution is to put a letter in place of the first digit of the two digit number and then run something like this:
if (worldFrame > 10)
{
worldFrame = (worldFrame * 10) - 480 +
world[index_y + y_modify][index_x + x_modify + 1] - ''0'';
index_x++;
}
that takes the ascii code of the letter and converts it into a number such as 10, 20, 30 etc...
Hope this helps some other dumb newbie such as myself...
Cheers,
-Jesse

Share this post


Link to post
Share on other sites
You COULD make all the numbers two-digits long.

char* world=
{"01010101010101020101020304", ...

This however requires bit more work than your own solution. i think.



//John
-----------------------------------------
Swedish saying:
"The one who joins the game must face the consequences of the game."

Share this post


Link to post
Share on other sites
I''d recommend just writing a map editor and learn how to read and write binary files in C++

It''ll simplify things a great deal and you should learn how to use files anyway. MIght as well start with something visual like the map so you know if it''s working or not.

Ben



[Icarus Independent | Jump Down The Rabbithole | Rabbit Tricks ]

Share this post


Link to post
Share on other sites
Thanks for the replies. When I started writing my map editor program, I realized that it would be a hundred times easier just to do what BeerNutts said, and that also takes care of the double digit problem... So, thanks for everyone''s input anyhow,
Later,
-Jesse

Share this post


Link to post
Share on other sites