Archive for the ‘Examples’ Category

Pixel Collision Engine

|

Indeed yet another post even if i am getting spammed by work i am still down here. Lately i was playing with an idea to create a little tank destruction game you know the one there are tons of them out there already, anyway since i used my Genome2D engine i run into a little problem very soon. Lets take a simple destructible terrain for example, player shoots a missile which hits the terrain and makes a crater then another player shoots… you get the picture the terrain is going to be pretty much devastated the problem here is to create a collision with such terrain. Since Genome2D uses Box2D for collisions it would be really hard to represent the terrain as a polygon or polygon groups and update it according to destructions. First problem is the obvious complexity and as we delve even deeper to possible scenarios its getting worse such as concave polygons, polygon separation etc.

Seemed like a dead end and not really worth the effort so i discarded Box2D or any collision engine based on primitives and went back to the roots. To detect a collision between two bitmaps which is what we want basically even when they were represented as Box2D primitives is pretty easy after all flash has this neat function hitTest and i am not talking about the DisplayObject method but about the pixel perfect BitmapData method which works like a charm. So its over, done we can play.

Nope not that fast, to check for a collision is one thing, to get a worthy feedback from it is another entirely. Lets say we threw a grenade in our little terrain scenario, it will hit the terrain obviously and we will get a positive hitTest callback however thats hardly enough, there are couple of other things we would like to know but one that is crucial is the reflection vector so we can update the grenade and bounce it off the terrain. And this is exactly the difference between one line of hitTest code and quite lot of lines that make the Pixel Collision Engine i created.

So i’ve created a little demo since i am so happy with the state it is, i was also looking for similar engines/algorithms out there which i could benchmark with my PCE and i stumbled upon CDK which is pretty neat and i am glad i didn’t find it before i started because i would be tempted to just use it. It does simply the same thing however there are some major differences. The main is that CDK can work with any display object which is then internally processed as bitmap where PCE always works with bitmaps since that was the plan. If for some reason you want to work with display objects its up to you to create the bitmap representations where CDK does it for you. CDK returns angles upon hitting an object, PCE returns vectors…

As i went over CDK i stumbled upon some really strange stuff there and if some of you use CDK or maybe even the author if he is reading this drop me a line dude and i can point out a lot of optimalizations and changes if you are still working on it.

For stats i am using Mr Doob’s great simple Stats class you sure want to check out.

Anyway thats enough of small talk, here is a simple demo with 500 particles where you can switch between the engines using SPACE or even increase/decrease the number of particles using ARROWS. Click the image to run the demo.

PCE

EDIT: I’ve got an email stating that CDK offers more when it comes to collision and response such as overlapping and color exclusion. To clear this i need to mention that PCE also offers overlapping information in the collision response without such information the physics would be hardly possible. When it comes to color exclusion nope PCE doesn’t implement this feature simply because i didn’t need it at the time but its implementable with ease and whats more there will be no major impact on the performance.

PS: Why most people prefer emailing me rather than using the comments? This way its so sad here when it comes to comments numbers ;)

CoolIris widget using Agile3D

|

Hey, got bored today and created something, yep i keep surprising even myself. I am sure most of you are aware what CoolIris is, for those that don’t its a browser addon for image browsing, how eloquent :) Anyway i didn’t come up with the idea to recreate CoolIris just like that, i was actually working on a project where they wanted to have an image browsing similar as its done in CoolIris just little bit more complex, so using Flash 10 3D capabilities i created it. Didn’t use Agile3D in that project since its still not ready for production, but now some time later i was wondering about the performacne difference about Agile3D and direct Flash implementation in this exact scenario. Surprise Agile3D is way faster. :)

Thats all for now, its 6am and i need to get some sleep after all. Any comments/questions are welcome.

View demo: DEMO

Introducing Genome2D

|

Genome2D screen

Hi there again, these last 2 months were really dragging, too much work. Anyway its time to present one of my other projects that I found time to work on. Its a 2D engine for Flash game developers, atleast it should be once its finished.

The idea behind this project is kind of complicated, as some of you know i am semi-active in freeware game scene, and rapid Flash activist. Trying to bring more free developers to Flash scene, but i wasn’t too successful so far. The problem is that most people and programmers as well have this old image about Flash in their minds, you all know the concept, the terrible slow vector games, few click ad-games, and so on…

Since most budding developers are not hard-core programmers and use all kind of game developing tools instead of programming, so even if i was successful in showing them current abilities of Flash i still had no luck to actually persuade them to use such a complicated language as AS3. The few that were able to step up from various dev tools went to work in C# or Delphi instead.

Thats it, thats why i decided to meet the requirements somewhere in the middle, so the game developer doesn’t need to create any of the hard stuff himself but use Genome2D instead. It will do all the hard stuff so developer can focus on the game logic. Most of the engine so far is designed for top down action games, but it can be used pretty much during development of any 2D game.

It also implements a modified Box2D physics engine, which is an open source physics engine that can be found at http://www.box2d.org it really is a great engine so even if you are not interested in Genome2D but you just want to try out some physics give it a try. I said modified Box2D engine, even though there is an ActionScript version of the Box2D library it still has this C++ “sickness” of the original. That means it doesn’t really use ActionScript event model to its potential so i reprogrammed parts of the engine so it takes advantage of various events. I also added functionality as virtual Z height and position so that objects of different Z height/position doesn’t collide with each other, implemented concave triangulation, etc. Thats not really important here, anyway. ;)

Back to the main point, and that is demo of Genome2D in action. Keep in mind that this is really first, probably pre-alpha, version. Enjoy.

View demo: DEMO

The graphics used in the demo was created by me just so it looks better than simple shapes running around. :)
I am also aware of various optimizations that can be done, new features are on their way as well.

PS: For those that are more interested in 3D especially in Agile3D don’t worry I am still working on it.

Cover Flow Widget class

|

Hi, yesterday i bet that i can code cover flow effect in flash under 60 minutes, so i created this class just for fun. Its in Flash 10 and I decided to post the full source codes here for download, so anyone can enjoy it and use as they see fit just leave the authors info. It’s fully commented if there are some questions just ask or if you want some additional features and have problems I can look into it. I also made it fully customizable with public properties such as enable mirror, additional borders, various offsets and rotations etc…

One note, it uses TweenLite for tweening so download this great tweening class if you want to use this widget. It can be found at http://blog.greensock.com/tweenliteas3/ I had my own tween classes before but i decided after trying out various opensource ones out there to use TweenLite, first i don’t need to pack my tween classes to each one of my source codes, and second I can really appretiate great work if I see it. Check it out.

screenshot

Sourcodes: Cover Flow sourcecodes
Example: Cover Flow

Example can be navigated using arrows. The photos used are actually mine, they are from my trip to Geneva autosalon this March. Enjoy.

BTW i won the bet, this class was created from scratch in 50 minutes. ;)

Creating scene interactivity DEMO

|

Sorry for the delay, there were some major changes in my life and i didn’t have time to blog. The “bad” news is that i am no longer working for the company i worked for in last 3 years. We had some opinion differences about the company future, where i wanted to focus on application/framework/core development but it just wasn’t in the cards, however i am still staying as external collaborator. The “good” news is that i will have a lot more time for experimenting with flash. This was after all the major reason to leave the nine to five job, and focus on pushing the boundaries. If anyone has any interesting ideas, or wants a collaboration on some project drop me a line. :)

But back to the topic even though i really didn’t have time to work on Agile3D i am posting a demo on scene interactivity i created in january. Its simple, to interact with the textures just hold SHIFT.

View Demo: DEMO

First texture is a simple painter with a few tool options to experiment with, second texture is very simple video player just becouse this is probably the most used application within 3D in flash. The final texture loads external SWF, in this scenario its our old Flash 9 3D engine demo. The external swf uses stage position of the mouse for the rotation offsets, if someone really wanted to implement external swf as interactive texture its not a good idea to use stage property but rather use some kind of canvas. It doesn’t matter here, since the demo is just for fun :) Enjoy and keep tuned for the next demo, since this was never intended to be the final one.

Are there any examples of scene interactivity that you want to see?