B4J Library SimpleGameEngine

Informatix

Expert
Licensed User
Longtime User
I added the sgeVehicle class and 9 steering behaviors in the new beta version. I also fixed an important bug.

Beta 0.9:
- I fixed an important bug with rotated and scaled actors;
- I added the sgeBehavior, sgeBehaviors and sgeVehicle classes;
- I added the Vehicle property to sgeActor;
- I added two demos ("cars" and "grandma and the zombies");
- I changed the default angle of OrientToPath for the FollowThisPath action;
- I added SegmentAndRect to sgeIntersections;
- sgePoint2D.Angle now returns the angle of the vector, which is more useful than the previous implementation of this function;
- I added Negate to sgePoint2D.
 

ilan

Expert
Licensed User
Longtime User

Sounds really interesting.

If i remeber correct @Erel said once that we can publish b4j apps to the mac store so SGE may be very useful if we want to create games for mac's.

I have already a very nice idea for what SGE may be useful.

Wil try to study it in the near future
 

Jaames

Active Member
Licensed User
Longtime User
Hi, i think that the "Interpolations" example is somehow broken after the latest B4J update.



Reserved word "Wait" by the new feature "Resumable Subs" is the problem I think. Or Am I totally wrong?
 

Informatix

Expert
Licensed User
Longtime User
I use B4J v5.0 and all works fine (I never release anything without re-testing all demos).
That looks like a problem with the syntactic analysis of B4J v5.50. Could you report it in the bug section of this forum?
 

ilan

Expert
Licensed User
Longtime User
Change the int "Wait" to something different
I think it is reserved to the resumeable subs.
 

ilan

Expert
Licensed User
Longtime User
Yes, but there's a big syntactic difference between "Wait For" and "Dim Const Wait As", so B4J should allow the use of Wait as a variable name (confusion is not possible with a "Wait for" command).

If it would be WaitFor without a space i would agree but since Wait is a seperate word i understand why you cannot use it like

Dim for as int
Dim do as int
Dim while as int
...
 

ilan

Expert
Licensed User
Longtime User
btw the ".Then" function that allow to add multiple actions is really awesome. does it also exist in libgdx? (i cant remember that i saw it there )

EDIT: i am trying your new examples right now and i am really impressed by them.
SGE looks really powerful. Good Job!
 

ilan

Expert
Licensed User
Longtime User
ok now i had a look at your zombie grandma example (and car example)
really awesome.

please correct me if i am wrong.
i see that you create SGE Actors so you intialize them and attach image to them and then you just update their location. similar how SpriteKit works.
so there is no rendering of each actor manually.

is it correct?
 

Informatix

Expert
Licensed User
Longtime User
All actors are rendered by this call: SGE.Root.Draw. Root is the main group, the root of the actors tree.
 

ilan

Expert
Licensed User
Longtime User
All actors are rendered by this call: SGE.Root.Draw. Root is the main group, the root of the actors tree.

ok its the same like in libgdx.

i could create a group add all actors to it and everytime i would call draw (or act) it will draw (act) only that group.

B4X:
    Dim sgeGr As sgeGroup
    sgeGr.Initialize(SGE.Root,"sgeGr")

EDIT: i just hope using .draw/ .act will not drop down the FPS like in libgdx. will need to test it
 

Informatix

Expert
Licensed User
Longtime User
i could create a group add all actors to it and everytime i would call draw (or act) it will draw (act) only that group.
Exactly. You can also move the whole group by a single change of the group coordinates, or apply effects only to this group, etc.

i just hope using .draw/ .act will not drop down the FPS like in libgdx.
libGDX does not really suffer from a performance drop when you use actors. In my Diktatour game, all visual objects are actors, including missiles, and it's a game where performance is critical due to the heavy computations and the great number of objects on screen at the same time.
Anyway, SGE is designed right from the start to render actors and groups, and there's no performance reason to not use them.
 

Informatix

Expert
Licensed User
Longtime User
The final version 1.0 has been released:
- I added the AutoReverse property to sgeAnimation;
- I added the sgeEffectDisplacementMap class;
- I changed the name of the COST constants in sgeNavigationGrid;
- I added AddDirectConnection and GetDirectConnection to sgeNavigationGrid;
- I added the support of staggered orientation to sgeTiledMap;
- I added the OptimizedRendering property to sgeTiledMap;
- I added two new demos: Pathfinding\DirectConnections and Effects\DisplacementMap;
- I added an example of staggered map to the TiledMap demo;
- I renamed the Wait constant in the Interpolations demo so it should work with B4j 5.50.

The Java source code is available against a donation of 10 euros or more.
 

EnriqueGonzalez

Expert
Licensed User
Longtime User
I am testing each of the examples, and both files in Behaviours folder fails.

Grandma
Error occurred on line: 228 (Main)

Cars
Error occurred on line: 114 (Main)

Thank you!

Edit:

PhysicsbodyEditorLoader also fails in line 121 (Main)
 
Last edited:

Jaames

Active Member
Licensed User
Longtime User
I am testing each of the examples, and both files in Behaviours folder fails.

Grandma
Error occurred on line: 228 (Main)

Cars
Error occurred on line: 114 (Main)

Thank you!

Edit:

PhysicsbodyEditorLoader also fails in line 121 (Main)

I tried it on b4j v 5.51, SGE v 1.0 and all above examples working fine here.

But small "bug" in the DirectConnections example, if I click on the "start" position example crashes.
B4X:
Loading 0% IMAGE "Level" level.png
Loading 50% GRID "NavigGrid" navigrid.txt
main._sge_render (java line: 202)
java.lang.NullPointerException
    at b4j.example.main._sge_render(main.java:202)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:90)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:77)
    at flm.b4j.simplegameengine.SGE$1.handle(SourceFile:134)
    at javafx.animation.AnimationTimer$AnimationTimerReceiver.lambda$handle$484(AnimationTimer.java:57)
    at java.security.AccessController.doPrivileged(Native Method)
    at javafx.animation.AnimationTimer$AnimationTimerReceiver.handle(AnimationTimer.java:56)
    at com.sun.scenario.animation.AbstractMasterTimer.timePulseImpl(AbstractMasterTimer.java:357)
    at com.sun.scenario.animation.AbstractMasterTimer$MainLoop.run(AbstractMasterTimer.java:267)
    at com.sun.javafx.tk.quantum.QuantumToolkit.pulse(QuantumToolkit.java:506)
    at com.sun.javafx.tk.quantum.QuantumToolkit.pulse(QuantumToolkit.java:490)
    at com.sun.javafx.tk.quantum.QuantumToolkit.lambda$runToolkit$404(QuantumToolkit.java:319)
    at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
    at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
    at com.sun.glass.ui.win.WinApplication.lambda$null$148(WinApplication.java:191)
    at java.lang.Thread.run(Thread.java:748)
 

EnriqueGonzalez

Expert
Licensed User
Longtime User
I tried it on b4j v 5.51, SGE v 1.0 and all above examples working fine here.

Me too.. i tried with 5.51 and SGE V1.0, at first it was failing, then i realized that i was running it in debug mode, tried on release and worked.

Thank you.
 

Informatix

Expert
Licensed User
Longtime User
I am testing each of the examples, and both files in Behaviours folder fails.

Grandma
Error occurred on line: 228 (Main)

Cars
Error occurred on line: 114 (Main)

Thank you!

Edit:

PhysicsbodyEditorLoader also fails in line 121 (Main)
I will fix these issues with the Debug mode in future releases. I probably forgot to add @RaiseSynchronousEvent somewhere.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…