Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (491)
Games in Android Showcase (112)
games submitted by our members
Games in WIP (555)
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  
  Azzet - Asset loading library  (Read 1729 times)
0 Members and 1 Guest are viewing this topic.
Offline ClickerMonkey

JGO Coder


Medals: 20


Game Engineer


« Posted 2013-02-06 19:58:33 »

Azzet is a simple library I created awhile back but finally decided to put it up on GitHub.

https://github.com/ClickerMonkey/azzet

It is an asset loading framework where you can pull assets from various sources in various formats. You can add your own formats and sources if you want.

Code Example:

1  
2  
3  
4  
5  
BufferedImage img = Assets.load("http://www.google.com/logos/classicplus.png"); // loaded from website
Font fnt = Assets.load("myfont.ttf", new FontInfo(32.0f)); // loaded from classpath
Clip snd = Assets.load("C:\UserData\MyMusic.wav"); // loaded from file-system
BufferedImage[] gif = Assets.loadFrom("mygif", "db"); // loads from DatabaseSource saved as "db"
Properties props = Assets.loadFrom("app.properties", "tcp"); // loads from TcpSource saved as "tcp"


Checkout the README for the link to examples, documentation, and downloads.

If you have any format requests (I was debating about adding a JOGL/LWJGL branch for Textures and Audio or something...) OR problems please let me know.

Let me know what you think!

Thanks

Offline sproingie

JGO Kernel


Medals: 202



« Reply #1 - Posted 2013-02-06 22:54:42 »

1  
2  
BufferedImage[] gif = Assets.loadFrom("mygif", "db"); // loads from DatabaseSource saved as "db"
Properties props = Assets.loadFrom("app.properties", "tcp"); // loads from TcpSource saved as "tcp"


How does it know the first was a DatabaseSource and the second was a TcpSource?
Offline ClickerMonkey

JGO Coder


Medals: 20


Game Engineer


« Reply #2 - Posted 2013-02-06 22:59:45 »

You add the sources at the start of the program:

1  
2  
Assets.addSource( "db", new DatabaseSource( getConnection(), "SELECT asset FROM asset_table WHERE name = ?" ) );
Assets.addSource( "tcp", new TcpSource( "129.24.84.10", 858 ) );


See the documentation for the Assets class (specifically loadFrom)

http://clickermonkey.github.com/azzet/

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline ReBirth
« Reply #3 - Posted 2013-02-07 02:52:24 »

I like the API (methods), but a class parameter will be nice for readability. Like
1  
Clip snd = Assets.load("C:\UserData\MyMusic.wav", Clip.class);

Offline ClickerMonkey

JGO Coder


Medals: 20


Game Engineer


« Reply #4 - Posted 2013-02-07 02:56:14 »

You can do that =)

Edit:

Here are all the load methods:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
load(String request) 
load(String request, AssetInfo requestInfo)
load(String request, Class<A> requestType)
load(String request, String requestExtension)
load(String request, String requestExtension, AssetInfo requestInfo)
loadFrom(String request, String sourceName)
loadFrom(String request, String sourceName, AssetInfo requestInfo)
loadFrom(String request, String sourceName, Class<A> requestType)
loadFrom(String request, String sourceName, String requestExtension)
loadFrom(String request, String sourceName, String requestExtension, AssetInfo requestInfo)

Offline ClickerMonkey

JGO Coder


Medals: 20


Game Engineer


« Reply #5 - Posted 2013-02-07 20:50:43 »

Just added background loading!

Here's an example of using FutureAssetBundle (opposed to handling the FutureAssets directly and checking the status of each):

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
 FutureAssetBundle bundle = new FutureAssetBundle();
 bundle.add( Assets.loadFuture("image.gif", BufferedImage.class) );
 bundle.add( Assets.loadFuture("sound.wav", Clip.class) );
 
 BufferedImage image = null;
 Clip sound = null;
 
 while (running) {
       // do stuff
   
     if (bundle.isComplete()) {
         bundle.loaded(); // notify all FutureAsset implementations the asset has been accepted.
        image = bundle.getAsset("image.gif");
         sound = bundle.getAsset("sound.wav");
         // move from loading to play screen
    } else {
         display bundle.percentComplete();    
     }
     
     // do other stuff
}


So now there are loadFuture and loadFutureFrom methods that return FutureAsset<A>.

Offline Cero
« Reply #6 - Posted 2013-02-07 20:52:25 »

seems pretty dope

since I use Libgdx I really value a good asset system

Offline ReBirth
« Reply #7 - Posted 2013-02-08 01:44:26 »

Yeah it looks like libgdx's AssetManager (at least from the front). What I like from this is static Grin

Offline ClickerMonkey

JGO Coder


Medals: 20


Game Engineer


« Reply #8 - Posted 2013-02-08 01:49:32 »

Hmm I'll have to look at LibGDX's... I've never used it... my original design for this was half inspired by JME's... perhaps LibGDX's was as well.

Offline ReBirth
« Reply #9 - Posted 2013-02-08 02:30:31 »

http://code.google.com/p/libgdx-users/wiki/AssetManager

However I encounter weird problem with the manager on my latest android game.

http://www.java-gaming.org/index.php/topic,28682.new.html

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline ClickerMonkey

JGO Coder


Medals: 20


Game Engineer


« Reply #10 - Posted 2013-02-08 02:35:56 »

http://code.google.com/p/libgdx-users/wiki/AssetManager

However I encounter weird problem with the manager on my latest android game.

http://www.java-gaming.org/index.php/topic,28682.new.html

The example on that page is out of date, here's the correct url (looks like libgdx moved from google code to github):

https://github.com/libgdx/libgdx/blob/master/tests/gdx-tests/src/com/badlogic/gdx/tests/AssetManagerTest.java

Yeah I read your post, I swear a few weeks ago I read someone else also having this error... like OpenGL (or whatever backend) did not properly or completely release a texture on shutdown... so when they restarted it seemed to still be loaded... or perhaps it was because the texture IDs were used but actually weren't... or maybe the opposite of that. Either way, I don't use LibGDX so I'm no expert.

Offline ReBirth
« Reply #11 - Posted 2013-02-08 03:22:15 »

Maybe I should call dispose() before exit(). On the docs it says "Exits the application. On android, this will cause a call to pause() and dispose() some time in the future, it will not immediately finish your application.".

I dont know if you plan to make this lib android-compatible too but hope you can consider this too while dev Smiley

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.

Nickropheliac (15 views)
2014-08-31 22:59:12

TehJavaDev (23 views)
2014-08-28 18:26:30

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

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

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

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

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

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

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

BurntPizza (48 views)
2014-08-09 21:09:32
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!