Archive for the 'games' Category

Pixel based destructible ground with Cocos2d

Micro Miners iOS game

OMG a giant worm! Micro Miners iOS game.

 

Worms, Lemmings, Micro Miners…

A pixel based destructible ground is the kind of engine used in many popular games such as early appstore hit iShoot by Ethan NicholasWorms, or Lemmings. And also, since the 15th of November 2012, in my new iOS game Micro Miners. I started Micro Miners two years ago, after testing an amazing class called CCMutableTexture that was crafted and shared by the not less amazing Lam Pham. “2 years ago” means the source code provided here is based on cocos2d v1, but not too difficult to adapt to v2, I guess.

For this article, I’ve created a Xcode v4.5 + Cocos2d v1.01 project with a basic destructible ground engine. This is intended to be very simple starting point if you want to make your own game base on destructible grounds. But in any case this is a ready to use destructible ground engine.

I also recorded a short video of the project in action on the iPhone simulator. A quick way to see if this article could be of any interest to you.

Source code : https://github.com/jpsarda/Pixel-based-destructible-ground-with-Cocos2d-iPhone

1) GitHub project and video demo

Watch carefully the video below, it shows exactly what you get when you download, compile and run the demo project provided on GitHub.

2) The performance bottleneck

The engine is based on the CCMutableTexture class. Basically, a CCMutableTexture maintains an array of pixels value representing the texture. You can then quickly access and modify the pixels in this array. But once you’re done with the modifications, you have to apply them. The internal pixel array is then drawn on the actual texture. This step is the performance bottleneck of the destructible ground engine. Knowing this, all must be done to minimize the surface of the CCMutableTexture we draw on, and the number of times we call apply on the CCMutableTexture.

3) Minimizing the surface of the CCMutableTextures

This is achieved in 2 steps

  1. 1 pixel on the texture will be rendered as a 2×2 square on the screen. In other words the displayed CCSprite associated to the texture is scaled by a factor of 2. The look is more pixelated but it’s still acceptable. For example, instead for applying our changes on a 320×480 texture, we will apply them on a 160×240 texture. This is 4 times less pixels to draw when we call apply on the CCMutableTexture.
  2. If we use full screen textures, each time we move our finger on the screen to dig the ground, the full screen CCMutableTexture is modified and we must call apply on it. That’s a pity because only a small part of the screen is affected by our finger. To prevent this, the ground is splited in zones. In the project provided, we’ve splited the ground in 4 stripes (from top to bottom). When we dig the ground, only the affected zones are redrawn (you can see the affected grounds colorized in red while digging).

Destructible ground, 1 zone affected

Finger digging in the middle of a ground zone, only 1 zone affected.

Destructible grouns, 2 zones affected

Finger digging at the border of 2 zones, 2 zones affected.

4) Minimizing the calls to apply

ccTouchesMoved, which is the method invoked when the user moves his finger on the screen, can be called at very high frequency. We can’t afford to call apply on the textures on every move. We solve this problem by introducing a minimum delay (0.5 seconds) to pass before taking into account a move of the finger. Illustrated with this peace of code in ccTouchesMoved :

if (now-lastDigTime>0.05f) {
    // determine affected zones ...
    // draw lines ...
    // apply changes ...
    lastDigTime=now;
}

Continue reading ‘Pixel based destructible ground with Cocos2d’

Recently released cocos2d games #2

Kingdom Rush

One of the best Tower Defense games ever. I played this game when it was first released for Flash, and I couldn’t stop playing until I finished it. The iPad version is as excellent as the Flash version.

 

League of Evil 2

The sequel of one of my all-time favorites games. When played on iCade it gets even better!

 

Sketchshare

Great application to share ideas with remote people. Not only this is a super polished application, but also they released as open source their custom color picker, and they made their sales figures public.

Art done with Sketchshare:

Recently released cocos2d games

There are many cocos2d games released each month. These are some of the recently released games that called my attention.

Sir Benfro’s Brilliant Balloon

A fantastical game.

Curio

A psychedelic  game.

Monster Wars

A great sequel of Legendary Wars

 

See more cocos2d games announcements on the cocos2d games forum

Numberlys: new iPhone App of the Week

Numberlys, a cocos2d based interactive book, is the new iPhone App of the Week. Congratulations Moonbot Studios.

Download:

More cocos2d apps posts: cocos2d games

Scramble With Friends: new Top #1 game

Scramble With Friends and Scramble With Friends Free, two cocos2d based games, are the new Top Paid #1, Top Free #1 and Top Grossing #3. Congratulations Zynga.

Download:
  • Scramble With Friends: $0.99
  • Scramble With Friends Free: $Free

More cocos2d games posts: cocos2d games

Disclaimer: Although I work for Zynga, this site is not affiliated with them.

Tiny Tower: iPhone Game of the Year

According to Apple, Tiny Tower (a cocos2d powered game) is the new iPhone Game of the Year!
Congratulations NimbleBit

  • Download Tiny Tower: $Free

Amazing Breaker and Ski On Neon: Top Paid #1 and Top Free #1 Apps

Amazing Breaker, a cocos2d game,  is the new Top Paid App #1. Congratulations Dekovir, Inc.!

Also, Flick Home Run! is Top Paid App #8.

In the Free chart there are 7 cocos2d apps in the Top 12, including Top Free #1 Ski On Neon.

Feed me Oil, the new #1 Top Paid iPhone App

Feed me Oil, a cocos2d for iPhone game, is the new #1 Top Paid iPhone App.

This is an excellent puzzle game with great graphics and  incredible physics. Highly recommended.

 

Top Grossing Apps and cocos2d

#1 and #2 US Top Grossing Apps are using cocos2d! :-) Congratulations Pocket Gems, Inc., the developer of both Tap Pet Hotel and Tap Zoo.

And Zombie Farm, another cocos2d game which was mentioned in previous posts, is the #12 US Top Grossing App.

It is worth noting that in the Top 12 Grossing Apps:

  • 11 are games
  • 10 are 2D games
  • 7 are Free apps ( using In App Purchases )
  • 4 are isometric games
  • 3 are using cocos2d :)

Download:

The cocos2d games for Mac are coming

cocos2d for Mac was introduced v0.99.5 (December 2010). Since then many cocos2d users ported their iOS game to Mac. These are some of the results:

Continue reading ‘The cocos2d games for Mac are coming’




Social Widgets powered by AB-WebLog.com.