It is currently Sat Oct 20, 2018 4:29 am

All times are UTC + 9:30 hours

Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: image loading
PostPosted: Sat Jan 24, 2009 9:18 am 
Main Coder

Joined: Fri Apr 04, 2008 10:50 pm
Posts: 169
I would like to propose a different way to load images.
Images should be loaded from 1 place, and loaded once at startup.

Example code could be:
Image img = resources.getImage("yourImgName")
Further the image could be read from a file like:

o read single image
unit is the name used in the code to get a reference to unit images, so when the path changes the code is not affected.
o unit res/img/unit/img.gif

Terrain images can be loaded & split into an ImageStrip like:
List<Image> terrainImages
getting a plain image: (imagine plain having Id 1)

s terrainStrip res/terrains.png 45
List<Image> terrainImages = resources.getImages("terrainStrip")

Now we want to load a spriteSheet(matrix img) and still be able to retrieve it by id(as in a strip)
a terrainStrip res/terrains.png 5 20
List<Image> terrainImages = resources.getImages("terrainStrip")
The difference is that with a spriteSheet the images can be on multiple rows, they don't have to be on 1 row.

and finally a unit spritesheet (where 1 row = 1 unit)
resources.getSpriteSheet("unit).get(unitID).get(0) wil retrieve the first image for unit type unitID.

o <fileName> A single image
s <fileName> <number> An images strip
m <fileName> <rows> <cols> Rows of images strips
a <fileName> <rows> <cols> A Matrix image converted to one strip

Images can be recolored behind the scenes so you can type
resources.getUnitImageInColor(Color c, int unitID)

that's about it, note that I store images 2x The original and the ones in the lists. The originals are needed for recoloring. recoloring any img can also be configured from a file.

 Post subject: Re: image loading
PostPosted: Wed Feb 04, 2009 9:52 pm 
Main Coder

Joined: Fri Apr 04, 2008 10:50 pm
Posts: 169
Each plugin will have different images to be loaded, a different unit spriteSheet image etc.
Internally the game will load a 'unit' spritesheet what this unit spriteSheet looks like is defined by the plugin.

Chom proposed to put each plugin in it's own dir
So we put an imgLoader txt file in each plugin dir that maps 'unit' to the actual sprite sheet location.

units awDefault/images/unit/unitSheet.png
properties awDefault/images/unit/propertySheet.png

units adHocWars/images/units.png
properties adHocWars/images/propertySheet.png

Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC + 9:30 hours

Who is online

Users browsing this forum: No registered users and 1 guest

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Blue Moon by Trent © 2007
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group