Wednesday, 19 October 2011

Flash game design

My idea for a flash game revolves around a zombie survival. This involves the player's character(The Survivor) having to survive wave after wave of increasingly difficult zombies that continue to chase the Survivor around the stage. The Survivor has to evade the zombies by moving around the stage and killing them off by shooting them. There will be multiple zombies on the screen at once. I have yet to decide whether the punishment for coming in contact with a zombie will be instant death or just rapidly deplete a health bar. I am also deciding whether the game will allow you to acquire new and better weapons. Much of what I would like to add to the gameplay will depend upon the time it takes to create the more necessary parts of my game, as I would be learning lots of new coding that haven't been taught to me through demo's.

Thursday, 13 October 2011

Collision detection demo

stage.addEventListener(Event.ENTER_FRAME, checkhit);
//Listen to the stage on every frame

function checkhit(myevent:Event):void {

cube1.x+=3
cube2.x-=3

if (cube1.hitTestPoint(cube2.x,cube2.y,true)){
//If any of the cubes get hit by the mouse in it's x or y direction, true means the i from blockarray is following the cubes, so the cube that is hit by the mouse will cause the transparency(alpha) down.
cube2.alpha=.3;

}


}

Array scripting demo

var blockArray:Array=new Array();


for(var i:int = 0; i < 15; i++) {
//Will duplicate the cube 15 times
var cube:MovieClip = new Box();
//This is looking for a new box in the libary
cube.x=Math.random()*550
//This is loading new cubes randomly on the x axis
cube.y=Math.random()*400
//This is loading new cubes randomly on the y axis, this works alongside the x axis too
addChild(cube);
//This is bringing a duplicate of the cube from the libary onto the stage

blockArray[i]=cube;

}

stage.addEventListener(Event.ENTER_FRAME, checkhit);
//Listen to the stage on every frame
function checkhit(myevent:Event):void {
for (var i:int = 0; i < 15; i++) {
//Creates a loop to create blocks 15 times.
if (blockArray[i].hitTestPoint(mouseX,mouseY,true)){
//If any of the cubes get hit by the mouse in it's x or y direction, true means the i from blockarray is following the cubes, so the cube that is hit by the mouse will cause the transparency(alpha) down.
blockArray[i].alpha=.3;

}
}

}

Thursday, 6 October 2011

Scripting demo 2

import flash.events.Event;
import flash.events.KeyboardEvent;

var moveRight:Boolean = false
var moveLeft:Boolean = false
var moveUp:Boolean = false
var moveDown:Boolean = false

var ship:MovieClip = new Ship();


 ship.x=275
 ship.y=200




addChild(ship);

stage.addEventListener(Event.ENTER_FRAME,moveShip);

function moveShip(event:Event) {

if (moveRight==true) {
ship.x+=3;
}

if (moveLeft==true) {
ship.x-=3;
}

if (moveUp==true) {
ship.y-=3;
}

if (moveDown==true) {
ship.y+=3;
}

}

//listen to keyboard being pressed.
stage.addEventListener(KeyboardEvent.KEY_DOWN,pressKey);
stage.addEventListener(KeyboardEvent.KEY_UP,stopship);

//if not pressed set move ship to false
function stopship(myevent:KeyboardEvent):void{
moveLeft=false;
moveRight=false;
moveUp=false;
moveDown=false;

}

//if pressed set move ship to true.
function pressKey(myevent:KeyboardEvent):void{
if(myevent.keyCode==Keyboard.RIGHT){
moveRight=true;

}

if(myevent.keyCode==Keyboard.LEFT){
moveLeft=true;
}

if(myevent.keyCode==Keyboard.UP){
moveUp=true;
}

if(myevent.keyCode==Keyboard.DOWN){
moveDown=true;
}
}