Jumat, 13 Agustus 2010

How to code a Beat em up

Some of you may remember a long time ago I did write a tutorial on beat em up's, but it was in AS2, and had a few major flaws I picked up on, therefore it was removed.
I figure now is the time to update those tutorials in AS3. This isn't going to be a straightforward making-from-scratch tutorial, rather a guide to the techniques involved. You'll have to do the grunt work yourself- no easy download FLA's for the lazybones here!
-------------------------------------------------
ADVANCED KEY-CAPTURE
-------------------------------------------------

Second only to a real fighting game such as Street Fighter 2, I can't imagine which type of game requires more pinpoint, tight arcade controls than a beat em up. Besides knowing exactly when a key is pressed, after we know what key has been pressed, we will also want to know when it was last pressed (in milliseconds), if it is being held down, and if so for how long.

//////////KEYS
var KEY_UP = Keyboard.UP;

var KEY_DOWN =Keyboard.DOWN;
var KEY_LEFT = Keyboard.LEFT;
var KEY_RIGHT = Keyboard.RIGHT;
var KEY_ATTACK = 87;
var KEY_JUMP = 81;
/////////////////////////////////////////////////////////////////////


First we need to set up some constant variables for the key-codes. As you can see, with the directional controls I'm just using the arrow keys therefore I can use the globals Keyboard.UP etc. KeyCode 87 = "W", KeyCode 81 = "Q".

var keys = new Object();
keys[KEY_UP]={down:false,count:0,held_down:false,timerA:200,timerB:0,timeElapsed:0};
keys[KEY_DOWN]={down:false,count:0,held_down:false, timerA:200,timerB:0,timeElapsed:0};

keys[KEY_LEFT] = {down:false, count:0, held_down:false, timerA:200,timerB:0,timeElapsed:0};

keys[KEY_RIGHT] = {down:false, count:0, held_down:false, timerA:200,timerB:0,timeElapsed:0};

keys[KEY_ATTACK] = {down:false, count:0, held_down:false, timerA:200,timerB:0,timeElapsed:0};

keys[KEY_JUMP] = {down:false, count:0, held_down:false, timerA:200,timerB:0,timeElapsed:0};

Next I've made an Object that contains information on all keys used.
down = Is the key being pressed?
count= How many times has the key listener detected this key being held down?
held_down= er..is actually being held down?
timerA and timer B are used for checking the length of time it's being held down.
timeElapsed= might or might now be useful till later.


stage.addEventListener (KeyboardEvent.KEY_DOWN, downKeys);
stage.addEventListener (KeyboardEvent.KEY_UP, upKeys);

Our keyListeners. What is a listener? Think of it as a function that never stops working until you tell it to. In other words, remove it.




function downKeys (ev:KeyboardEvent)
{
if (keys[ev.keyCode] != undefined)
{
keys[ev.keyCode].down = true;
keys[ev.keyCode].count++;
keys[ev.keyCode].timerA = getTimer() - keys[ev.keyCode].timerB;
keys[ev.keyCode].timerB = getTimer();
}
};

function upKeys (ev:KeyboardEvent)
{
if (keys[ev.keyCode] != undefined)
{
keys[ev.keyCode].down = false;
keys[ev.keyCode].count=0;
keys[ev.keyCode].held_down=false;
}
};

////////////////////////////////////////////////////////////////



downKeys listens for pressed keys, and upKeys listens for unpressed keys.
Okay so every listener triggers an event. Don't worry too much about what that means, anyway the ev:KeyboardEvent part means 'ev' equals the key that has been picked up by the listener. We can use it as a reference into our handy keys object.

if (keys[ev.keyCode] != undefined)

Only proceed if a key has been picked up by the listener.

keys[ev.keyCode].down = true;

This key has been pressed, so set down to true.

keys[ev.keyCode].count++;

Increment variable count- telling us how many times the listener has picked up this key being held. *NOTE* This doesn't work quite as simply as you might think, the AS3 Key Listener is a funny beast- to be explained later.

keys[ev.keyCode].timerA = getTimer() - keys[ev.keyCode].timerB;

getTimer() returns the number of seconds since the movie has been playing. TimerA is the now time. The old time - the timer value it gives us right now. Think about it, you'll get it!

keys[ev.keyCode].timerB = getTimer();
Set timerB, the then time.

So, now I can detect whether a key is being pressed with a line like:

if (keys[KEY_JUMP].down)
{
trace("JUMP has been pressed");
}

This replaces the old AS2 isKeyDown nicely. In fact, it's better isn't it? Not only can we check if the key is down, but we can also get more information about that key.

p.s.Don't forget your libraries at the top.:

import flash.events.KeyboardEvent;

import flash.events.Event;

Senin, 02 Agustus 2010

'INSANITY II' bidding on FGL

So the game is done, completed 100% and on Flash Game License now awaiting bids. I am in no rush at all to sell, in fact I've half a mind to pimp it out armed only with mochi or cpmstar ads.
I figure if 'THE INSANITY' hit over 1,000,000 players in a half year, that would effectively have gotten me about $1000 in ad revenue by now- and if I could be patient for a few years, that could dd up and add up, who knows? I'd have the cash the sponsors paid for it minus any legal obligation to put someones logo on my game. So we'll see, the only stress for me is the fans out there won't get to see the game till it's been through the bid wars. I'm still adding bits and pieces to the game while it's up there waiting for a pappa.
In the meantime, work starts on the next project. It's time for ACCCCCTTTTIIION! Yes, enough of these dour creepy-crawlie point'n'c*lickers EvilKris is breaking from tradition. Although keeping with the horror theme would make for sound business sense, I'd also like the kiddies to be able to play my games occasionally without their mum's going 'What the bleedin' hell you playing here?- that's bloody disgusting turn it off!'
So the next game will be using my Streets Of Rage Fighter Engine (rewritten in AS3) and will be a simple game kinda similar to the old classic MoonStone albeit shorter and much more hyper- paced. Essentially you'll have a map with about 50 random locations you can 'search', hit any spot and you'll have some enemies to fight and on winning you'll either get a weapon, something to give health recovery, or a hint as to where the final location you're looking for is.
I haven't quite decided on the theme yet but it'll probably be something with barbarians and goblins as I've been playing Oblivion lately. Had a dream I was working for Bethesda the other day.
Tell you what it feels damn nice to get off Insanity 2, summer is here, the babes are on the beach, and my own complication in life is figuring how to get the best suntan.

Senin, 26 Juli 2010

AS3 Splatterhouse..



After many requests for updates and AS3 conversations, I've finally taken the initiative to updating the tutorials to AS3. There's also a pretty good chance I'll add a couple more chapters to deal with multiple enemies and tile-based platforms.
There's a hefty transition between AS2 and AS3 and as such the tutorials will take some time to revamp, in the meantime if anybody is dying to see some basics laid out (movieclip with basic control and attacks), grab the - AS3 SPLATTERHOUSE CODE - here (full FLA)
ARROW KEYS- Move, W- Attack.
---------------------------------------------------
'THE INSANITY II' is more or less finished. I'm just waiting on some audio to come in and I'll be uploading it to FGL. Won't be long folks. Actually already cracking on with my next game believe it or not- a fully fledged Final-Fight type beat-em up with borrowings from Double Dragon, SpikeOut, and CrimeFighters. Haven't quite decided on a theme yet but the engine will be similar to my previous SORF engine (though updated to AS3) and it will be SHORT. No more shacking up for 7-8 months on one game. This one will be Dad'N'Me length.
Already got a character running around doing combo's maaaaan I'm getting to be a good coder these days, lol!
Now I've tried this before and failed, but I am looking for a good spriter. Anyone who is pretty talented- at either drawing fighting sprites from scratch or even say, just reworking old Capcom sprites so they're original- get in touch. Clear 40/60 deal on this one so there could be some major cash involved. If I can't find a good artist for this one I'm screwed, I *can* design characters in 3ds with motion capture but I'm not exactly Frank Frazetta when it comes to natural art talent.

Selasa, 01 Juni 2010

"INSANITY II"- on schedule!

Phew! After a ridiculously long gestation period of 7 months or so it seems like the second game is almost ready to launch. The game is playable from start to finish in it's current state, and all that's left to do is to drop in the audio (20% done already), draw up the ending cinematics, fix some dialogue weaknesses and beautify some of the weaker images. Then wham bam baby! she's good to go.
I'd say at the rate I'm working on it, bar ill health or an exploding computer the game should be on FGL for the sponsors to sniff around at by the end of July- possibly even the end of June. The whole project has been like a goddamn weight around the neck for this year and I truly hope someone appreciates the monumental effort I've put into making this the best Flash horror game ever. Personally I'm looking forward to the months after this, bumming around the humid, gorgeous Japanese beaches with a can of Asahi- before coding simpler games I can finish in 2-3 months max. Whacking the MochiAds on and watching my bank account saturate with passive income, that sort of thing. I know I'll never make the amount of $$$ I think 'The Insanity II' is actually worth, due to it being done in the Flash medium, but what the hell -no regrets, this has been for the most part a labour of love, and artistically speaking it should stand the taste of time in comparison to some other games out there. And who knows about future platforms? Maybe an Iphone version?
Although I can't release another alpha version of the game, you guys can rest assured 'THE INSANITY II' is far better than the first one in every way. Horror fans will not be disappointed. More updates coming soon.
p.s.I will also rewrite my SplatterHouse tutorials for AS3 when I have the time this summer.

Senin, 12 April 2010

Whew...

...down down..deeper down. Just finished another couple of sections of 'THE INSANITY II' and all I gotta say is, this is some scary sh*t coming out of my brain and onto the medium we all know and love called Flash here. Tell you what guys if you want to have cozy dreams don't sit on your computer alone drawing pics of half-eaten bodies with their intestines hanging out...
Anyway, I need a break so I thought I'd blog for a sec before I get out the guitar.


I don't suppose I'll ever spend as much time authoring any games as I have with the Insanity series. But will there be a trilogy? Maybe one day. But 6 months is really way too long to spend on making a game. What's the point? I definitely need to cut them shorter. With story-intensive games like this one there's really no choice but still...One worry I do have is fitting this all in under 5 mb. I can't see it happening what with all the audio that has to go in at the end, so there might be some restrictions in that capacity.

Anyway, 2011 will be my year for multiple game releases- you can bank on that.

I want to wrap this puppy up because I'm DYING to code a decent beat-em up. I've been doing *ahem* research? on MAME recently and some of the golden oldies, Crimefighters, Shadow of Mystara, Aliens vs Predator. Man, thems some good games and I'm bagging to get my imprint on the legacy of great fighting games.
I quit playing Tekken 6 because frankly the game isn't that much of a challenge, I think my Eddie is retired at around position 170 in the world so, can't complain. Back on MGO again with a level 14 girl character called 'THE INSANITY' (surprise). You wont find me on the UK servers but if you ever go on the Japanese ones feel free to friend me and we can clan up or something.
I've been checking out some of the new releases on PSN. Brink is looking exciting. Just, dammit, I wish they'd bring out Monster Hunter on the PS3. Even if I have to go through it all in Japanese again like I did on the PS2 I'd be game.

Kamis, 25 Maret 2010

INSANITY II next Alpha available








INSANITY II ALPHA.02 is good to go!


There's a wee bit more game there for your enjoyment. You can now see more of CHIMERA and solve another puzzle. I've been checking out screenies for the new Dead Space 2 and it's looking pretty good. Man, wish I could be working on a game like that.

Rabu, 24 Maret 2010

The Arnolfini Processor

Some people are complaining they don't understand how to solve this puzzle.



As you can see in the first pic (far left) this is a clue as to how to decipher the painting's secret clue.

'The Insanity II' is a more intellectual game than the first one. I'm aware that many people will struggle to figure out the puzzles which is why I'll include a walkthrough YouTube video with it's release (with money-making ad's on the page of course bwahahahaaaaa!)

For your information, the Arnolfini Portrait is a *real* picture by the way :-) And is historically known for having many hidden meanings- read about it out on Wikipedia

The demo will be updated shortly with a couple of extra sections. I'll let you guys know when it's out.