Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Tilengine on Java
#21
I think I see the problem.

First, check the syntax, this is incorrect:

-I"../Tilengine.dll"


The -I parameter should not be used here. It is used to include headers, but the dll is a binary.

Biggest problem is that you're using mingw64, that is used to build 64-bit binaries, but you're linking to 32-bit version of Tilengine.dll. You cannot combine  executables of different architecture. You must link against 64-bit version of Tilengine.dll.

I wrote the binding when my main development machine was still 32-bit, I haven't tested it with 64-bit compilers... I'll check
Reply
#22
I finally did it! And it works on Java!

This update is still in a Work In Progress state, but I think the most of functions are updated.

You can find the WIP update here https://github.com/system64MC/JTilengine/
Reply
#23
Congratulations!!
I'm glad you made it work. Keep going! Let me know if you need more support.
Regards,
Reply
#24
Thanks! I'll can now use this fantastic Engine!
Reply
#25
I want to allow the creation of multiples raster effects, so I have to create an object instance of a Raster Effect class, what I did. But it doesn't work.

How can I achieve that please?

what I did is creating a raster effect class :

Code:
public class RasterEffects {

   private final Layer layer;

   public RasterEffects(String rasterMode, Layer layer) {
       this.rasterMode = rasterMode.toLowerCase();
       this.layer = layer;
   }

   public void setRaster()
   {
       Global.tln.SetRasterCallback(this, this.rasterMode);
   }

   public String getRasterMode() {
       return rasterMode.toLowerCase();
   }

   public void setRasterMode(String rasterMode) {
       this.rasterMode = rasterMode.toLowerCase();
   }

   private String rasterMode;

   public void createRaster()
   {
       Global.tln.SetRasterCallback(this, "mode7");
   }

   public void mode7(int line)
   {
       if(line == 24)
       {
           Global.tln.DisableLayer(layer.getLayerID());
       }
   }
}

And after I tried to instanciate it in the main class :

Code:
...
RasterEffects raster = new RasterEffects("mode7");
raster.setRaster();
...
while(Global.tln.ProcessWindow())
       {
            ...
            raster.mode7();
       }

But it asks for a Line argument, thing you don't use in your sample.
Also, the compiler says "java.lang.NoSuchMethodError: raster.mode7" that means the method probably doesn't exist. But I created this method.

What can I do to fix that please? Thanks for the answer.
Reply
#26
Hi,

If you check provided samples, you'll see that "line" argument is heavily used inside the raster effect body:
https://github.com/megamarc/JTilengine/b...w.java#L89


Code:
// set the raster callback function name
tln.SetRasterCallback (this, "rasterCallback");

// callback body
void rasterCallback (int line) {
   ...
}

Before trying to encapsulate in classes and instances, make sure that the samples work, and then try to modify them to check that you understand its mechanism. One change each time. Also keep in mind that only one raster effect callback can be enabled. Ussing classes and instances may (or may not) introduce issues unrelated to the engine itself.
Reply
#27
So I can't have a different raster effect for Layer1, another for Layer2 and another for Layer3?

By the way, is it possible to make methods in the Tilengine class Static?

UPDATE : I checked for raster effets and effectively I can't use multiples Raster Effects at the same time.
But what I can do is creating multiple raster effects methods and selecting the right one when I need a particular one.
Reply
#28
I continued to convert some functions to JNI and I encountered a problem.

I tried to convert this function : 

- .h file -
Code:
TLNAPI void TLN_EnableCRTEffect (TLN_Overlay overlay, uint8_t overlay_factor, uint8_t threshold, uint8_t v0, uint8_t v1, uint8_t v2, uint8_t v3, bool blur, uint8_t glow_factor);


- So I did that in TilengineJNI.c - 

JNIEXPORT void JNICALL Java_Tilengine_EnableCRTEffect(JNIEnv* env, jobject thisobj, jint overlay, jbyte overlay_factor, jbyte threshold, jbyte v0, jbyte v1, jbyte v2, jbyte v3, jboolean blur, jbyte glow_factor)
{
    TLN_EnableCRTEffect (overlay, overlay_factor, threshold, v0, v1, v2, v3, blur, glow_factor);
}


And in Tilengine.java : 

public native void EnableCRTEffect(int overlay, byte overlay_factor, byte threshold, byte v0, byte v1, byte v2, byte v3, boolean blur, byte glow_factor);

When I run the program, it instantly crash at launch. Did I do something wrong?
Reply
#29
Hi!

Raster effect is a global frame feature, that's why you can't have one for each layer. However, you can modify any layer or sprite parameters inside the same callback. That's what the example shooter.c does. It's a bit complicated, but you can see that the raster callback operates heavily on both background layers to simulate depth and enhance parallaxing:
https://github.com/megamarc/Tilengine/bl...ter.c#L208

Are you using Tilengine.h from release 2.8.5? In order to give advice on crashes, you should attach all your development project inside a zip and post it here: dlls, executable, classes, graphic assets... anything needed to run and reproduce the issue. Runtime crashes are often caused by inconsistences on the environment.

I have intention to remove the complex TLN_EnableCRTEffect() function and simplify it on a basic enable/disable on future releases, so don't bother with it either...
Reply
#30
I joined a ZIP with all my source files.
My workspace is a bit wonky because I'm testing engine's features. I have no idea if treating layers and raster effects as objects a good idea by the way, but it works.

Also, is it possible to put objects on the tilemap? Is there a function in Tilengine to spawn them where I put them on the tilemap? If not, how can I implement that?

Again, thanks for your help!


Attached Files
.zip   TestGame (2).zip (Size: 923.3 KB / Downloads: 1)
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)