Wednesday, 19 October 2011
game aspects
This is a screen shot of the game i am using for reference. I have come over a couple of problems during the make of my flash game. For example when to cars move from lane to lane the angle of the car view changes, this will be to difficult to do with out a 3D model. So I think I am going to make to game from a top view to make to game easier to make. Also I am going to make it 2D birds eye view to give it a retro feel. For the game I am going to make a scoring system go up during the time that you play, so the longer you last the more point you gain.
Thursday, 13 October 2011
Array in flash
import flash.display.MovieClip;
import flash.events.Event;
var blockArray:Array=new Array();
// create array called block array
for (var i:int = 0; i <15; i++){
// will loop cube 15 times
var cube:MovieClip = new box();
//brings in box from library
cube.x=Math.random()*550
//places cube from library along width of stage
cube.y=Math.random()*400
//places cube from library along hieght of stage
addChild(cube);
// duplicates cube from library
blockArray[i]=cube
// numbers the cubes
}
stage.addEventListener(Event.ENTER_FRAME, checkhit);
//listen to stage on every frame
function checkhit(myevent:Event):void{
for (var i:int = 0; i < 15; i++){
if (blockArray[i].hitTestPoint(mouseX,mouseY,true)){
// if any of the cubes get hit by the mouse in any direction (x,y) and if mouse hit whole object or reg point
blockArray[i].alpha=.3;
}// if box get hit make box transparent
}
}
import flash.events.Event;
var blockArray:Array=new Array();
// create array called block array
for (var i:int = 0; i <15; i++){
// will loop cube 15 times
var cube:MovieClip = new box();
//brings in box from library
cube.x=Math.random()*550
//places cube from library along width of stage
cube.y=Math.random()*400
//places cube from library along hieght of stage
addChild(cube);
// duplicates cube from library
blockArray[i]=cube
// numbers the cubes
}
stage.addEventListener(Event.ENTER_FRAME, checkhit);
//listen to stage on every frame
function checkhit(myevent:Event):void{
for (var i:int = 0; i < 15; i++){
if (blockArray[i].hitTestPoint(mouseX,mouseY,true)){
// if any of the cubes get hit by the mouse in any direction (x,y) and if mouse hit whole object or reg point
blockArray[i].alpha=.3;
}// if box get hit make box transparent
}
}
hit test
stage.addEventListener(Event.ENTER_FRAME, checkhit);
//listen to 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 any direction (x,y) and if mouse hit whole object or reg point
cube2.alpha=.3;
}// if box get hit make box transparent
}
//listen to 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 any direction (x,y) and if mouse hit whole object or reg point
cube2.alpha=.3;
}// if box get hit make box transparent
}
Thursday, 6 October 2011
code demo 2 library placement
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 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;
}
}
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 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;
}
}
Subscribe to:
Comments (Atom)
