Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (541)
Games in Android Showcase (133)
games submitted by our members
Games in WIP (603)
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  
  (Slick2D) TiledMap resource efficiency  (Read 1230 times)
0 Members and 1 Guest are viewing this topic.
Offline DrewLols

Senior Devvie


Medals: 3
Projects: 1


Noob going through metamorphosis...


« Posted 2012-07-13 19:00:24 »

I'm really loving the tools that come out of the box of Slick2D!  I'm building a platformer game in which I control the transitions from area to area.

I'm only slightly concerned with loading's effects on the background music playing.  When transitioning from one level to another, there is a slight hiccup in the background music that is playing.  I've narrowed the problem down to the TiledMap that is used in each level.  I use a resource manager to dynamically cache and access resources.

Is there a way when creating a new TiledMap to re-use the resources used in previous TiledMaps?  If that's not possible, is there a way to prevent the TiledMap's loading from interfering with music playing in the background?  I also have considered preloading a TiledMap into the resource manager so that it may be used later without reading from a .tmx file.  I'd just like to know all of my options.

Thanks a bunch!

Did you know that 90% of statistics are wrong?
Offline ra4king

JGO Kernel


Medals: 356
Projects: 3
Exp: 5 years


I'm the King!


« Reply #1 - Posted 2012-07-13 19:09:29 »

Doesn't music play in its own thread? If so, then this seems like thread fighting really.

Offline DrewLols

Senior Devvie


Medals: 3
Projects: 1


Noob going through metamorphosis...


« Reply #2 - Posted 2012-07-13 19:12:40 »

It was my understanding that music played in it's own thread just like you said.  For some reason, though, the music skips a little when making transitions...  I actually tried what I mentioned above and preloaded TiledMaps, but the music always skips a tad when making transitions.  Strange...  The game's performance is generally buttery smooth in every other aspect.

Did you know that 90% of statistics are wrong?
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline ra4king

JGO Kernel


Medals: 356
Projects: 3
Exp: 5 years


I'm the King!


« Reply #3 - Posted 2012-07-13 19:18:56 »

How many cores does your CPU have? I wouldn't worry too much about this anyway.

Offline DrewLols

Senior Devvie


Medals: 3
Projects: 1


Noob going through metamorphosis...


« Reply #4 - Posted 2012-07-13 19:21:56 »

I'm pretty sure it's four.  Not that my laptop is particularly fast, though.  It get's its job done, but I usually get a better performance on other computers.  Anyway, yeah, I wasn't TOO concerned about this issue, but I'll post if I find a solution.

Did you know that 90% of statistics are wrong?
Offline DrewLols

Senior Devvie


Medals: 3
Projects: 1


Noob going through metamorphosis...


« Reply #5 - Posted 2012-07-13 19:47:02 »

Ah Ha!  I figured it out!  I use a bunch of HashMaps to store previously used data in my Resources class.  I was an idiot and forgot to put the resources used for font into its designated HashMap after being loaded the first time... Derp...  Doesn't COMPLETELY fix the problem with the music, but as long as I'm careful with my resources, the split second skippyness in the music shouldn't happen.

Did you know that 90% of statistics are wrong?
Offline davedes
« Reply #6 - Posted 2012-07-13 19:56:17 »

Slick’s music is streamed in the same thread as rendering/logic/etc which is most likely causing your issues.

Map loading should be pretty fast since it’s just parsing XML text – if it's slow, I'd imagine it's because the tiled loader is decoding/uploading texture data for a tilesheet. Instead, you should be loading the tilesheet image once, and reusing it with multiple maps. (If this isn’t currently possible with the TiledMap API, you should file a RFE.)

Another solution would be to use a different audio library which supports threading, like Paul’s SoundSystem or TinySound.

Offline ra4king

JGO Kernel


Medals: 356
Projects: 3
Exp: 5 years


I'm the King!


« Reply #7 - Posted 2012-07-14 02:11:35 »

Slick doesn't create a new thread just for audio?! That's not a good idea :S

TinySound uses JavaSound, which is completely unreliable. Just use OpenAL entire directly or through Paul's SoundSystem.

Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

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

The first screenshot will be displayed as a thumbnail.

Mr.CodeIt (10 views)
2014-12-27 04:03:04

TheDudeFromCI (13 views)
2014-12-27 02:14:49

Mr.CodeIt (25 views)
2014-12-23 03:34:11

rwatson462 (56 views)
2014-12-15 09:26:44

Mr.CodeIt (46 views)
2014-12-14 19:50:38

BurntPizza (92 views)
2014-12-09 22:41:13

BurntPizza (113 views)
2014-12-08 04:46:31

JscottyBieshaar (84 views)
2014-12-05 12:39:02

SHC (94 views)
2014-12-03 16:27:13

CopyableCougar4 (102 views)
2014-11-29 21:32:03
Resources for WIP games
by kpars
2014-12-18 10:26:14

Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

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
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!