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".
I grew-up playing Mario, Sonic, Contra, Mega Man, Double-Dragon, Battletoads, Metal Slug, Prince of Persia, Blackthorne and many many others, so yeah...
'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
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.
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!
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.
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.