-=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- (c) WidthPadding Industries 1987 0|170|0 -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=-
SoCoder -> Showcase Home -> Functions Libraries


 
JL235
Created : 04 August 2007
Edited : 02 February 2009
System : Server Based
Language : Ruby

Llama

Simple 2D Java Game Library

Llama.jar
Screenshots
Version 1 of my new simple 2D Game Library for Java is finally complete. Inspired by Blitz, it offers Java's great 2D capabilities wrapped into a couple of very easy to use, simple classes.

Full Documentation available here!

Features include:
  • Different types of the 'GraphicsDisplay' class to offer full screen, windowed and border-less windows for your games.
  • Multiple windows support
  • A simplified control interface giving the coder the ability to simply check if a key is down or not, thus removing the need to set up complex event listeners.
  • Unified graphics commands for both windows and images.
  • Full documentation
  • Hardware accelerated double buffering.
  • Sound support.

To use, simply download the jar and import it as a library. If you are using NetBeans this is done in your projects properties settings. Finally in your class it's a simple: 'import llama.*;'

Soon to come:
  • Hardware accelerated images,

Latest Update

Version 1.1 is now complete! Version 1 adds Sound support, a few fixes, default program close for windows.

For my long term model, I now plan to port my whole library over to Java3D for version 2. This will allows faster images, buffers and better sound support.

 

Comments


Saturday, 04 August 2007, 01:31
JL235
My library uses the Java library, so no. However Jython (Python on the Java VM) and JRuby (Ruby on the Java VM) are fully compatible with Java classes, as well as lots of other languages ported to the Java VM.
Saturday, 04 August 2007, 09:39
Nolan
Neat. I'll definitely be giving this a try soon, now that I use Java a lot. Any chance you'll ever wrap some openGL-Java bindings into this library? It would give you a lot more power and customization.
Saturday, 04 August 2007, 10:04
HoboBen
Hi Diablo,

I've always been confused by Java (I have books on it, but they're very old!) but do you think you could post a small piece of example code that imports the library and draws a few shapes so that I can use that to get an idea of how things work?

Cheers mate
Saturday, 04 August 2007, 12:16
Scherererer


Draws a circle in random places on the screen!

|edit| Edited to comply with new standards! |edit|
Saturday, 04 August 2007, 15:08
HoboBen
Oh cool - thanks Instinct.

Time to dig up the old development environment...
Saturday, 04 August 2007, 17:01
JL235
I have a few changes for Instincts code. The application doesn't close when the window does, as otherwise it wouldn't be able to handle multiple windows.

I don't like the look of that for loop so instead I'd suggest a while loop with 'g.isRunning()' as it's condition. When the window is closed it no longer running and so the loop will break.

Instinct is also using an early alpha version of the library, as it's GraphicsDisplay and not Graphics.



Nolan, if available, it will perform the buffer operations on your graphics card. I have plans to add another image class which uses Java's 'VolatileImage' class where the image data is stored on the graphics card. Behind the scenes, Java will use DirectX if you are running Windows and OpenGL on other operating systems. If these are not available to Java, then it will use software rendering.
Saturday, 04 August 2007, 18:48
Nolan
Sounds promising. At first, I thought the library was rather slow. Wondering why, I opened up task manager and saw about 30 instances of java.exe... probably because, using the for(; loop, the program didn't correctly shut off. I could be wrong, however.

I had a pretty sweet particle program running, but accidentally ended the process of the wrong 'java.exe', which closed down netbeans before I saved the code. Oh well... still a pretty cool library!
Saturday, 04 August 2007, 19:19
JL235
Yes, the for loop will never end. That is why it will never shut.

Because I wanted it to allow multiple windows to be used it means I don't set to have the program end when a window is closed (although I could add that as an option). Instead you either need to run out of code (which your not with that for loop) or do 'System.exit(0)'. That is why I'd also suggest 'while (g.isRunning())'.

Also, for an infinite loop I think 'while (true)' is also better then 'for (;'. The condition is a lot more obvious.

|edit| Please also note that Instincts code is pausing so the oval doesn't move around too quickly. You don't need to use pause code normally. I will also be making some example code. |edit|
Saturday, 04 August 2007, 19:57
Nolan
although I could add that as an option

That would be a very good option, and a simple one to add, I would think.

The condition is a lot more obvious.

Perhaps, but does that really matter? The coder is the one who sees the source, so as long as he/she understands it, I see no problem with using a more confusing loop such as for(;.

Still though, I see what you mean.
Saturday, 04 August 2007, 20:52
JL235
Many coders may not have seen a for loop like before. I haven't. So it means you then have to think about and estimate what it will do, with testing being the only real guarantee that your right.

Nolan The coder is the one who sees the source

What if your coding for a company or in a team? Then other people will have to read, add and maintain your code. It's important that they then understand the source as quickly as possible to help them learn how your code works and what it does.

I'll add that option to the list. Maybe I could add it to the constructor, something like 'GraphicsWindow(int width, int height, String title, boolean endOnClose)'. For your main window you could pass true into there, but for any others you could miss that parameter out and it would default to false.

This means you could have three windows, say a main window and two others, and the program will only end when the main window is closed.

I'm also thinking of adding a 'plot' and 'getPixel' methods to the Drawable class, but sound support is top of my list.
Saturday, 04 August 2007, 21:20
Scherererer
Haha, my bad with the for loop . And also with the Graphics instead of GraphicsDisplay... Ironically I was thinking about it but I got distracted and didn't fix it before I posted. I think if you have an endOnClose by default it should be set to true, since most things will require it to end when closed.

I'm really not sure why I use the for(; instead of while(true), probably just because it's fewer characters .
Sunday, 05 August 2007, 00:27
JL235
Actually, I was a little wrong. Java does not exit when you run out of code, so I will be adding the exit on close as default.

For now putting 'System.exit(0);' at the end of your code will get Java to quit.
Friday, 10 August 2007, 02:44
JL235
Updated!
Monday, 13 August 2007, 01:46
Phoenix
I've now downloaded Java and gotten your engine running, and I like it It reminds me a lot of Blitz. Good job! I might actually make something useful with it.
Monday, 13 August 2007, 05:18
JL235
Blitz command reference is one of my biggest influences. For my own projects I wanted to use a library which was just as simple, and didn't use events lists for controls.