To get a better feeling for jme i am creating a few example games to see how to create different kinds of games.
I like to share the first one i completed to get a bit of feedback.
It is probably not very optimized but shows how to implement a few things.
A few parts are directly out of tutorials others i figured out with help from ppl here in the forum.
This example is a fight between two robots on a grid-like ground. I played arround with glow for some objects too.
The enemy is rather dumb while firendly but gets pretty aggressive once the player enters its attack range.
Even tho the game is fun (i played a few rounds after completing before i realized how much time i spend playing ).
Somehow the fps is pretty low, don’t realy know why, because all the objecta are very simple. I wanted to create an example without loading any assets and only using basic jme librarys. Maybe someone can give me some clues why this is the case. Its also all in the main class so you can copy paste it into a new project and just hit run.
So here is the code. Any comments or improvements welcome, enjoy:
Seems like maybe some code was gobbled up around line 265.
The forum is nearly useless for posting code (which is too bad considering we are a code-based project)… so if you don’t turn all of the less-than and greater-than symbols into encoded forms then it screws up the posted code and gobbles chunks up.
I have a few other projects i am currently working on like this i probably will contribute, so if you like you can add me too those simpleExamples and i can ad them there too.
On the casing i did not put in any validation or extra casting because in this small scale i know for sure that i find a float there.
@ryukajiya said:
I have a few other projects i am currently working on like this i probably will contribute, so if you like you can add me too those simpleExamples and i can ad them there too.
On the casing i did not put in any validation or extra casting because in this small scale i know for sure that i find a float there.
Cool! Just send me your gmail and i’ll add you. You will need Mercurial client to commit. Good contribution!
About casting: I cannot compile if i have no casting on my machine (Linux, java7).
I’ll get such an exception:
Updating property file: /home/mifth/jMonkeyProjects/jme-simple-examples/JMESimpleExamples/build/built-jar.properties
Compiling 1 source file to /home/mifth/jMonkeyProjects/jme-simple-examples/JMESimpleExamples/build/classes
/home/mifth/jMonkeyProjects/jme-simple-examples/JMESimpleExamples/src/com/intermediate/Main.java:363: type parameters of T cannot be determined; no unique maximal instance exists for type variable T with upper bounds float,java.lang.Object
float enemyhealth = enemy.getUserData(“health”);
1 error
/home/mifth/jMonkeyProjects/jme-simple-examples/JMESimpleExamples/nbproject/build-impl.xml:926: The following error occurred while executing this line:
/home/mifth/jMonkeyProjects/jme-simple-examples/JMESimpleExamples/nbproject/build-impl.xml:307: Compile failed; see the compiler error output for details.
@ryukajiya said:
Ok, sis not know it causes problems on other platforms. IDE did not complain about it so i left it like this, but can change it no problem.
I guess it cannot even run on my machine if you compile it on your machine. Just a remark if you will make any commercial project. Check if it works on linux+java7.
I am using Java7 JDK too on windows tho, so this might actualy a problem that is platform dependant.
Changed the gist code to cast the floats correctly. Were a few more places too.
@ryukajiya said:
I am using Java7 JDK too on windows tho, so this might actualy a problem that is platform dependant.
Changed the gist code to cast the floats correctly. Were a few more places too.
Yeah, strange thing though… Dunno know how it works on Mac.