Make a Flash game like BoxHead – part 1

One of the most popular Flash games is BoxHead by Sean Cooper, that released the 5th game of the series called The Zombie Wars.

BoxHead

At the moment I am just giving a small prototype of the “hero” controlled with arrow keys and the “zombie” chasing the hero.

One of the interesting things about BoxHead is that all movements are based upon old 8-ways system… this means hero and zombies can walk only on 0, 45, 90, 135, 180, 225, 270 and 315 degrees.

So there is not so much trigonometry involved in it.

I will comment the code later, meanwhile if you have questions post them in the comments.

Download the source code and give me feedback

  • Wow! This is great, Ive always secretly wanted to make a game such as this.

  • David

    very useful, as always
    why didn’t you use the Math.sin(45) method instead of using 0.707? are there any advantages to using a decimal?

    Also, can you show us how to create and control multiple enemies? i.e. would we attach loads of zombie movies using the for() and then have each of them its own onEnterFrame = function(){} or is there another method?

  • the problem with these kinds of games is not making it, it is the huge amount of enemies.

  • Jack Hopkisn

    Dude. This is amazing!!!

  • I LOVE BoxHead… This is going to be the best tutorial series ever…

  • Flasher

    Bring on the Boxhead clones! Nice one.

  • Fairlyn

    the thing i’m really interested in is how you’re going to get enemies to go around obstacles.

    as for the original game; i played the the other ones way too much, this does not bode well for my productivity.

  • Me too. I need an IA…Thanks Emanuele.

  • And Mar

    @David

    Using .707 is faster than Math.sin(45) so it is better when you might be using it many times (e.g. many enemies?)

    @styxtwo

    I’m guessing that bitmap would be best for many enemies because its faster and you could manage them in a loop. cacheAsBitmap?

  • i need help!!

    Hey emanuele(or someone else who can help me)
    ive got a question can i make a hittest with two objects and then flash shows me cordinats where the two are hittesting?(i need this for a kind of gravity)

  • Excellent article – thanks.

  • Xodus

    I used 2 play this game all the time, the thing i really want to learn is how to create a certain number of zombies per lvl, like david said, maybe using a for() command with an attachmovieclip function?

  • @I need help!!!

    I can help you, email me:

    birdveiw @live.com

    (^take away the space)

    @Xodus

    I simply put it on the stage, the attach thing doesn’t work for me…But, we all have opinions, don’t we?

  • the game was awesome, and graphics were good.
    about the tut, i can’t wait for the next one to come… i think this will also give us the idea of how to create a isometric engine for RPG’s and adventure games.

  • very nice, i’ve always wanted to know how to make a game like this…thanks emanuele!

  • oh yeah, maybe make it a little faster with the next tut…

  • I was testing it out when I thought of something. If there are going to be lots of zombies, then the zombies should be slower, otherwise they are easily going to overpower the hero=(

  • i tried to do something where if the zombie hit the hero, then it attached a blood spurt movie clip and it had a delay so it only attached every 30 frames. It didn’t work for me, CAN SOMEONE HELP ME? Here was the code I used:
    //delay variable
    bloodDelay = 29;
    .
    .
    .
    //in zombie function at bottom
    if(this.hero.hitTest(_x, _y, true)){
    bloodDelay++;
    if(bloodDelay==30){
    bloodDelay = 0;
    _root.attachMovie(“blood”, “blood”, _root.getNextHighestDepth(),{_x:this._x, _y:this._y});
    }
    }

  • stebo

    Hey emanuele
    will you also create a tutorial for the splitscreen mode of boxhead series?? that would be really cool…..

  • Izy

    I can’t wait for the comments on this one.

    I’m trying to write my own version of this in AS3, and as always I’m running into problems with the angles.

    If I subtract 90 from the degrees version of the angle, the ranges get messed up and it’s no longer half negative, half positive.

    Did something change between AVM1 and AVM2?

  • Flasher

    Whoa! I’ve tracked down the terrain graphics. Not that difficult since there’s a credit in the game.

    http://lostgarden.com/2006/07/more-free-game-graphics.html

    The artist mentions a copyleft license. Cheers!

  • Izy

    Incidentally, lines 65 through 73 are brilliant,
    particularly line 69.

    I’ve seen a similar technique for getting integers out of a random number function, but I didn’t think to use something like to get a limited number of results to represent the angle range.

    Elegantly simple.

  • vsww

    nice work!

  • lailai

    @xavi-v
    no, the hero should move 3x faster

  • dude

    thats just hittest for that

  • Slasher145

    Great job emanuele, great tutorial. I intrigued to see the commented version, it’s always nice to learn.

  • Pingback: Managing isometric depths in Flash : Emanuele Feronato - italian geek and PROgrammer()

  • Carlos

    sorry guy, but BoxHead by Sean Cooper uses profissional programming, it uses AS3 and sean cooper in some classes work in byte and pixel level for the best optimization…you can’t show this in a simple tutorial.

  • Emanuele Feronato

    Of course I can’t show this, but I will show enough to make a decent clone

  • David

    When is the next part comming up? I really want to learn how to have 2 guns and change between them!

  • stevie

    wow awesome! who knows when the nxt part is out? oh and EMANUELE F please can you make a simpler platform game tutorial I gat stuck on the last one…PLEASE?

  • stevie

    EMANUELLE plese make a simple platform game Im stuck

  • The Urch

    Hey great tutorial its awesome.
    Can you make one where the hero can shoot and more zombies spawn. Or instead of guns you could have force powers and kill the zombies by pushing them into walls and such.
    Awesome tutorials anyway.

  • The Urch

    Another thing…
    Has anyone heard of the “game”(more of a simulator but you could consider it one) falling sands?
    If you haven’t go to http://www.fallingsands.com. If anyone knows how to program that it would be awesome.

    Keep programming . .
    /
    \___/

  • The Urch

    http://www.fallingsandsgame.com i meant
    Typing error sorry

  • The Urch

    no s after sand either

  • Shadowfyx

    im gunna sound like a rite idiot but how do u use the actionscript.
    im trying to use the tutorial to make a sort of Resident Evil 4 mercanaries game.
    ive downloaded an actionscript program
    now what?

  • Shadowfyx

    hi its me agind
    in fat what program would you recomend
    and what do you do with the source code cos i cant find anything that opens .fla files

  • RickHard

    Hi!
    I can’t make a simple HitTest, where if the zombie hit the hero, then gotoAndPlay(“win”);
    CAN YOU PLEASE HELP ME ASAP?
    Answer here in the forum, or e-mail me to breakinhabits@gmail.com
    Thank you so much

  • Joseph Donofry

    Very nice tutorial. I am currently working on (I actually just started) working on a BoxHead like game. My friend and I want to try to add online co-op and all kinds of fun things to it, but I have to make the framework first!

  • th

    hi uyz….all the code is great..
    but what program do u use to actualy insert it?
    i am a tottal noob..this is my fistgam thingy…so bear wit me…:)
    fanx..
    (email me)

  • Thomas D

    Would someone be able to make Boxhead zombie in java script so i can play at school on jcreater ^^

    this class is a blow off so i mess around but they are finding my game sites to fast so it would be greatly appriceated

  • Esquel

    Is there someone who can help me with making this game to a little shooter? I really need help, I suck at this!

    add me at msn : steventjeh@hotmail.com or mail me

    thank you!

  • Zac

    so am i right in thinking there is no part for this???

  • rhys

    what are you supposed to do on the grey box im trying to make a shooter what do i do

  • Pingback: Triqui’s Picks #1 : Emanuele Feronato()

  • Oliver

    Hi i’m trying to make a boxhead tribute game for a computer stdies assignment. Do you know where i can get a sprite sheet?

  • Oliver

    P.S. for those who haven’t ever made a game before gamemaker is a software you can download for free and it makes making games easy, in a matter of minuets i had a zombie that chases the player around walls, and thats the hard bit. Now all i have to do is devils and weapons. The only problem with gamemaker is getting it online.

  • Ricardo

    Hi. I like your tutorial; it’s very easy to follow and looks great. Will you be making part 2 shortly?

  • DannyDaNinja

    Ricardo, it’s now July 2010, I would love to see another part but after all these years, i doubt one will ever ome…

  • tbanims

    is there a second one?

  • AdmiralAP

    what game maker should i use to make this game?

  • AdmiralAP

    nevermind

  • D david

    can you do video tutorial plz

  • Velenda

    Thanks, but how to chosse the numbers of zombies in the map ?

  • Simon

    Hello Guys I’m new at this. How I put game so others can play? and I want to make 2 players can play it. Thanks!