Giter VIP home page Giter VIP logo

cloudbomber's Introduction

YouTube Video

CloudBomber

A Chipmunk Pro autogeometry / Cocos2D 2.0 example project where you play as an grumpy storm cloud that shoots nuclear missiles at a bunch of happy boxes on a lovely rolling landscape. Trust me. It makes perfect sense!

Overview:

This is a Chipmunk Pro autogeometry demo project that is built on top of Cocos2D 2.0. The focus for this demo is to show how simple it can be to mix Chipmunk Pro’s autogeometry to implement deformable terrain with Cocos2D. It implements a single screen game that uses the same Cocos2D rendering code that renders the screen to generate the Chipmunk geometry. While very simple and easy, transfering pixels from the GPU to the CPU is a little slow. Performance is not a major focus of this demo over simplicity. However, the cost of regenerating all the geometry only takes a couple dozen milliseconds. This method would work perfect for generating static level geometry at runtime or an occasional terrain deformation such as in a Scorched Earth clone.

How it works:

Chipmunk Pro allows you to trace images (or procedural functions) to turn them into geometry. For Objective-C, it comes with a few handy wrapper classes that make this easy to do. The included class, ChipmunkGLRenderBufferSampler, sets up an offscreen OpenGL rendering buffer that is used as a bitmap image source. You can then simply call Cocos2D code while the sampler is bound and the pixels are copied into sampler and are ready to be marched (extracting the contours)!

While it’s somewhat expensive to transfer the pixels from OpenGL back to the CPU where Chipmunk can use them. This is too slow to perform every frame, but works perfectly fine at load time and works pretty good if you only need to change the terrain once in a while.

The holes in the terrain are cut by sprites drawn over it with a multiply blending mode. When composited together in the render texture, they multiply the destination alpha to 0 in their centers where they are transparent, and darken around the edges of the hole where they are opaque and black. It’s a pretty easy compositing trick to do. Then all you have to do is blit the render texture to the screen (or the sampler).

What’s included:

A number of handy utility classes you can use in your own code:

  • ChipmunkSprite: Automatically synchronize Chipmunk bodies to Cocos2D sprites.
  • ChipmunkDebugNode: An simple node for rendering Chipmunk collision shapes and constraints.
  • HMVectorNode: A node that provides immediate mode rendering of high quality, anti-aliased primitives. ChipmunkDebugNode is built on top of it.
  • ChipmunkGLRenderBufferSampler: ChipmunkBitmapSampler subclass that allows you to easily render GL content into a sampler and then extract geometry from it.
  • imageconvert/retinaconvert: Utility programs I’ve made and use that allow you to generate .png files from Photoshop source files without needing to re-export them by hand every time you build.

cloudbomber's People

Contributors

slembcke avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.