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;
}
}

Wednesday, 28 September 2011

Basic navigation coding

stage.addEventListener(KeyboardEvent.KEY_DOWN, moveship);

function moveship(myevent:KeyboardEvent):void {
if (myevent.keyCode==Keyboard.RIGHT){
ship.x+=5;
ship.rotation+=5
if (ship.rotation>=90){
ship.rotation=90;
//This is an example of coding that allowed me to rotate the ship alot more smoothly. The coding above is done so the ship will turn until it reaches 90 degrees and then stops turning so the ship can carry on moving right without rotating.
}

}
// These coding's below are variations of the coding above, but now for the other arrow keys and their rotation. These were part of experimentation. After the first coding of the RIGHT key was shown to us I decided to experiment with what I learnt to finish the rest of the directional keys. I attempted to have all directional rotations to rotate to their correct position and then stop but I could only get the RIGHT KEY to do this.

if (myevent.keyCode==Keyboard.LEFT) {
ship.x-=5;
ship.rotation-=5
if (ship.rotation>=270){
ship.rotation=270;

}

}

if (myevent.keyCode==Keyboard.DOWN) {
ship.y+=5;
ship.rotation-=5
if (ship.rotation>=180){
ship.rotation=180;
}
}

if (myevent.keyCode==Keyboard.UP) {
ship.y-=5;
ship.rotation=0;
}

}

stage.addEventListener(Event.ENTER_FRAME,bounds);

function bounds(event:Event) {
if (ship.x>=550) {
ship.x=0;
// This allowed me to set a boundry for the stage, so when the ship would pass outside the stage boundary's it would appear out the opposite side of the stage. 
}



}

Flash Games Research

Space invaders














Space Invaders is a retro arcade game


Madness Interactive
http://www.newgrounds.com/portal/view/118826


















Portal: Flash Version
http://www.newgrounds.com/portal/view/404612


This is a flash game of the popular console game Portal. The game still focuses on the main gameplay elements of the console game by using the portal gun to overcome puzzle rooms which become increasingly difficult as you progress.