Tilengine - The 2D retro graphics engine forum
Tilengine on Java - Printable Version

+- Tilengine - The 2D retro graphics engine forum (http://tilengine.org/forum)
+-- Forum: English forums (http://tilengine.org/forum/forumdisplay.php?fid=3)
+--- Forum: Support (http://tilengine.org/forum/forumdisplay.php?fid=7)
+--- Thread: Tilengine on Java (/showthread.php?tid=952)

Pages: 1 2 3 4 5 6 7 8


RE: Tilengine on Java - megamarc - 12-09-2020

Hi,
I'll check the attached 7z later, thanks.

For objects, you can use the "Object Layer" feature:
http://www.tilengine.org/doc/md_layers.html#autotoc_md31

These can be directly loaded and drawn by Tilengine from Tiled object layers. However, if you want to use them a spawning points in your gameplay, you have to do it by hand. There is the function TLN_GetObjectList that allows to iterate along all the objects in the list. Based on their type and position relative to the viewport, you can use them as spawning points. That's what the Python Platformer example does:


https://github.com/megamarc/TilenginePythonPlatformer/blob/31db4893ee1af48d772fac857e139c2d62823db9/platformer.py#L30

That example does create the list loading directly the .tmx file without Tilengine support. After that, I added the "object layer" feature where you can load and query the object list directly from within the engine.


RE: Tilengine on Java - System64 - 12-09-2020

Oh so it shouldn't be so hard if I can spawn objects with data inside the list (the object and its cordinates). I'll experiment that.

Update : On Tiled, I saw I can define custom properties for a tile (in the tileset editor) in the left pannel, the properties pannel. Can I also use that to define a propertie for each tile?


RE: Tilengine on Java - megamarc - 12-09-2020

Yes, Tilengine can read two custom tile properties, that can be queried with TLN_GetLayerTile() function into a TLN_TileInfo structure:
  • type: numeric value, member "type" of TLN_TileInfo structure. Its value is up to you.
  • priority: sets FLAG_PRIORITY in member "flags" of TLN_TileInfo struct. Makes the tile appear in front of sprites
They're both demosntrated on front layer of "Python Platformer" project:
https://github.com/megamarc/TilenginePythonPlatformer


RE: Tilengine on Java - System64 - 12-09-2020

Ah yeah the custom type field is useful, that means I can define a behavior for each type, for exemple 1 for solid, 2 for semisolid, 3 for a ladder, etc...


RE: Tilengine on Java - megamarc - 12-09-2020

Yes!
This is the intended use case of the custom "type" attribute :-)


RE: Tilengine on Java - System64 - 12-09-2020

I think the Python Platformer and Super Mario Clone C# are probably the best samples : It shows how a small prototype game can be built with the engine. Others are good too, it can learn what you can do, but not really help to build a project itself


RE: Tilengine on Java - megamarc - 12-10-2020

Both are quite complex samples. I think the samples bundled with the engine must be simple and showcase basic features. The creation of working gameplay mechanics is beyond the scope of the engine itself, so I decided to publish them as separate projects. But they're the reference demonstration on how to implement actual game mechanics with it.


RE: Tilengine on Java - System64 - 12-10-2020

that's not magical, you can have any engine or framework, it can bring some functions or interfaces to manage ressources, you have to implement mechanics by yourself. An engine won't help you to make your character jumping. Maybe with a very specific engine, but it should be rare to find or for internal use, so not public.


RE: Tilengine on Java - System64 - 12-10-2020

I still update the Java bindings and I have some problems.

I updated some simple functions likes TLN_GetLayerHeight and updated the Tilengine.java too

And when this function is executed, my program crashes and displays :

Exception in thread "main" java.lang.UnsatisfiedLinkError: Tilengine.GetLayerHeight(I)I

at Tilengine.GetLayerHeight(Native Method)
at TestWindow.main(TestWindow.java:46)

Is it normal? the method in Java is public native int GetLayerHeight (int nlayer); and the function in the binding is 

JNIEXPORT jint JNICALL Java_Tilengine_GetLayerHeight (JNIEnv* env, jobject thisobj, jint nlayer)
{
    return TLN_GetLayerHeight (nlayer);
}


Is it normal? Also, I just did a commit on my github fork so it's possible to see the changes I did.
Thanks for the answer


RE: Tilengine on Java - megamarc - 12-10-2020

You're doing great work with the binding!

I've updated my local working copy with your latest commit to se what happens. I have a java compilation error that is silly but prevents me from generating the final class to run. The error is duplicate definition of SetLayerTilemap inside Tilengine class:

Code:
.\Tilengine.java:225: error: method SetLayerTilemap(int,int) is already defined in class Tilengine
        public native boolean SetLayerTilemap (int nlayer, int tilemap);
                              ^

Aren't you getting this error?

At first sight what you've posted is correct, but have you modified TestWindow.java example? I see something strange here:
  • The sample never calls directly GetLayerHeight()
  • Your output complains that the error is located in line 46 of main() function, but on my original sample, line 46 is a call to LoadTilemap() inside run() function.
Am I missing something?