Hi guys,
I'm still slightly new to the actionscripting world, and for a project at college we have to recreate an existing game that has been made in game maker in actionscript.
So the tiling and movement etc are correct to some extent, but I have no idea how to start with the collision detection.
When the koala touches a TNT, the koala is meant to die and a movie clip is supposed to play and the koala falls off of the screen. I have some idea of how to do this using simpler methods, but not with classes and arrays etc.
Could anyone please give me some pointers or tips on where to start with this?
Here's a selection of the code so far:
import flash.events.Event;
const MAP_WIDTH = 16
const MAP_HEIGHT = 11
const TILE_WIDTH = 40
//-------
//Level 01 Setup
//0 is Blank, 1 is Walls, 5 is Koalas
//2 is Dynamite, 4 is Exit, 3 is Detonator
var origMap:Array = [
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
[1, 5, 2, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 2, 0, 1],
[1, 0, 1, 0, 1, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1],
[1, 0, 1, 0, 1, 4, 0, 0, 0, 2, 0, 1, 0, 1, 0, 1],
[1, 5, 1, 0, 1, 2, 1, 1, 1, 1, 0, 1, 0, 1, 0, 1],
[1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1],
[1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1],
[1, 5, 1, 3, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1],
[1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1],
[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
]
var map:Array; // used in the game play...
var displayMap:Array;
var koalas:Array = new Array(
var dynamites:Array = new Array();
var detonators:Array = new Array();
var exits:Array = new Array();
* TILE_WIDTH;
tile.visible = false;
addChild(tile);
tile.gotoAndStop(1);
switch (map[row][col]){
case 1: tile.gotoAndStop(2);
break;
case 2:
var myDynamite_mc

ynamite = new Dynamite();
myDynamite_mc.x = TILE_WIDTH / 2 + (col) * TILE_WIDTH;
myDynamite_mc.y = TILE_WIDTH / 2 + (row + 1) * TILE_WIDTH;
myDynamite_mc.visible = false;
myDynamite_mc.row = row;
myDynamite_mc.col = col;
addChild(myDynamite_mc);
dynamites.push(myDynamite_mc);
break;
case 3:
var myDetonator_mc

etonator = new Detonator();
myDetonator_mc.x = TILE_WIDTH / 2 + (col) * TILE_WIDTH;
myDetonator_mc.y = TILE_WIDTH / 2 + (row + 1) * TILE_WIDTH;
myDetonator_mc.visible = false;
myDetonator_mc.row = row;
myDetonator_mc.col = col;
addChild(myDetonator_mc);
detonators.push(myDetonator_mc);
break;
case 4:
var myExit_mc:Exit = new Exit();
myExit_mc.x = TILE_WIDTH / 2 + (col) * TILE_WIDTH;
myExit_mc.y = TILE_WIDTH / 2 + (row + 1) * TILE_WIDTH;
myExit_mc.visible = false;
myExit_mc.row = row;
myExit_mc.col = col;
addChild(myExit_mc);
exits.push(myExit_mc);
break;
case 5:
var myKoala_mc:Koala = new Koala();
myKoala_mc.addEventListener(Event.ENTER_FRAME, moveKoala);
myKoala_mc.x = TILE_WIDTH / 2 + (col) * TILE_WIDTH;
myKoala_mc.y = TILE_WIDTH / 2 + (row + 1) * TILE_WIDTH;
myKoala_mc.visible = false;
myKoala_mc.row = row;
myKoala_mc.col = col;
addChild(myKoala_mc);
koalas.push(myKoala_mc);
break;
}
}
}
}
function copyArray(copy:Array, original:Array){
/* copies the contents of original array into copy. Both arrays assumed to be 2D */
for (var row = 0; row < original.length; row++){
copy[row] = new Array()
for (var col = 0; col < original[row].length; col++){
copy[row][col] = original[row][col]
}
}
}
// other listeners==================
restart_btn.visible = false;
rescue_mc.visible = false;
splash_mc.start_btn.addEventListener(MouseEvent.CL ICK, startGame);
restart_btn.addEventListener(MouseEvent.CLICK, reStartGame);
stage.addEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler);
stage.addEventListener(KeyboardEvent.KEY_UP, keyUpHandler);
// Event Handlers===================
function startGame(m:MouseEvent){
DoOver();
splash_mc.visible = false;
for (var row = 0; row < MAP_HEIGHT; row++){
for (var col = 0; col < MAP_WIDTH; col++){
displayMap[row][col].visible = true;
}
}
for each (var bear in koalas){
bear.visible = true;
setChildIndex(bear, numChildren - 1);
}
for each (var TNT in dynamites){
TNT.visible = true;
setChildIndex(TNT, numChildren - 1);
}
for each (var DET in detonators){
DET.visible = true;
setChildIndex(DET, numChildren - 1);
}
for each (var EXIT in exits){
EXIT.visible = true;
setChildIndex(EXIT, numChildren - 1);
}
restart_btn.visible = true;
rescue_mc.visible = true;
}