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 game help

Author
Message
Darksyde
22
Years of Service
User Offline
Joined: 13th Sep 2003
Location: Staffordshire, UK
Posted: 18th Aug 2004 22:43
Hi, sorry for starting another topic, but the title of my previous one seems a little innappropriate as I have now run into other problems.
I've got an array loading in data using the for loop. But for some reason the map seems to be displaying itself sideways (rotated 90 degress anti-clockwise). Any help would be appreciated.



Cheers



Im willing to find out what impossible means.
Darksyde
22
Years of Service
User Offline
Joined: 13th Sep 2003
Location: Staffordshire, UK
Posted: 18th Aug 2004 22:54
Sorry for my noobness. (Esp double posting, lol)
I switched to, read map(y,x) and it works fine...
Only thing is I don't quite understand why I have to do this.

Cheers



Im willing to find out what impossible means.
pizzaman
22
Years of Service
User Offline
Joined: 18th Feb 2004
Location: Gateshead, UK
Posted: 18th Aug 2004 23:10
hi

The reason why you have to do this is because your for-next loops are a little messed up. It should be:



pizzaman
Darksyde
22
Years of Service
User Offline
Joined: 13th Sep 2003
Location: Staffordshire, UK
Posted: 18th Aug 2004 23:23
Thanks, why is it that the loop has to be structured like that? I'm just curious. I guess i can just learn to do things a certain way. But I always like to question why things have to be done that way.

Cheers



Im willing to find out what impossible means.
pizzaman
22
Years of Service
User Offline
Joined: 18th Feb 2004
Location: Gateshead, UK
Posted: 19th Aug 2004 00:10 Edited at: 19th Aug 2004 00:20
oh sorry I meant to explain but got side-tracked

What you were doing wrong was that you were using for-next loops the wrong way. Lets imagine you want to read some data into an array for example, first you'd want to read in a row of data so you'd do this



then you would want to read data from different rows into the array so you would put a for next loop around the previous code because you want to read a row of data and then read all the rows of data



What happens here is the y for-next loop is set to 1 then the x for-next loop is set to 1 then the data is read into to the array at array(1,1), then the x for-next loop increments x to 2 and reads the data into array(2,1); this repeats so data is read into array(3,1), array(4,1), array(5,1). Then the x for-next loop is at 5 so it exits its loop, now the y for-next loops hits "next y" so it increments y to 2, now x is reset to 1 from this line "for x = 1 to 5" so the data is read into the array like array(1,2), then array(2,2), then array(3,2), this keeps happening until both for-next loops varialbes, x and y are both 5 then no more loops are done

Also when printing the data from the array to the screen, you'll either want do this by printing a horizontal row of tiles to the screen, then looping this a set number of times with different verticle increments; or by printing a verticle column of tiles to the screen then looping this a set number of times with different horizontal increments.

So say to do a horizontal row of tiles first you would do



then you would want to repeat this code with increasing the verticle variable with each repeat like so:




One final note to make your code more efficent do this



What it does is just read the image number from the array, straight into the paste image command; as long as the image exists this is the best method for displaying tiles to screen.

pizzaman
Darksyde
22
Years of Service
User Offline
Joined: 13th Sep 2003
Location: Staffordshire, UK
Posted: 19th Aug 2004 00:26
Yes that makes sense. Thanks a lot



Im willing to find out what impossible means.

Login to post a reply

Server time is: 2026-06-11 14:47:03
Your offset time is: 2026-06-11 14:47:03