adsGoogle Ads (aka AdMobs) is one of the most well known ad system used by developers to make some money with free apps/games. But other solutions exist and can be real alternatives.

I used to have some problems with revenues from Google Ads so i made some research and discovered App Flood.
The documentation on services proposed were clear and the “how-to” guide looked very clear and simple. So i decided to give a try to AppFlood in one of my LibGDX game.
After a quick registration on the web site to register my app and get my keys, i started implementing the API in my code. I was well surprised to see how much all is working out of the box and all the options proposed (banner, video ads, revenue on APK installation).
But how integrate an adsystem with a libgdx application?
Indeed with libgdx, the android application is just a wrapper to your main application in order to run it on android devices.
The adsystem should be plugged on the android layer through the application manifest
So first, add the required library in your android project:

  • Download somewhere the jar (as it will not be available on maven central repo)
  • and add the dependency:

Then following App flood doc, modify your AndroidManifest file:

The idea is to have a callback in your “core” code in order to call the ads system when you need to (for example screen transition).
So just create a simple interface for this in core module:

Modify your main application class to allow android application to registered the ad system:

Then implements this class in your Main android activity. Don’t forget to call the registering method on the main application.

Then whenever you decider you just have to call the method showAds() from your core code but dont forget to check if an ads system was registered otherwise you will get a NullPointerException

Sounds easy no?

Just finished to implement a new hostile arc vision detection for my monsters. The new algorithm is more realistic because it takes care of where the monster is looking and if there is no solid objects between him and the hostile. It is now possible to hide behind a wall and attack the monster on his back without being detected.

I used LibGDX intersect utilities and some angle computations.

aiFew weeks ago, i have done a post on how doing a smarter pathfinding for I.A. from results given by A*.

Someone asked me to show some code, so you will find below the method I use in my game. It is very rough but if you are a developer and you want to improve yourself on this subject, this will help you even if you can’t use it out of the box.

The method findPath() called in the first line is an A* implementation which gives a list of tiles index to reach the target modelized as a GridPoint2 objects. The “smarter” method returns a list of Vector2 objects which are real 2D coordinates in my world. Notice that the “area” parameter object passed to the method represent the surface of the sprite located at (x,y) which want to reach the target point (tx,ty). The area is relative to the position of the sprite. The parameter “collisionDetector” is an utility object which can check if the tile is solid or not (like a wall).

I just finished to implement a better version of path finding for my cthulhu game.

The basis is still based on A* but i add some additional steps to make the path used by hostile smoother and clever: I describe my enhancements in drawings below:

  1. The first drawing explain the real situation: you have one hostile located at point A. This hostile is modelized as a rectange (the collision area); The hostile need to reach point B behind a wall.
  2. The second drawing explains a path finding result using A*. A* is based on tiled so you will have a tiled vision of the path to used to reach point B. But remember, our hostile is a rectangle on a map with x,y coordinates and not integer tile indices.
  3. My first enhancement take A* tile path result and remove unecessary tiles (see third drawing) to keep only turn points.
  4. Then i do some additional process to compute real points (x,y coordinates) which takes care of hostile collision area and mnimizes the path regarding turn points.

The result in action:

Tiled map is a really good tool to create a classical 2D game. Everything already exists from editor to rendering. You just need to produce some tilesets, create a map with a tool like Tile map editor and with some few lines of code from libgdx, you have a 2D area game. You can find tons of tutorials explaining how to do this, including the official libgdx wiki.

Sadly nothing exists to render a fake perspective:BNyonmNCYAA6JYY if you put a wall tile on the map and use a sprite for a character behind the wall, the sprite will not be hidden because all tiles form the map are drawn before sprites.

After a discusion with @_TylerChurchill on twitter, I have implemented a solution using 2 different layers in my map, one for all the basic stuff (floor, walls, objects) and one for all elements that should hide all things drawn before – the “perspective”.

My standard map definition looks like the screenshot below:

ScreenShot149

I just added a new layer named “perspective”

ScreenShot151

And isolate all perspective elements in this layer:

ScreenShot150

In order to use this trick, I create a new TiledMapRenderer class from libgdx to ignore the “perspective” layer when the method #render() is called and add a new method to call to render it at the end of my drawing iteration process.

In my game initialization method,  I have initialized my new TileMapRenderer specifying that the layer to ignore is named “perspective”

In the rendering iteration process, i have called the #render() method from the map renderer, then i drew all sprites and then i have called the new #renderPerspective() method. Notice that you need to order all sprites using their “y” coordinates from the farest to the closest in order to keep a correct perspective for sprites.

The result: BOwerG0CEAAtsML

Like the post i did about tools i used, here the list of web sites which can help you to make a game. Some web site are talking about general development, not relative to any specific framework,  some are more relative to libgdx, and to finish some usefull links concerning graphics design:

Every developer has its own favorite tools but i think it’s always usefull to know what other people are using. Maybe someone will find the tool he was looking for since days. I found my pixel editor thanks to a post from an indy dev on twitter.
So here my list:
* IDEA intellij community edition : prefer the original comparing to android official IDE
* tortoise GIT because i prefer to have an external commit tool to manage images and other stuff not handled by IDE
* bitbucket free source code hosting. Some tools to manage the todo list
* inkscape to start graphic design before pixelize it
* pyxeledit the best pixel editor
* paint.net to edit image: simpler comparing to gimp
* libgdx to develop the game
* Tiled map editor to create map usable by libgdx
* BM Font to generate bitmap font
* as3sfxr for sounds

That’s all