Dec 272011
 

I’ve been puzzling over the number of new users I’m seeing over the last few days. Some if it can be attributed to the Kindle Fire, but that still leaves a lot of unexplained new users. I’ve checked my stats across the various Android marketplaces, and they are all up.

Well, it looks like the answer might just be “It’s Christmas”. According to this article on TechCrunch, there were 6.8 million new Android and iOS device activations on Christmas day. 242 million apps were downloaded. They cite a post on Flurry’s blog, which has more detailed data.

And that’s probably the real explanation for what I’ve been seeing. Android phones and tablets given as Christmas presents all over the world, with users spread out across the various marketplaces that I have my games listed on. That would explain why I can’t find any specific trends in the new users, whether geographical, or marketplace-related.

I’m curious to know if other developers have seen similar end-of-December shifts in their stats. If you have some data to share, I’d love to see it.

Merry Christmas! :)

Dec 272011
 

If I use my game downloads as any indicator, the answer would be “A lot”. As I’d mentioned earlier, my daily downloads on the Amazon appstore went up around mid-November, which is when the Kindle Fire was released. But even then, it went from 0-2 downloads per day to 10-12 downloads per day – a big increase in relative terms, but still quite tiny in absolute terms. I was wondering how many Fires were going to get activated on Christmas. Well, here’s one indicator:

Continue reading »

Dec 252011
 

Here’s the ‘New Users’ chart for Bus Jumper since the initial release of the game (click on the image for a more detailed view):

Let’s look at the data from around October 15th. I released an update around that day, which explains the spike. I also published the game on 2 new markets, Appia and Mobango. Both of those are doing reasonably well, so the average daily new users has been higher since then. I released the last update on December 3rd, and that shows a spike too. However, the last couple of days have had pretty high downloads, and I have no idea what’s causing that.

Continue reading »

Dec 242011
 

Here’s the second half of the story – how to recycle dead bullets. I added a bullet cleanup system that checks for collisions with platforms, and for bullets that have gone past the visible edge of the world.

    @Override
    protected void process(Entity e) {
        BulletComponent bulletComponent = Components.getBulletComponent(e);
        if (!bulletComponent.active()) {
            return;
        }

        // If the bullet is touching a platform, deactivate
        PhysicsComponent physicsComponent = Components.getPhysicsComponent(e);
        if (PhysicsContactChecker.isTouching(physicsComponent, Label.Platform) != null) {
            Bullet bullet = bulletComponent.getBullet();
            bullet.deactivate();
            return;
        }
       
        // If the bullet is past the right edge of the screen, deactivate
        SpatialComponent spatialComponent = Components.getSpatialComponent(e);
        Vector2 position = spatialComponent.getPosition();
        float width = spatialComponent.getSpatial().getWidth();
        if (position.x - width / 2 > camera.position.x + camera.viewportWidth * camera.zoom / 2) {
            Bullet bullet = bulletComponent.getBullet();
            bullet.deactivate();
            return;
        }
    }

To make this work, I had to add some more data to the Bullet class. I spent quite some time this morning working on this and wondering why it wasn’t working. Once a bullet was deactivated, it appeared that it would never get activated again. I finally realized that it was activating, but then immediately deactivating. And the reason is the contact / collision data. I’m maintaining contact data in the physics component, outside of box2d. When I deactivate the box2d body, the contacts are deleted in the box2d world, but I wasn’t clearing out my own contact data. As a result, when I put the bullet back into the game, even though I’d moved it to a new position, it still had the old contact data from when it collided with the platform. So the collision code fired again, and the bullet got recycled immediately.

Once I figured that out, the fix was simple – when deactivating a bullet, clear the contact data in the associated physics component. This requires saving the physics component in the bullet. I might come back and re-think this at some point, it feels like there might be too much data shared between various classes. Anyway, here’s the new Bullet class:

public abstract class Bullet {

    protected BulletPool pool;
    protected boolean active;
    protected PhysicsComponent physicsComponent;
   
    public void activate(Vector2 position) {
        active = true;
       
        Body body = physicsComponent.getBody();
        body.setTransform(position, 0);
        body.setActive(true);
    }
   
    public void deactivate() {
        physicsComponent.getContact().clearAllContacts();
        Body body = physicsComponent.getBody();
        body.setTransform(-10, -10, 0);
        body.setActive(false);

        pool.free(this);
        active = false;
    }

    public boolean active() {
        return active;
    }
}

When deactivating, clear contacts, mark the body inactive, and move it out of the way. Activating the body does the inverse – mark it active, and place it where it needs to be. With this approach, I don’t really need to mark the renderable invisible – an inactive bullet will never be picked up by the camera.

This seems to work fairly well. I added a log to check the high water mark of my bullet pool. Even when I’m being obnoxious with the ‘fire’ key, it’s hard to cross 20-25 bullets. That should be a manageable number, both for Artemis and for box2d.

Dec 232011
 

I’m finally at the point where I had to tackle this problem, which can be briefly summarized as follows. Any game with a shooting mechanic needs to handle bullets, which are a large number of short-lived objects. The naive solution is to create a new bullet every time the player fires a weapon, and then forget about it when the bullet’s no longer ‘alive’. However, the Android garbage collector will punish you if you do that, and your game will experience large stalls every few seconds as it reclaims all that memory. You need to set up a pool of objects, and reuse them. Any Android developer who’s done a game with some kind of ‘bullet’ in it knows this. I dealt with this in Bus Jumper, where the falling objects are essentially bullets. But Neil Rajah presented some new challenges, which required a new solution.

Continue reading »

Dec 142011
 

Just got an email from Mobango that they’ve featured ‘Drippy the Raindrop’ as their game of the day. This is the first time any of my games has been featured by any app store (as far as I remember, anyway :) ) so I think this is pretty cool :) You can see the promotion on their Twitter feed and Facebook page:

Twitter

Facebook

It’ll be interesting to see what effect this has on the game’s downloads.