Android Question Gameview / libGDX Help

wonder

Expert
Licensed User
Hi guys!!

I'll try to keep this as short and organized as possible.

My name's Bruno and I'm new to the forum, but I've been working with B4A for a while now.
This place has been a great resource for me, so first of all, many thanks to all of you for the tutorials and answers. You really helped me a lot. Also many thanks to Erel for creating such an amazing tool.



UPDATE:
===============================================

I DID IT!!!!! :D
I successfully ported the app from GameView to libGDX.
Please be so kind to test it and give me some feedback on performance results.
It works great on my Asus tablet and Xperia phone.
===============================================



About The Project:


I'm currently creating a fighting game / beat'em'up engine called "Bulldozer Engine".
My goal is to build games like Streets Of Rage, Final Fight or Street Fighter with great responsiveness and speed. I'm using Street Fighter 3 sprites and a hi-res 16-bit-era style background in order to stress test the app.



This is the main module:

B4X:
Sub Main_Engine_Cycle_Tick

    cycle_number = cycle_number + 1

    '================================================================

    If First_Cycle = True OR counter >= Ceil(cycle_fps/sprite_fps) AND cycle_fps <> 0 AND real_fps <> 0 Then
            
                    counter = 0            
            
                    start_calc_fps = DateTime.Now
            
                    Do Until active_actor = number_of_actors
            
                            Animation                
                                                
                            active_actor = active_actor + 1
                                                
                    Loop
            
                    If active_actor >= (number_of_actors - 1) Then
                        active_actor = 0
                    End If            
            
    End If

    '================================================================

    Scroll_Update

    Do Until active_actor = number_of_actors
        
                BG_Scroll_Test
        
                Actor_Orientation
        
                Body_Part_Location
        
                AI_Set_Destination
                        
                Player_Move
        
                AI_Move
        
                Check_Boxes
        
                Player_Colision_Detector
        
                AI_Colision_Detector
                                      
                AI_Interaction
        
                AtkStr_Control
        
                Display_LifeBars    

                active_actor = active_actor + 1
        
    Loop

    If active_actor > (number_of_actors - 1) Then active_actor = 0

    '================================================================

    If active_actor = 0 Then Bubble_Sort

    counter = counter + 1

    actors.Invalidate

    '================================================================

    If (cycle_number Mod 2 ) = 0 Then
        If cycle_number = 2 Then cycle_number = 0
        cycle_start = DateTime.Now
    Else
        cycle_end = DateTime.Now
    End If

    end_calc_fps = DateTime.Now

    '================================================================

    'Calculate Animation FPS
        timestamp = end_calc_fps - start_calc_fps

    'Calculate Engine FPS
        cycle_time = (cycle_end - cycle_start)
        cycle_fps = Abs(Round2((1/cycle_time*1000), 2))

    'Calculate Discrepancies
        fps_dif = (real_fps - target_fps)
        cycle_dif = (cycle_fps - game_speed)

    Auto_Adjust_FPS

    First_Cycle = False

End Sub


As you can see, I have the Animation Cycle separated from all the other modules, because I want the Animation to run at 24 FPS and the game engine to run at 60 Hz. These numbers are defined in Process_Globals:

B4X:
Sub Process_Globals
    
        'Engine Settings

            'ENGINE MODE OPTIONS
     
                Dim game_speed = 60 As Int              ' - Default: 60Hz
                Dim cycle_fps = game_speed As Float
                Dim target_fps = 24 As Int              ' - Desired FPS for optimal animation
                Dim sprite_fps = target_fps As Float    ' - Starting animation FPS

            (...)


At the end of the Main Cycle, I have a module called Auto-Adjust FPS which compensates the animation speed, in case the frame rate drops momentarily. This option can be set on or off with ease.



Now, my little big problem:

So far I'm even surprised with how much I've accomplished in only 4 weeks but yesterday I've encountered a big problem.

My (quite unfinished) game engine runs great on my ASUS tablet (ME173X) but runs very slow on all other devices that I've tested. I've uploaded reference videos for every device where I tested this app.

Even with all the modules disabled, leaving only the Animation, the engine still runs slow.

I guess the problem is that I'm using the lib GameView and for what I've been reading in other posts, I should be using libGDX because it operates directly with OpenGL.

If this is the case, I really need your guys help in order to "port" my app from GameView to libGDX.




DEBUG Videos:

ASUS ME173X:
Perfect Animation and Speed

Sony Xperia P: Slow

HTC One M7: Slow

Samsung Galaxy S3: Slow

PC Emulator Andy: Unplayable


Here's a link to the GameView version, so that you can test it yourselves.

Thanks in advance for the help! :)

PS: Note that the HTC One is far superior to my ASUS tablet and still it runs slow.
 
Last edited:

walterf25

Expert
Licensed User
Hi guys!!

I'll try to keep this as short and organized as possible.

My name's Bruno and I'm new to the forum, but I've been working with B4A for a while now.
This place has been a great resource for me, so first of all, many thanks to all of you for the tutorials and answers. You really helped me a lot. Also many thanks to Erel for creating such an amazing tool.



About The Project:


I'm currently creating a fighting game / beat'em'up engine called "Bulldozer Engine".
My goal is to build games like Streets Of Rage, Final Fight or Street Fighter with great responsiveness and speed. I'm using Street Fighter 3 sprites and a hi-res 16-bit-era style background in order to stress test the app.



This is the main module:

B4X:
Sub Main_Engine_Cycle_Tick

    cycle_number = cycle_number + 1

    '================================================================

    If First_Cycle = True OR counter >= Ceil(cycle_fps/sprite_fps) AND cycle_fps <> 0 AND real_fps <> 0 Then
             
                    counter = 0             
             
                    start_calc_fps = DateTime.Now
             
                    Do Until active_actor = number_of_actors
             
                            Animation                 
                                                 
                            active_actor = active_actor + 1
                                                 
                    Loop
             
                    If active_actor >= (number_of_actors - 1) Then
                        active_actor = 0
                    End If             
             
    End If

    '================================================================ 

    Scroll_Update

    Do Until active_actor = number_of_actors
         
                BG_Scroll_Test
         
                Actor_Orientation
         
                Body_Part_Location
         
                AI_Set_Destination
                         
                Player_Move
         
                AI_Move
         
                Check_Boxes
         
                Player_Colision_Detector
         
                AI_Colision_Detector
                                       
                AI_Interaction
         
                AtkStr_Control
         
                Display_LifeBars     

                active_actor = active_actor + 1
         
    Loop

    If active_actor > (number_of_actors - 1) Then active_actor = 0

    '================================================================

    If active_actor = 0 Then Bubble_Sort

    counter = counter + 1

    actors.Invalidate

    '================================================================

    If (cycle_number Mod 2 ) = 0 Then
        If cycle_number = 2 Then cycle_number = 0
        cycle_start = DateTime.Now
    Else
        cycle_end = DateTime.Now
    End If

    end_calc_fps = DateTime.Now

    '================================================================

    'Calculate Animation FPS 
        timestamp = end_calc_fps - start_calc_fps

    'Calculate Engine FPS
        cycle_time = (cycle_end - cycle_start)
        cycle_fps = Abs(Round2((1/cycle_time*1000), 2))

    'Calculate Discrepancies 
        fps_dif = (real_fps - target_fps)
        cycle_dif = (cycle_fps - game_speed)

    Auto_Adjust_FPS
 
    First_Cycle = False

End Sub


As you can see, I have the Animation Cycle separated from all the other modules, because I want the Animation to run at 24 FPS and the game engine to run at 60 Hz. These numbers are defined in Process_Globals:

B4X:
Sub Process_Globals
     
        'Engine Settings
 
            'ENGINE MODE OPTIONS
      
                Dim game_speed = 60 As Int              ' - Default: 60Hz
                Dim cycle_fps = game_speed As Float
                Dim target_fps = 24 As Int              ' - Desired FPS for optimal animation
                Dim sprite_fps = target_fps As Float    ' - Starting animation FPS

            (...)


At the end of the Main Cycle, I have a module called Auto-Adjust FPS which compensates the animation speed, in case the frame rate drops momentarily. This option can be set on or off with ease.



Now, my little big problem:

So far I'm even surprised with how much I've accomplished in only 4 weeks but yesterday I've encountered a big problem.

My (quite unfinished) game engine runs great on my ASUS tablet (ME173X) but runs very slow on all other devices that I've tested. I've uploaded reference videos for every device where I tested this app.

Even with all the modules disabled, leaving only the Animation, the engine still runs slow.

I guess the problem is that I'm using the lib GameView and for what I've been reading in other posts, I should be using libGDX because it operates directly with OpenGL.

If this is the case, I really need your guys help in order to "port" my app from GameView to libGDX.




DEBUG Videos:

ASUS ME173X:
Perfect Animation and Speed

Sony Xperia P: Slow

HTC One M7: Slow

Samsung Galaxy S3: Slow

PC Emulator Andy: Unplayable


Here's a link to the app, so that you can test it yourselves.
http://www23.zippyshare.com/v/5998905/file.html

Thanks in advance for the help! :)

PS: Note that the HTC One is far superior to my ASUS tablet and still it runs slow.
Hi there, first of all let me start by saying, WOW!
this game looks very good, i've never used the gameview library and i wasn't aware you could even do things like this.
I've developed a game in libgdx, however is a different type of game, let me say that my experience with LibGDX was amazing, there was a lot that i had to learn, but once you start feeling comfortable and understanding the syntax it becomes very easy to work with it.
I would be interested in helping you port this game to libGDX, i'm a bit busy at the moment but am willing to help out as much as i can, just so that i can see this game working with LibGDX.

Let me know when and how you would like to start.

Cheers,
Walter
 
Upvote 0

wonder

Expert
Licensed User
Hello Walter and thanks for your quick reply!!

I'm really glad you like the engine so far!
I'd be happy if you give it a try and tell me how fast does it run in your device, the link is at the end of the first post.

Indeed I should have started this game with libGDX, it feels terrible to encounter such a roadblock at this stage in the development.
I'm kinda lost now, I'm not sure what to do. I need to know if there's a way I can fix the current code and why is this (slowness problem) happening.

I'd like to have the first playable prototype ready before Xmas, so if indeed it has to be ported to libGDX I will certainly appreciate your help! :)
 
Upvote 0

walterf25

Expert
Licensed User
Hello Walter and thanks for your quick reply!!

I'm really glad you like the engine so far!
I'd be happy if you give it a try and tell me how fast does it run in your device, the link is at the end of the first post.

Indeed I should have started this game with libGDX, it feels terrible to encounter such a roadblock at this stage in the development.
I'm kinda lost now, I'm not sure what to do. I need to know if there's a way I can fix the current code and why is this (slowness problem) happening.

I'd like to have the first playable prototype ready before Xmas, so if indeed it has to be ported to libGDX I will certainly appreciate your help! :)
I just tested it on my galaxy S4 and it works great, here's a link of a small video i made while running the app.

https://www.dropbox.com/s/ff3pnglshzw71tq/20141021_113314.mp4?dl=0
 
Upvote 0

wonder

Expert
Licensed User
Wow!! I'm glad to see it runs really fast!! Thanks for testing!!
Gameplay wise, how does it feel? The AI is a little bit dumbed down for test purposes.
My goal is to bring back the joy of the 16-bit SNES/SEGA era. :)


I want this engine to run on the highest number of devices possible.
What could be causing the speed differences?
Experts, share your thoughts.
 
Upvote 0

walterf25

Expert
Licensed User
Wow!! I'm glad to see it runs really fast!! Thanks for testing!!
Gameplay wise, how does it feel? The AI is a little bit dumbed down for test purposes.
My goal is to bring back the joy of the 16-bit SNES/SEGA era. :)


I want this engine to run on the highest number of devices possible.
What could be causing the speed differences?
Experts, share your thoughts.
I just tested on my Galaxy tab 3 and it runs real slow, i couldn't really tell you the reason for the speed differences as i have not used the gameview library, i'm sure Erel or someone else who has used this library would be able to shed some light, again this game will run real smooth in libGDX.
 
Upvote 0

wonder

Expert
Licensed User
Thanks Erel!! :)

I will install the GameView examples from your tutorials and see if there are performance differences between devices.

My question (and my fear) is, is it possible to port it to libGDX without restructuring the whole thing?

I guess I'll need the following libGDX equivalents to GameView:

  • Does libGDX also store the 2d sprites/bitmaps on a list?
GameView.BitmapsData as List​
  • Does libGDX also has a Source Rectangle for 2D sprites/bitmaps?
GameView.SrcRect.Left
GameView.SrcRect.Top
GameView.SrcRect.Right
GameView.SrcRect.Bottom​
  • Does libGDX also has a Destination Rectangle for 2D sprites/bitmaps?
GameView.DestRect.Left
GameView.DestRect.Top
GameView.DestRect.Right
GameView.DestRect.Bottom​
 
Upvote 0

bluejay

Active Member
Licensed User
What happens when you turn off the animated gif in the background? Do you still see a speed difference between devices?
 
Upvote 0

wonder

Expert
Licensed User
Hello Bluejay!

If I turn off the background, on some devices, I get a speed boost. I cannot however use that workaround to "save" my game.

I already convinced myself that I have to rewrite the code in order to use libGDX.
 
Upvote 0

inakigarm

Well-Known Member
Licensed User
Impressive !! In my chuwi v88 tablet (quadcore), until one enemy rests, the game speed is a bit slow; but with last enemy,everything goes too quickly !

I've seen some libgdx projects and i'm sure that you must learn about it from informatix posts and others; think the game speed would be more or less stable with a reasonable number of enemies
 
Upvote 0

wonder

Expert
Licensed User
UPDATE:
===============================================

I DID IT!!!!! :D
I successfully ported the app from GameView to libGDX.
Please be so kind to test it and give me some feedback on performance results.

It works great on my Asus tablet and Xperia phone.

===============================================
 
Upvote 0

mangojack

Well-Known Member
Licensed User
hi wonder .. not really my area of expertise .. (do I have any area of expertise ?? :confused:)

but seemed to run well on Samsung Tab4 SM-T530 Quad-Core 1.2Ghz KitKat 4.4.2

here's a debug video for you .. BullDozer.mp4 ..

for your info .. without recording the game , Realtime engine speed logging at 59-63.
whilst this is probably not your main concern at present ? I had to force stop the app numerous times . GameOver OK button non responsive.

Best of Luck.
 
Upvote 0

wonder

Expert
Licensed User
Hi Mangojack, thanks for testing!!

Indeed, there is a problem with "Game Over" event, it isn't working properly.
Other than that I'm happy to see that everything's working fine. :)

My biggest challenge was to port 6 weeks of work from GameView to libGDX, I'm glad everything went well.

Now back to the lab.
I'm hoping to have this engine more or less ready by December and who knows I'll be able to create a game in time for Xmas! :D
 
Last edited:
Upvote 0
Top