Hi Guys,
Update, this has been released. Please see forum post here:
https://forum.thegamecreators.com/thread/222554
Over the past few days I have taken the AppGameKit Native Library and created Java bindings for it. This means that AppGameKit can now be used with Java (or even Kotlin), allowing users access to things such as OOP (Classes, Interfaces, Inheritance), JSwing, JavaFX, Java libraries, etc. However, I am wondering if there is any interest within the community for this? Since the Java Native Interface requires a shared library (DLL) I would have to get permission from TGC to release AppGameKit Java (like AGKSharp and AppGameKit for Python had to do). I am trying to gauge interest to see if it's worth speaking with TGC?
Below is the "MovingSprites" example code converted to AppGameKit for Java:
package agkjtest;
import com.thegamecreator.agk.AGKEntry;
import com.thegamecreator.agk.AGKLib;
/**
*
* @author Sean
*/
public class AGKEntryPoint implements AGKEntry {
private int mCanMove = 0;
private int mSprite = 0;
private float mOrgX = 0.0f;
private float mOrgY = 0.0f;
private float mDirX = 0.0f;
private float mDirY = 0.0f;
private float mDistFromAtoB = 0.0f;
@Override
public void begin() {
// set a virtual resolution of 320 x 480
AGKLib.SetVirtualResolution(320, 480);
AGKLib.CreateSprite(AGKLib.LoadImage(toAGKPath("background4.jpg")));
mSprite = AGKLib.CreateSprite(AGKLib.LoadImage(toAGKPath("lime.png")));
}
@Override
public void loop() {
AGKLib.Print("Touch or click the screen to move the");
AGKLib.Print("sprite to that location");
if (AGKLib.GetPointerReleased() != 0) {
float pX = AGKLib.GetPointerX();
float pY = AGKLib.GetPointerY();
if (mCanMove == 0) {
++mCanMove;
mOrgX = AGKLib.GetSpriteX(mSprite);
mOrgY = AGKLib.GetSpriteY(mSprite);
float distX = pX - mOrgX;
float distY = pY - mOrgY;
mDistFromAtoB = (float) Math.sqrt(Math.pow(distX, 2) + Math.pow(distY, 2));
if (mDistFromAtoB != 0.0f) {
mDirX = distX / mDistFromAtoB;
mDirY = distY / mDistFromAtoB;
}
}
}
if (mCanMove > 0) {
AGKLib.SetSpritePosition(mSprite, mOrgX + mDirX * mCanMove, mOrgY + mDirY * mCanMove);
if (mCanMove < mDistFromAtoB) {
mCanMove += 2;
} else {
mCanMove = 0;
}
}
AGKLib.Sync();
}
@Override
public void complete() {
}
private String toAGKPath(String fileName) {
String dir = System.getProperty("user.dir");
return "raw:" + dir + "\\media\\" + fileName;
}
}
Sean