Porting an Android Game Framework for Java Desktop usage

UPDATE: It is complete. It is a very basic framework for 2d games that don’t use OpenGL or so.

Here is a video where I show you how to start both versions, the android and the desktop one.

There is a snake Game implemented to show you the differences needed in the version,
as well as have something to test :stuck_out_tongue:

Please give me some feedback

hello everyone,
I am totally new to this forum, but already messing around with Android and Java for a good year now.

I started my journey with the Book “Beginning Android 4 Games Development” by Mario Zechner. Coded some stuff, tried out even more and now finally got to a point where I want to implement the Interfaces of that Framework for Java Desktop usage- meaning:

when I code a new Game using the Methods of that Frameworks’ interfaces, i want to be able to copy those classes
to an other version of the same Framework, where the only difference is that those Interfaces are implemented by Java Standart api methods, so i can have a Jframe Desktop Version of my game.

This repository holds both modules, take a look into the readme to see how it works.
For those only developing for Java, use the javalib directory as the running module. The app directory is the Android Module.

I am currently struggling on implementing the Input Interface, since there are 3 Classes sticking to it:
TouchHandler ( interface)
KeyboardHandler(class)
singleTouchHandler(class)
multiTouchHandler(class)

the input interface declares 2 classes, the key event class and the touch event class.

I think of using the touch event class as return type for mouse clicks in java.
My problem is of finding out a method like Mario Zachner did with the pool class which stores the events triggered and gives them back in a list upon request ( input interface -> getTouchEvents) this list I want to fill - for the java version - with touch events (of the input interface declaration) which correspond to triggered mouse events, meaning :

  • I’d need to have a mouselistener and analyze the triggered mouse events
  • Generate TouchEvents corresponding to the mouse events’ analyzation
  • store them in a list
  • return them in the interface method.

is my approach correct?
I thank everybody already who is willing to take a look at it :wink:

Have you tried looking into any of the cross-platform frameworks available? A while back I was recommended LibGDX here on the forum and it is really fantastic. With one code base you can easily compile to desktop, Android, iOS, and web and all of this is done automatically for you. So you don’t have to have multiple versions of the same project or move code around. :slight_smile:

Isn’t libgdx written by Mario Zachner too?
I guess I ´ll need to take a look at other frameworks to see how they solved this :stuck_out_tongue:

I’m not sure how many they have on the official LibGDX team (it’s open source so there are several contributors), but yeah Mario is one of the official guys. If you decide to make the switch there are a variety of listeners already provided in LibGDX for handling touch, multi-touch, keyboard, fling, etc.

I haven’t tested on iOS yet (no mac to compile on) but desktop and Android work perfectly. On desktop it handles mouse clicks and on Android it handles touch using the same listener code. For text input LibGDX also launches the Android onscreen keyboard but on desktop it uses the physical keyboard. You don’t have to handle any of the differences as that’s all hidden away by the “magic” of LibGDX. It’s very slick! :slight_smile:

okay thanks :slight_smile: i will take a look at it :wink: after having implemented my framework for java i will propably switch to a more complete framework , but i want to do it once myself to understand whats going on behind :slight_smile:

so here I am, searching the Input Implementations in Libgdx, I found this:

as I thought its the same guy ( mario Zachner ) developing libgdx.
It is in its fundamentals obviously build like the framework from his book.
I report back when i successfully archived the Java Implementation for his Book Framework.

okay it is mostly done, you can try out my extension of the framework.
the repository:

it includes both versions, an android module “app” and the java version “javalib”
to understand how this framework works read the book or ask me here about my java extension

i would be happy if others participate in this project, the original thread was opened by
me in the german android-hilfe forum.

please test it and give me some feedback :slight_smile:

it is done:

i added a simple snake game to show the result on different platforms.
most key parts are implemented cross platform, I left it simple enough to
leave it up to yourself what kind of game it will support.

see first post for github project link or check youtube description :slight_smile: