Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (487)
Games in Android Showcase (110)
games submitted by our members
Games in WIP (553)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Spritesheets in Slick2D, most efficient way.  (Read 1148 times)
0 Members and 1 Guest are viewing this topic.
Offline Jacob Pickens
« Posted 2014-03-05 04:33:03 »

What would be the best way to load images into a slick2D game. Spritesheets or single images. If it is Spritesheets how would I go about that? I just want the fastest way to load images into a slick2D game. (As long as its not to complicated) Anyways, ya spritesheets.
Online Rayvolution

JGO Kernel


Medals: 185
Projects: 2
Exp: 1 year


Resident Crazyman


« Reply #1 - Posted 2014-03-05 04:38:27 »

It depends on your goals and your design. Both ways work. Wink

I use both depending on the situation, all of my animations are spritesheets, and so are all the images for my maps (that use TilEd files, and that requires sprite sheets anyway).

My GUI and my "items" (inventory items) are all single images though.

- Raymond "Rayvolution" Doerr.
Retro-Pixel Castles - Survival Sim/Builder/Roguelike!
LIVE-STREAMING DEVELOPMENT: http://www.twitch.tv/SG_Rayvolution
Offline Jacob Pickens
« Reply #2 - Posted 2014-03-05 04:43:01 »

Interesting thank you. Whats your loading times for SixtyGig? are you loading it on a separate thread?
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Online Rayvolution

JGO Kernel


Medals: 185
Projects: 2
Exp: 1 year


Resident Crazyman


« Reply #3 - Posted 2014-03-05 04:45:06 »

Loading time at the moment is basically instant. There's an ever-so-slight delay right as a large map loads though.

But right now everything is single threaded. Wink

EDIT: should also take into consideration I have hardly no "content" to load since I've been mostly working on programming the past few weeks. Wink

- Raymond "Rayvolution" Doerr.
Retro-Pixel Castles - Survival Sim/Builder/Roguelike!
LIVE-STREAMING DEVELOPMENT: http://www.twitch.tv/SG_Rayvolution
Offline Jacob Pickens
« Reply #4 - Posted 2014-03-05 04:47:09 »

Dang I only have like 30 images in my game atm (Slick2D, no sprite sheets, pre-optimized) and it's gotta take like 10 seconds
Online Rayvolution

JGO Kernel


Medals: 185
Projects: 2
Exp: 1 year


Resident Crazyman


« Reply #5 - Posted 2014-03-05 04:56:59 »

Dang I only have like 30 images in my game atm (Slick2D, no sprite sheets, pre-optimized) and it's gotta take like 10 seconds

Well, to be fair, I am loading the game off a machine with a 256gb SSD, Intel i7, 580GTX and 16Gb of ram. Cheesy

How big are these images you're loading? My sprite sheets are absolutely huge (768x1024 each, about 10 of them). You can checkout my video in my thread if you're curious on my load times.

- Raymond "Rayvolution" Doerr.
Retro-Pixel Castles - Survival Sim/Builder/Roguelike!
LIVE-STREAMING DEVELOPMENT: http://www.twitch.tv/SG_Rayvolution
Offline BurntPizza
« Reply #6 - Posted 2014-03-05 04:57:13 »

Two different ways to do something: different sets of pros/cons. Evaluate your situation, and act accordingly.

Spritesheets will tend to render faster, as there is only one texture (read: image) to bind. (Look up 'texture binding' if you don't get that)
How would you go about doing it? There are innumerable tutorials.

Separate images may be easier to edit, so if you are going to be making frequent changes to your GUI, etc, you might want to do that. After everything is finalized, you can then make a spritesheet out of it anyway.

Dang I only have like 30 images in my game atm (Slick2D, no sprite sheets, pre-optimized) and it's gotta take like 10 seconds

It's almost certainly something else that is causing the problem. I told you a few minutes ago in the other thread about premature optimization, now I'll tell you how to go about proper optimization: Measure and test. Specifically, use a profiler, such as VisualVM. It will tell you what is taking so long, and then you know exactly what to fix, so you don't waste time trying to fix other things that aren't causing the problem. Treat the cause, not the symptoms.
Again, I direct you to the great and almighty Google for more.

Offline Gibbo3771
« Reply #7 - Posted 2014-03-05 11:55:12 »

Dang I only have like 30 images in my game atm (Slick2D, no sprite sheets, pre-optimized) and it's gotta take like 10 seconds

Most likely an I/O problem, if the files are huge (many mb each can be considered huge) and your running a standard Sata drive then you will see the load time.

If you are loading those 30 images constantly on load, say you have a map that is 32x32 tiles and each image takes up 1 tile, that is 1024 tiles in total.

If you are loading an image from disk for each and every tile, then this will be 1024 I/O operations...that is very inefficient.

Instead you should maybe take a look at loading in all images ONCE, maybe store them as a static final field in an assets class or asset manager and then create new instances from them. This means regardless of how many tiles you have, 1024 or 3523635734626 you are only having to load the files in once from the disk.

"This code works flawlessly first time and exactly how I wanted it"
Said no programmer ever
Offline kappa
« League of Dukes »

JGO Kernel


Medals: 76
Projects: 15


★★★★★


« Reply #8 - Posted 2014-03-05 12:17:33 »

I'd say go with single images, its easier, more flexible and faster for development.

Spritesheets although more efficient for rendering just add needless complexity during development.

You should leave optimisations until the end, if it turns out that binding too many images is a bottleneck then you can always switch to spritesheets later.
Offline Grunnt

JGO Wizard


Medals: 66
Projects: 8
Exp: 5 years


Complex != complicated


« Reply #9 - Posted 2014-03-05 13:48:53 »

Dang I only have like 30 images in my game atm (Slick2D, no sprite sheets, pre-optimized) and it's gotta take like 10 seconds

What size (in KB or pixels) are these images? It should not take that long...

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Gibbo3771
« Reply #10 - Posted 2014-03-05 14:27:56 »

Dang I only have like 30 images in my game atm (Slick2D, no sprite sheets, pre-optimized) and it's gotta take like 10 seconds

What size (in KB or pixels) are these images? It should not take that long...

I assume he only has 30 images but he is loading them from disk 100's or 1000's of times for every object he creates, such as a grass   or stone tile.

"This code works flawlessly first time and exactly how I wanted it"
Said no programmer ever
Offline Jacob Pickens
« Reply #11 - Posted 2014-03-05 21:31:43 »

I have 64x64 pixel images along with an image manager class that loads everything upon start up.
Offline BurntPizza
« Reply #12 - Posted 2014-03-05 21:55:50 »

Make sure you only load 1 of each image, it could be that you are loading many copies of each, i.e. one for each tile (or whatever the images are), which would cause the slowdown you are seeing.

Also, consider not loading everything at start up, if it can be loaded really quick (64x64 images will be quick), then you could load only what you need for the level that is being played, etc. However do this only if loading times are still a problem, otherwise it's only another thing to potentially get wrong.
Offline Grunnt

JGO Wizard


Medals: 66
Projects: 8
Exp: 5 years


Complex != complicated


« Reply #13 - Posted 2014-03-06 08:37:03 »

Also, you may want to make sure the image loading is actually the source of the problem, and not e.g. the JVM that needs to load (slowly), which may take some time.

Pages: [1]
  ignore  |  Print  
 
 

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

CopyableCougar4 (24 views)
2014-08-22 19:31:30

atombrot (34 views)
2014-08-19 09:29:53

Tekkerue (30 views)
2014-08-16 06:45:27

Tekkerue (28 views)
2014-08-16 06:22:17

Tekkerue (18 views)
2014-08-16 06:20:21

Tekkerue (27 views)
2014-08-16 06:12:11

Rayexar (65 views)
2014-08-11 02:49:23

BurntPizza (41 views)
2014-08-09 21:09:32

BurntPizza (33 views)
2014-08-08 02:01:56

Norakomi (42 views)
2014-08-06 19:49:38
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!