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
Spelunker : Savlonic

Spelunker : Savlonic

The newest song from Savlonic from their new album, Red. You...



Cat Face detects some ham in the area.

TomSka Behind Your Sofa

TomSka Behind Your Sofa

What on earth is that boy up to?

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

RT @JellyBugToons: New animation coming in the next few days.


RT @Kr3id: New vidya made with Eddache and Weebl should be out tomorrow. Check out the first two episodes of Russian Dancing...


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

Weebl's Stuff Retro Flight Bags!!

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