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.

AppGameKit Classic Chat / FileEOF on subimages.txt?

Author
Message
DavidAGK
AGK Developer
10
Years of Service
User Offline
Joined: 1st Jan 2014
Location:
Posted: 6th Sep 2017 20:42
I'm using atlas images for my game tiles. Currently I calculate the number of tiles in each image by dividing the width of the image by the tile size and multiplying by the height of the image divided by the height of the tiles. However in reality I don't always use every tile that that maths renders - ie there are some blank tiles at the end. Because the subimages.txt file is not explicitly opened like other files in AppGameKit (happens automatically in background) I can't scan through that file until FileEOF says I've got to the last line. If I could do that, I could use the natural length of the subimages.txt file to ascertain the correct/real number of tiles. Is there another neat way to achieve this? I could have a decode text file that states how many real tiles there are but it feels clumsy.

Not a biggIe as we're only talking about a few blank tiles but... you know... correctness etc

Using Tier 1 AppGameKit V2
Started coding with AMOS (Thanks Francois Lionet)
PartTimeCoder
AGK Tool Maker
9
Years of Service
User Offline
Joined: 9th Mar 2015
Location: London UK
Posted: 6th Sep 2017 21:39 Edited at: 6th Sep 2017 21:42
Quote: " I can't scan through that file until FileEOF says I've got to the last line. If I could do that, I could use the natural length of the subimages.txt file to ascertain the correct/real number of tiles."


You can, the subimages file must be in the same folder as the image and you know the image name so simply append "subimages.txt" to the end, open the file and count the lines.



or by id
Scraggle
Moderator
21
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 7th Sep 2017 07:37
Presumably, you made the atlas texture yourself so you should already know how many lines are in it.
If not (or also) you could open the subimages file in notepad and look at how many lines are in it.

If you need your project to be able to determine the number of lines in the subimages file at run time then you could loop through it as PTC has said but a quicker method is to simply note the number of lines and write that on the first line of the subimages file. Read that first, then loop through the subimages file that many times.

DavidAGK
AGK Developer
10
Years of Service
User Offline
Joined: 1st Jan 2014
Location:
Posted: 7th Sep 2017 08:26
Cheers guys, good solutions. Let me see what the delay is with the PTC version and then figure what will suit.

Thanks for your input.
Using Tier 1 AppGameKit V2
Started coding with AMOS (Thanks Francois Lionet)

Login to post a reply

Server time is: 2024-11-24 07:39:53
Your offset time is: 2024-11-24 07:39:53