Game Design Blog




Our guy is running around and picking up objects to use with his catapult. These are going to be various items but for now we will start with one generic type. We create a scattering of rocks on our game floor and each one is added to a list.

function game_spawn_rock(idname){
rock_mc = mcx.rocks_mc.attachMovie( idname, "rock_"+rocks_array.length, mcx.rocks_mc.getNextHighestDepth() );
rock_mc._y = gamevars.roadheight-rock_mc._height; //this places the rock flat on the ground
rock_mc._x = Math.round(Math.random()*900); //for now we place the rock in some random X position
rock_mc.spriteid = idname; //we save the clip ID so we can make a copy of it to carry later
rocks_array.push(rock_mc); //PUSH is a code way of saying add this to the end of my list.

Every game loop we run a function to check if the boy is in contact with a rock. This is done by looping through the entire list of rocks using the hitTest function to see if they are overlaping with the boy. If an overlap is detected the number of the rock is saved in a variable called boyvars.nearestrocknum.
If the boy overlaps more than one rock only the last one is stored as this will be the last one to be saved into boyvars.nearestrocknum.
Before we start boyvars.nearestrocknum is set to -1 which we will use to indicate there is no rock nearby.

If the boy is already carrying a rock then we cannot pickup another. Any rock being carried is stored in the variable boyvars.rock.
We check to see if this is empty before looking for rocks that can be picked up.

function game_loop_check_rocks(){
//check if we are carrying a rock
if (boyvars.rock==null){
//check for rocks
boyvars.nearestrocknum = -1;//reset to none before we start
for (n=0;n< rocks_array.length;n++){
if (mcx.boy_mc.hitTest(rocks_array[n])){
boyvars.nearestrocknum = n;//we are standing on a rock save its number

When we pick up a rock, the rock on the ground is hidden (this is so we can easily show it again if dropped) and a copy of the rock is shown being carried by the boy. If we drop a rock the hidden original is moved to the new positon where we dropped it and shown again.
When we put a rock on the catapult its not coming back so only then do we delete the hidden rock on the ground.
The co-ordinate axis for most movieclips is in the upper left corner. The Y values start at zero and increase as they go downwards.
With this in mind we can place any size of rock exactly above our boy by placing it at a Y value equal to the negative of its height.

function game_boy_pickup(){
rock_mc = rocks_array[boyvars.nearestrocknum];

//set a pointer into the rocks list
boyvars.rock = boyvars.nearestrocknum;

//reset this value so we cannot pickup more rocks

//create a rock carry graphic
clip = mcx.boy_mc.rock_carry_mc.attachMovie(rock_mc.spriteid,"clip",1);
clip._y=-clip._height;//This puts the rock above the boy graphic as if he is carrying it


//hide original mc

This code will be updated so that different items have different weight values. This will be used when firing from the catapult but also may be used to make the boy run slower when carrying heavy items.


Latest Stuff
Behold My Mighty Steed

Behold My Mighty Steed

Steeds will be beheld. Verily.

Destroy Every Pie You Touch

Destroy Every Pie You Touch

The long lost episode of Weebl and Bob that, thanks to recent...

Russian Dancing Men ep.3

Russian Dancing Men ep.3

It's Summer in the USSR and the Russian Dancing Men are out on...

Latest Peepl's Stuff
Investiture of the edible

Investiture of the edible

Once upon a perfect peril...

Universithing: Pilot

Universithing: Pilot

So here it is! I'm starting Uni this September, and as...

Drugs, drugs, drugs!

Drugs, drugs, drugs!

A young boy faces the horrors of crack use through the smooth...

Weebl's Tweets

Hey @VidFestUK goers. For my panel how about I just do song requests? What you think?


RT @CBeebiesHQ: Do you love making things with your LO? CBeebies is looking for a fun creative family for a new TV pilot:


RT @cartoonhangover: We love it! RT @aburrows96: @cartoonhangover hope you like it! #fanartfridaych


Roll up, see what awesome stuff we have on offer!

Weebl's Stuff Retro Flight Bags!!

Weebl's Stuff Retro Flight Bags!! - £14.99