Share My Creation Mobile Crush - Game with Source

My first LibGDX game! Normally I make in-house business apps. I also think we should see more source code in this forum so this is intended as an example.

https://play.google.com/store/apps/details?id=com.bluejaysystools.mobilecrush

This is a reimplementation of Andy McAdam's Orchard Crush so I could learn how to implement a LibGDX game including creating my own graphics, fonts, sounds and music without being distracted by game play design issues.

Many thanks to Andy McAdam for providing the source code for Orchard Crush. To study his code I started to refactor it into subroutines but I ended up rewriting virtually all of it and the end result is a completely new app with the same game logic (except for the auto double tap that I added).

In the spirit of the Andy's release you can get my source code from here:
https://www.dropbox.com/s/ri3v63dvxr58hy4/Mobile Crush - Public Src.zip?dl=0

I did some basic optimizations and tidied up the source code a fair bit to hopefully make it easier to understand as an example program for others. A simple game such as this does not get a lot of benefit from complex optimizations so these were left out so the code remained easy to read.

Many thanks to Informatix for his 'Introduction to the libGDX library' and the LibGDX port. This was especially useful not only for LibGDX but also for references to other tools that are needed to create the game assets.

This example does not use a lot of LibGDX functions and it compiles with LibGDX_lite just fine. I am currently using it as a test bed to explore more advanced libGDX functions like texture atlas, polygonspritebatch, scene2D and TiledMaps.

Known Limitations:

  • it assumes constant fps so the game will slow down if the phone is doing something on the background.
  • aspect ratio is not quite right.

Some Things I Learned:
  1. debugging and finetuning screen positions is a pain. The debugger does not work because LibGDX runs in its own thread and there is no screen designer.
  2. mixing games logic in with drawing is different to my normal practice of keeping GUI and program logic separate
  3. you have to be careful to make game objects that are easy to distinguish from each other and the background
  4. a lot of the free stuff on the web is only free for non-commercial use
  5. making music loops is tricky - it needs to be bland enough to loop but interesting enough to not be annoying. I used my old Magix Musicmaker 15 to mix some loops with limited success.
  6. LibGDX makes a lot of things easy. The games scales well across devices from Galaxy S to Galaxy Tab II and Note 4. It even works on a Google emulator (using x86 accelerator).

Bluejay
 

Attachments

  • GameScreen_small.png
    GameScreen_small.png
    136.9 KB · Views: 3,630

dexMilano

Active Member
Licensed User
Longtime User
Ok I tested it.
Installed LibGDX
Compilation without errors but if I compile against the emulator B4A goes in timeout and cannot release the app in the emulator.
Am I missing something?

However again thanks
 

bluejay

Active Member
Licensed User
Longtime User
Ok I tested it.
Installed LibGDX
Compilation without errors but if I compile against the emulator B4A goes in timeout and cannot release the app in the emulator.
Am I missing something?

However again thanks

Does the app start? Is the emulator set to use OpenGL from the host PC?

I have seen the emulator crash after many test installs so there may be a memory leak issue. The emulator does not have much memory.
 

bluejay

Active Member
Licensed User
Longtime User
Hi wonder, glad you like the music.
I did not like any of the ones on the web so I made my own.
You can probably tell which of the two music loops I did first.
 

bluejay

Active Member
Licensed User
Longtime User
Hi dexMilano,
I have left the one game running in the emulator for three hours while connected to Android Device Monitor (see the tools folder in the sdk) and have been unable to detect any memory leaks in heap memory.

I did see the potential for an extremely rare crash so I have updated the source code with one if statement prevent that. This would not have anything to do with your emulator issue.
 

bluejay

Active Member
Licensed User
Longtime User
I own an ancient copy of Magix Music Maker 15. It came with lots of sample loops so I dusted the program off and loaded about 15 trance samples onto 5 tracks then played with fades and audio effects to make different tracks dominant at different times for variation and to create a seamless blend for the looping.

The advantage with Magix is that they have already selected sets of loops that go together well. I have never tried FL Studio.

BTW - Andy McAdam deserves the credit for most of ideas for the fancy animations. I tried to replace them with my own but they weren't as good so I tried to improve his eg make them smoother.
 

andymc

Well-Known Member
Licensed User
Longtime User
Hi! I just tried this game! I like the options menu you've added, and the time out to automatically pop tiles after selecting them.

thank you for using my code and including me in the credits. I made the animations in a rush so they could probably be improved quite easily. I was going to add a sort of "bounce" when the tiles drop down but never got round to it.
 

bluejay

Active Member
Licensed User
Longtime User
Hi! I just tried this game! I like the options menu you've added, and the time out to automatically pop tiles after selecting them.

thank you for using my code and including me in the credits. I made the animations in a rush so they could probably be improved quite easily. I was going to add a sort of "bounce" when the tiles drop down but never got round to it.

I rewote almost all the code so check out the source files - feedback is very welcome. I did make small changes to the animations to make them a bit smoother and code optimization to reduce the load on the garbage collector (especially on the main menu). Also blocked screen press briefly at game over to avoid accidental return to main menu - text only bobs when it will respond to a screen press. I did add some frame rate scaling but I thinking this is possibly not a good idea.

I did think of adding a bounce to the board drop down but never got round to it. :)
 
Top