TestFlight

Wew !

Today I made a great discovery : http://www.testflightapp.com/

This tool allows to upload and share builds as you develop your product, allowing testers and developers to share feedback and new versions.

Just perfect to get your stuff improved during your development, great job TestFlight !

Controls

After few friends tried the game, I’ve finally resolve to change controls.

I wanted to try a new gameplay, using the full screen to control the character’s moves, throwing and movable map elements.

It was definitely a mistake for a game like this one. Whether I like it or not, this is still a platform game with special actions, and a gamepad is the most suitable device to feel the game properly.

Well, I’d really to think differently but for now I’ll stick with this pad : the common solution for mobiles and tablets is to draw a virtual pad.

image

From the first tests, the player experience is definitely improved, and the tutorials are so easier to think of.

Here is the first presentation. Let’s start showing people what the game looks like so far and get feedback before the game is released.

Collision issues

Happy circle character

From this doc , “when a collision involves a circle, and if the collision result is returned in local-space, then the local-space position of the collision is always 0,0. This is a Box2D limitation.

My, animating a rounded character without legs nor arms is easier for sure, I didn’t expect to have problems with collisions…

Well, I don’t remember what was the need at that time, since now I have completely changed the way the player controls the character. So I don’t need to listen to these collisions anymore.

image

Tips and tricks

Memory

I had real troubles to set my PhysicsManagers and EffectsManager without memory leaks.

But now, following this guide, I have a great basis, clean

Optimization

I found out this doc to optimize the code. Really useful to improve memory management and what is encouraged or discouraged writing Lua.

For instance, I used to put ‘table.insert’ everywhere I would do an ‘array.push’ in javascript. I could read there it’s quite a mistake in Lua.

Foreground

The main problem pulling foreground tiles to front occured during the loop through the camera children.

Bringing them to front moved also their indexes, so after having pull one to front, it happened to appear later in the loop.

A simple trick as it often appears : just loop the children backward to avoid index issue

for i=camera.numChildren,1,-1 do
   if(camera[i].foreground) then
      camera[i]:toFront()
   end
end

Level Editor

Freshly baked Level Editor. 

Energies

CBEffects

As said before, I’ll use CBEffects. It’s an excellent particle system built by Caleb Place.

Thanks to this effects, I have quite good graphics on the playground and menus.

Using a particle system rather than sprites is far more beautiful, but far more greedy as well. So had to create an EffectManager, the guy who knows when to start an effect, when to hide it and when to destroy it. Basically when an effect “is on the screen” or “collides with” a stuff.

The tricky thing was to make effects follow movable stuffs, like throwable rocks and the moving character.

image

New design

I spent some time drawing a better scene.

Here is the new character, and the new blury animated background with mists and Moon ! (well for the moon you’ll see it next time on another screenshot I guess)

I’ve found out more resources, like these trees from Reiner’s Tilesets.

Actually, I didn’t expect to reach this quality, I’m really happy my game will finally look quite good.

Collisions and Trajectories

Context 

The character may throw a rock.

image

PreCollision

This rock way start from the character (x,y) and goes anywhere. 
So, there is a first collision between the character and the rock at the very start.

There are also collisions between energies and the rock : energies are only sensors, they must not collide with the rock and stop it.

To cancel the physics linked to the very first collision or with sensors, I must use Corona “preCollision" and ‘event.contact.isEnabled = false’

if(event.other == character.sprite or event.other.isSensor) then
     event.contact.isEnabled = false
end

Collision

Now I need the rock to collide to know when it’s crashed and to be removed from the playground.

Here, the collisions I’ve mentionned later will occur all the same. The pre-collision has just cancelled the “physics” to apply, but if I listen to collision, I will hear the character or a sensor collide with the rock.

So here again, I must check whether to accept or not the collision occuring

if(event.other ~= character.sprite and not event.other. isSensor) then
      effectsManager.off(event.target)
      display.remove(event.target)
end


Trajectory

Thanks to this tutorial, I can draw the trajectory of my rock. 

image

Physics

Awesome Corona’s physics

So easy nowadays to use simple physics in a 2D game. You’d probably be amazed to hear you can build an angry-bird like level to learn how to use physics as a tutorial.

Behind the scene  

The scene can be viewed as debug or even hybrid to debug collisions and moves easily during development.

image

The floor :

The floor allows to know  :

  • the relative speed to add or remove to the character’s move (movable tiles)
  • if a floor is dragged, then the character is to be dragged as well if he is on that floor

The floor is set when the character collides with a tile.
But then we must be sure this is really a floor and not a wall nor a roof, or yet another movable tile coming from a side, or yet again a “stuff” like an ennemy bullet or whatever else definitely not a floor.

Furthermore, a collision occurs when the character leaves the floor, so these first collisions must be ignored (checking character.vy)

if(event.other.y > event.target.y
and event.other.isFloor
and vy > -200) then
   floor = event.other
end