Pages

Showing posts with label Actionscript. Show all posts
Showing posts with label Actionscript. Show all posts

Love Thy Gravity - Mini game

Challenged myself to make a small game in under 40 hours.

Came up with Love Thy Gravity in 30 hrs (non-continuous obviously)

You can play here - http://www.kongregate.com/games/MakubexFox/love-thy-gravity/















Let me know if 30 hours was too much or well used O_o

Lesson learned: Level Design is really-amazingly-brain-fuckingly hard. Number of levels dropped from 20 to 12 X_x

Flash 10 to 11 Issue

Well I got my pinball game to work in Flash player 11. \m/

The issue was I had set "mask" property on the root graphic.. well this wasn't an issue in 10.1

Fix is to -
1. Create a child
2. Make the child draw the mask-graphic
3. Set this child element as mask

Btw, Flash Develop 4 looks uber cool O_o

Tags: Flash Player 11, Bitmap, Mask, Redraw, Region, Bug, Issue

Applying Material in Away3D

I wanted to know Away3D basics first, before getting my hands dirty with Broomstick. So, currently I'm using version 3.6.

I looked at the Ferrari sample, and i replicated it - all seemed fine.
But when I created my own model - I wasn't able to apply material in Away3D.

Funny thing - a lot of people seem to have the same issue and no results have been posted yet. So after Google(Nasdaq GOOG.. lol.. that outta belittle you) finished playing cruel tricks on me, I was finally able to figure out the issue on my own.

Step 1: Modelling
Create the 3D Model and Unwrap UV
Go to Material Editor - Select a material and set a name for it - This is very important!
Apply this material and export it as a 3DS Model

Note: I'm using some old 3DS Max 2008 trial version that I got in a DVD along with some boring useless book, so a lot of things may be different or changed. And yeah, the new Blender is apparently awesome - gotta try it.


Step 2:
In Away3D, get the mesh ready and do the following

// Load the model, use load or parse - me use parse
// Gift me a server or shut up
myMesh =  Max3DS.parse( /* Embedded Resource */);


// Apply the material
// Note: The name "SKIN" is same as the one we set before
myMesh .materialLibrary.getMaterial("SKIN").material = Cast.material(/* Embedded Texture*/);


Just an FYI how I found this -
I opened the binary 3ds file in notepad++ and found only few things that were human readable - model name, material name and texture filename. So, yeah, it was a brute force attack.

NTFS: Prefer NOT to apply "texture or image" before export - will give resource not found run time error


Pinball Box2D Prototype

This has been due for quite a while now - another reason I should never consider "project management."

But in my defense:
We won the World-Cup. So spent a lot of days being "high"
IPL going on (ah c'mon.. cheerleaders)
Guess who saw 3 seasons of Clone Wars? Muhaha \m/

Ok so I wanted to learn how to use a "Physics Engine" in a game. I narrowed down to Box2D.
I wanted to make something new, so I thought how about a Pinball game! Well.. apparently people have already tried that.. so.. boo hoo.

I actually ran into some trouble, expected - considering this was the first time I used it. I didn't how to rig up the "Flipper" system. Then I came across this post. So that was the moment of "Boo hoo" i told above, people already "Been there, coded that"

The Game: (Requires Flash Player.. duh)
[Its 1 MB, wait till it loads]

Link

Instructions:
Use LEFT and RIGHT Arrow Keys
P to Pause
SPACE or CLICK in the first screen

Known Bugs:
Flipper collision fails sometimes, probably due to drop in frame rates (Box2D requires constant time step)

Things to keep in mind:
When using b2RevoluteJointDef, do NOT set mass to zero and enable limit and motor.
Velocity and Position Iterations have little effect, they didn't seem to fix the flipper issue.

Note: It's doesn't work with with Flash Player 11

Flixel Test 01 - Contra Style!

I had last Friday off ( sssshhhh.. I was sick \m/ ) so started testing out Flixel Engine.


Here's a video of what I did.
PS: Frame jerks are because of the screen-grabbing. It actually runs pretty smooth @ 60 FPS.


Sprite Credits - Original creators @ Konami, then guys @ nesmaps.com and nes-snes-sprites.com for ripping em.


My first take on the engine and it's flexibility:
Pretty cool features - I didn't have to write too much code for this. It took me just 3 days to rig this whole thing up. All i had to do was create 3 classes. I must admit, there are not many "valuable" tuts around that give you an insight, but the EZPlatformer demo did pave the way. But to be noted -  I spent around 2 days for my classes itself (player state management and collision detection) and around 4 hrs to get the hang of flixel itself.


The feature I loved the most was "follow". You can ask the camera to follow a Sprite (in this case my "Player"  that extends from FlxSprite).


The part what I didn't like - so little info about FlxTilemap. It seems to have so many methods for me to use - but couldn't get anything working. It may be simple for off-the-shelf platformer but this was a little different. I didn't want collision from all the tiles, and I wanted different behavior when collision occurred across Land, water, etc and I wanted the fall-through.


So finally I decided to use my own Collision detection. Was it easy? Piece of cake  - at least for this. Everything worked with just AABB systems.


Here's how I went about it -


Iteration 1:
Decided to create rectangles with "Type" information from my previous editor. Went smooth. I got about 50-55 FPS. (around 300 rectangle-intersection tests per frame)


Iteration 2:
Since this is a side-scroller and same "Type" of tiles extend for a while, I thought I could reduce the count of rectangles by combining the neighbors. So 5 rects of same type next to each other become 1 rect with combined dimension (horizontal only). So the count reduced to 51 \m/ and I got around 55-60 FPS.


Iteration 3:
Why waste all tests when only part of the screen was visible? (Yeah yeah.. octree and quadtree concepts). I created a "Shell" class that encapsulates the rectangles. I set a threshold like 10 - so it will create 6 partitions to hold these 51 rects split by their X co-ordinates. (yeah.. very simple one to start off with). If the outer-shell collides then it checks those inner rects for collision. Some logging revealed an average of 10-20 collision tests (reduced from 51). 
[Best Case: When player is in the air - 51 tests reduced to just 6]


However FPS remained the same - around 60. Not much of an improvement -optimization outcome reduces exponentially x_X




Too much text, I'll stop. Hope to post my Player state management soon. It was more fun than this ( pinky promise ).


But here's something to ponder ( always makes me go WTF ) - The original Contra by Konami was written (probably) in Assembly Language and optimized for 8-Bit machines and the game play was still out of this world \m/