Games [Project] Kingdom Crisis (KZ Engine)

wonder

Expert
Licensed User
Longtime User
New version is out: faster, more accurate and more responsive! New video on the first post. :)
 

wonder

Expert
Licensed User
Longtime User
Well, a game engine can only be showcased by showing a "game" running on it. :)

Note that the "game" itself is no game at all, at least in my point of view.

Since there are no winning conditions, clear rules or established relationships between individual elements, what you see in the video is just something that looks, plays and feels like a videogame, hence the designation "Tech Demo".

So, do you want to give it a test drive? :D
 

wonder

Expert
Licensed User
Longtime User
you must have good knowledge of (platform) games
I grew-up playing Mario, Sonic, Contra, Mega Man, Double-Dragon, Battletoads, Metal Slug, Prince of Persia, Blackthorne and many many others, so yeah... :D
 

wonder

Expert
Licensed User
Longtime User
Here's the new AI:


B4X:
'Determines enemy movement (@Return: isWalking)
Sub Enemy_AI As Boolean
    ...
    ...
    ...

    'Cache results
        Dim cannotDropFrwd = CannotDrop( directionX) As Boolean
        Dim cannotDropBack = CannotDrop(-directionX) As Boolean

    'Set conditions
        Dim condition1 = (isOnTheMapEdgeX                                                     ) As Boolean
        Dim condition2 = (isBlockedX(directionX)     And hCollision                           ) As Boolean
        Dim condition3 = (isDrop(directionX)         And cannotDropFrwd                       ) As Boolean
        Dim condition4 = (isStandingOnASingleBlock   And cannotDropBack   And cannotDropFrwd  ) As Boolean
        Dim condition5 = (isBlockedX(-directionX)    And cannotDropFrwd                       ) As Boolean    

    'Test conditions
        If condition1 Or condition2 Or condition3 Or condition4 Or condition5 Then    
            If condition2 And Climb(directionX) Then
                walking = True
                Return walking
'<------------------------------------ Return point ------------------------------------>
            End If

            velocity_x = 0    
            If condition4 Or condition5 Then
                AlignToMapX
                walking = False        
                Return walking
'<------------------------------------ Return point ------------------------------------>
            End If
            facingLeft = (facingLeft == False) '<-- Turn around
        End If

    'Make it walk
        velocity_x = math.clamp4(velocity_x + (accel_x * getDirectionX), -vmax_x, vmax_x)
        walking = True
        Return walking
'<------------------------------------ Return point ------------------------------------>
End Sub
 
Last edited:

wonder

Expert
Licensed User
Longtime User
Version 0.0.43a is out!
- Compiled with LibGDX v1.12
- AI improvements and bugfixes
- SaveWorld is now called asynchronously
- Now supporting ARMv8-A (64bit) devices (thanks @Informatix!!)
- My development board is now live: https://trello.com/b/mXEBQff3/kz2d

@John H. Guillory, please try this version. Your issue should be solved.
 
Last edited:

wonder

Expert
Licensed User
Longtime User
kanban.PNG

Live @ https://trello.com/b/mXEBQff3/kz2d

After 3 weeks of code refactoring, I'm finally back from the catacombs! :D

Let's have a look at what was done:
- Memory consumption reduced by 90%
- Faster game logic and rendering cycle

old.PNG
new.PNG

Before and After refactoring...

Version 49a should be out soon, please report any crashes or wired weird behavior... :)
 
Last edited:

Cableguy

Expert
Licensed User
Longtime User
You got it wired? That's weird!
 

wonder

Expert
Licensed User
Longtime User
Can u explain how u get the java heap memory and native heap memory?
B4X:
myLabel.Text = _
    "Native Heap Memory : "     & Round2(lGdx.NativeHeap / 1024 / 1024, 2) & " MB" & CRLF & _
    "Java Heap Memory   : "     & Round2(lGdx.JavaHeap   / 1024 / 1014, 2) & " MB"
:)
 

ilan

Expert
Licensed User
Longtime User
Your cycle time is very impressive. I checked in my new game the time for the whole process including rendering and box2d world update (all physics) including all loops i make and i get about 3-5 ms per frame . It is still under 16 so i will get 60fps but still your cycle time is impressive. Good job!
 

wonder

Expert
Licensed User
Longtime User
...but still your cycle time is impressive. Good job!
Thank you so much!! The main cycle is really something that has to be carefully handcrafted. Here's some tips:
- No useless iterations, make use of the Continue and Exit statements inside your loops.
- Choose your loops wisely (For i = A To B, For i = B to A, Do While i, Do Until i, For Each). Every loop has its advantages and disadvantages.
- Choose your data collections wisely (Arrays, Lists or Maps). There's a time and a place for each one of them.
- Cache repeated function calls!!!!! (cachedValue = myMap.Get(key) for example)
- Avoid all nested loops, except the unavoidable ones.

Useful links:
- https://www.b4x.com/android/forum/threads/for-vs-while.70615/#content
- https://www.b4x.com/android/forum/threads/the-stupid-things-we-do.70611/
- https://www.b4x.com/android/forum/threads/type-class-or-module.72734/

I hope it helps... :)

PS: I forgot to mention, but remember to always follow an Object Oriented Programming line of coding. While it doesn't directly affect performance, it makes things a lot easier to deal with. Just be sure to make the right decision when it comes to choose between a Type, a Call or a Code Module.
 
Last edited:
Top