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 / Tileset management

Author
Message
LeGugusse
17
Years of Service
User Offline
Joined: 15th Feb 2007
Location: Paris - France
Posted: 30th Dec 2011 15:57
Hi,

Is there a way, with AppGameKit, to load a sprite from an image tileset?

I mean:
The tileset is an image of n X n tiles of 64 x 64 pixels.
I want to load the tile X,Y and make a sprite with it.

Is that possible?

thanks.

Cry "Havoc!" and let slip the dogs of war
Digital Awakening
AGK Developer
21
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Sweden
Posted: 30th Dec 2011 16:03
Make an animated sprite and set the correct frame for that tile.

LeGugusse
17
Years of Service
User Offline
Joined: 15th Feb 2007
Location: Paris - France
Posted: 30th Dec 2011 16:16
Ok, I see the method.
But it's a long work...
Thanks.

Cry "Havoc!" and let slip the dogs of war
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 30th Dec 2011 16:44
Try looking at the "SetSpriteAnimation( iSpriteIndex, iFrameWidth, iFrameHeight, iFrameCount )" command. It will do what you want in one command I believe.

Digital Awakening
AGK Developer
21
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Sweden
Posted: 30th Dec 2011 17:37
That and SetSpriteFrame().

Marl
12
Years of Service
User Offline
Joined: 19th Nov 2011
Location: Bradford, UK
Posted: 1st Jan 2012 19:18
While I also use the method suggested by Digital Awakening / baxslash, it's only fair to point out that AppGameKit also uses atlas files which were designed for this very purpose.

It just happens that hijacking sprite animation functions for tileset use saves a ton of work setting up atlas coordinate files
LeGugusse
17
Years of Service
User Offline
Joined: 15th Feb 2007
Location: Paris - France
Posted: 2nd Jan 2012 10:01
Can you tell me what you call "Atlas" files?

Cry "Havoc!" and let slip the dogs of war
The Zoq2
14
Years of Service
User Offline
Joined: 4th Nov 2009
Location: Linköping, Sweden
Posted: 2nd Jan 2012 10:44
An atlas file is a normal imagefile...
Marl
12
Years of Service
User Offline
Joined: 19th Nov 2011
Location: Bradford, UK
Posted: 2nd Jan 2012 14:12
To save duplication, check out this thread for more details.
http://forum.thegamecreators.com/?m=forum_view&t=192926&b=41
LeGugusse
17
Years of Service
User Offline
Joined: 15th Feb 2007
Location: Paris - France
Posted: 2nd Jan 2012 14:25
Ok!
I understand the use of the loadSubImage()!
Thanks!

That means if you want to use, eg, a rpg maker tileset, you need to make your own txt file?

Cry "Havoc!" and let slip the dogs of war
Marl
12
Years of Service
User Offline
Joined: 19th Nov 2011
Location: Bradford, UK
Posted: 3rd Jan 2012 03:28
Quote: "That means if you want to use, eg, a rpg maker tileset, you need to make your own txt file?"

It depends on the source of your images.

Since atlas files are an established format, many tileset generating programs produce this file as part of the export function.

Hubdule's excellent font tool does exactly that;
http://forum.thegamecreators.com/?m=forum_view&t=189225&b=41

I imagine "Model-2-Sprite" and "SpriteMe" also do, but have not used either so can't confirm this.
Digital Awakening
AGK Developer
21
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Sweden
Posted: 6th Jan 2012 13:23
No need to use an atlas file if all of your tiles are the same size.

baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 6th Jan 2012 13:28
Quote: "No need to use an atlas file if all of your tiles are the same size."

Unless they are not square. If you are using an image 32x128 it will be bloated to 128x128 in memory, in this case combining 4 images that are 32x128 into one image 128x128 would save you 3 times the memory.

Digital Awakening
AGK Developer
21
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Sweden
Posted: 6th Jan 2012 14:00
It is my understanding that 32x128 stays that size. But say 50x100 would become 64x128.

But that wasn't really the issue. If you have a tileset image where all the tiles are the same size it is pointless to use an atlas to split up the tiles.

An atlas should be used to have multiple images within the same image. The advantage of using an atlas is that it renders faster than using multiple images. For example you could have multiple tileset images within one atlas image.

baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 6th Jan 2012 14:18
Quote: "It is my understanding that 32x128 stays that size. But say 50x100 would become 64x128."

Perhaps I've misunderstood. I'm not sure I have any way of checking this though...

Digital Awakening
AGK Developer
21
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Sweden
Posted: 6th Jan 2012 14:32
I'm not saying I'm 100% correct on that though. But I believe each dimension should be ^2. So if anyone can say for sure it would be nice

bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 6th Jan 2012 16:15
we need someone from TGC to confirm if images will be rounded up to the next square size or ^2.
Paul Johnston
TGC Developer
21
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 10th Jan 2012 18:57
Quote: "It is my understanding that 32x128 stays that size. But say 50x100 would become 64x128."


Correct, the dimensions only need be a power of 2, they don't need to be square.
Digital Awakening
AGK Developer
21
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Sweden
Posted: 10th Jan 2012 21:08
Thanks Paul

Preben
AGK Studio Developer
19
Years of Service
User Offline
Joined: 30th Jun 2004
Location:
Posted: 15th Jan 2012 11:01
Use AppGameKit to generate your tileset cords, in your code you already know what you want ( your tileset loading code ) so do something like this:



Locate the tileset1 subimages.txt file and copy it to your media folder. you can use the same "tileset1 subimages.txt" file for all your 64x64 tilesets just rename the file.

best regards Preben Eriksen,

Login to post a reply

Server time is: 2024-04-26 14:21:24
Your offset time is: 2024-04-26 14:21:24