DMF 203 game – final Project
Goals: This game will be a ‘first-person shooter’, of sorts. I’m behind on the lingo. Would the original ‘Asteroids’ be considered an ‘FPS’?. The terrean spaceship (in geosynchronous orbit), will be making shoot/don’t shoot decisions (no logic to these, by the way) and based upon the target hit, will score points, or have points deducted. Is that bifurcated object that is headed your way a Ctulhuian nursing bottle (they are important allies) - for their giant two-mouthed infants (which morph into 3 mouths after they lose their set of ‘eye teeth’) - or is it a miniaturized Maladrxirian binary fission weapon? Is that a Zoooooooooooooooooooordn ‘man-of-war’ craft, or a Shiiiishnian geriatric tour spacebus, coming to see the Grand Canyon and donate their earthling-compatible extra organs, which used to go into landfills on their home planet? Think fast! Or, “Feel the force”, or, “I haven’t even had my morning coffee yet; why do they have me manning the plasma cannon on this rust-bucket when I haven’t had the minimum required refresher simulation training in over ten months?”
The ‘bogies’ will be starting at the top of the screen, and descending towards the bottom of the screen, where the patrol ship moves from left-to-right horizontally, based on mouse movement. Clicking the mouse shoots projectiles, which travel in a straight line, after they are fired. This is not intended to be a friendly/logical/satisfying game. Think ‘Sartre Pac-man’. Or Buddha, for that matter (Life is suffering…). This game is more about mordant humor, modern angst, cynicism, and betrayal-of-trust issues, than it is about ‘fair play’ and richly-rewarded motor skills.
Things to think about and attempt to program in:
1) A ‘space background’ with stars, that moves somehow, but is easily visually distinguishable from the incoming objects.
2) Sound effects. Some background noises (for the sheer annoyance/distraction), and sounds for ‘collisions’ (and launching ‘projectiles’?).
3) Some way of displaying scores (and irreverent messages)
4) ‘Random generators’ for different objects, and random vectors, and random speeds?
Random generators for score deductions (That hostile just moved past you at mach 27. Text display – “Why didn’t you have your transonic monitors turned on?”).
Title: Galactic Xenophobia II
Much coding to learn…
Sunday, May 15, 2011
Sunday, May 8, 2011
1st game e-mailed to Adam; here is 'funkyActionScript' coding
Here is the coding for game1, if anyone cares to take a look at it. This game does have 'issues'.
//EMDA 203 "First Game" base code v.1
//v1: now with Mouse Control! //Sound! hitTestObject! StageBoundaryBounces!
package
{
//import flash.display.DisplayObject;
//I couldn't figure out the visibility stuff...
import flash.display.MovieClip;
import flash.events.Event;
import flash.ui.Mouse;
import flash.events.MouseEvent;
import flash.display.DisplayObjectContainer;
//
//import flash.media.Sound;//
public class FirstGame1v2 extends MovieClip
{
//Declare Global Variables
var player:MovieClip;
var ball:MovieClip;
var ball2:MovieClip;
var projectile:MovieClip;
var projectile2:MovieClip;
var vx:Number;
var vy:Number;
//var ballBounceSound:Sound;//***NEW
//var playerSound:Sound;//***NEW
var score:Number; //The score
public function FirstGame1v2()//CONSTRUCTOR FUNCTION
{
//Instantiate Variables
trace ("top of constructor")
player = new SmallVertRayGun;
ball = new SmallSaucerGuy;
ball2 = new Alien;
projectile = new SmallRay;
projectile2 = new SmallRay;
vx = 15; //setting movement rates; see much farther down
vy = 2; //setting movement rates; see much farther down
//ballBounceSound = new SoundBasso;//***NEW
//playerSound = new SoundGlass;//***NEW
trace ("Welcome to Galactic Xenophobia!");
score = 0; //This starts the game at 0
trace ("the score is " + score);
//Hide the mouse ***NEW
Mouse.hide();
//Set up the stage
addChild(player);
addChild(ball);
addChild(ball2);
addChild(projectile);
addChild(projectile2);
player.x = stage.stageWidth*.5; //positioning raygun
player.y = stage.stageHeight*.93; //positioning raygun
ball.x = stage.stageWidth*.5;
//positioning SaucerGuy, when he makes his(?) entry
ball.y = stage.stageHeight*.05;
//positioning SaucerGuy, when he makes his(?) entry
ball2.x = stage.stageWidth*.5;
//positioning Alien, when he makes his(?) entry
ball2.y = stage.stageHeight*(.001);
//positioning Alien, when he makes his(?) entry
// Event Listeners
addEventListener(Event.ENTER_FRAME, onEnterFrame);
stage.addEventListener(MouseEvent.CLICK, myClick);
//looking for mouseClick, to do something with
}
// Event Handlers
function myClick (event:MouseEvent):void
//this is for firing ray with mouseClick
{
trace ("mouse click detected");
//had problems; testing function
addChild(projectile2); //moving 'ray';
projectile2.x = (player.x - 10);
projectile2.y = stage.stageHeight*.87;
//these last 2 lines superimpose it on original 'ray'
if (projectile2.y == projectile.y)
{
removeChild(projectile);
}
trace
("Do you truly feel comfortable trying to destroy ");
//testing things
trace ("something/someone you have never even tried to talk to?");
if ((projectile2.y < projectile.y) || (projectile2.y == 0)) { //trace ("Hunh?"); //testing things removeChild(projectile); } if (projectile2.y < 0) { addChild(projectile); } } function onEnterFrame(event:Event):void { // PLAYER X CONTROLLED BY MOUSE ***NEW player.x = mouseX; projectile.x = (player.x - 10); projectile.y = stage.stageHeight*.87; //Stage Boundary Collisions if(ball.x > stage.stageWidth || ball.x < 0) { vx = -vx; //ballBounceSound.play();//***NEW } if(ball.y < 0) { vy = -vy; } //check for Saucer/RayGun collisions if(player.hitTestObject(ball)) { removeChild(ball); addChild(ball); ball.x = stage.stageWidth*.5; ball.y = stage.stageHeight*.05; //playerSound.play();//***NEW addScore(-2); //penalty for saucer crashing into your gun emplacement } //check for Projectile/Saucer collisions if(projectile2.hitTestObject(ball)) { removeChild(projectile2); removeChild(ball); addChild(ball); ball.x = stage.stageWidth*.5; ball.y = stage.stageHeight*.05; //playerSound.play();//***NEW addScore(2); } //check for 'friendly fire' collateral damage if(projectile2.hitTestObject(ball2)) { removeChild(projectile2); removeChild(ball2); trace ("What are you doing! That organism was on our side!") //playerSound.play();//***NEW addScore(-8); } //allows SmallSaucerGuy to advance down past SmallRayGun, and move off stage // and then brings in new SmallSaucerGuy if(ball.y > stage.stageHeight*.99)
{
addChild(ball);
ball.x = stage.stageWidth*.5;
ball.y = stage.stageHeight*.05;
//ballBounceSound.play();//***NEW
addScore(-2); // you snooze, you lose
}
//move stuff
ball.x += vx;
ball.y += vy;
ball2.y += 2*vy;
projectile2.y += 4*(-vy); //speed of 'ray' (projectile2)
}// end onEnterFrame function
function addScore(addThis:Number):void
//adds or subtracts certain amount to score
{
score += addThis; //computes the score
trace ("your score is " + score); //displays the score
if (score > 2)
{
vx = 30;
//increases the side-to-side speed of the saucer
}
if (score > 8)
{
trace ("Your score may be 10, but Pride goeth before the fall...");
vx = 45; //increases the side-to-side speed of the saucer
vy = 5;
//increases the speed of the saucer's vertical approach to your position
}
if (score > 10)
{
//this makes the saucerGuy very small
ball.width = ball.width*.15;
ball.height = ball.height*.15;
}
if (score > 12)
{
//now you lose your rayGuy completely
removeChild(player);
}
if (score < 12)
{
addChild(player);
}
if (score < 10)
{
ball.width = ball.width*1;
ball.height = ball.height*1;
}
if (score < -12)
{
trace ("Your defensive efforts have been sorely inadequate.");
trace ("If you have actually survived this possibly hostile ");
trace ("extraterrestrial border incursion, consider yourself");
trace ("posted to kitchen duty until the time and date of your ");
trace ("court-martial has been scheduled.");
}
}
}// end class
} // end package
//EMDA 203 "First Game" base code v.1
//v1: now with Mouse Control! //Sound! hitTestObject! StageBoundaryBounces!
package
{
//import flash.display.DisplayObject;
//I couldn't figure out the visibility stuff...
import flash.display.MovieClip;
import flash.events.Event;
import flash.ui.Mouse;
import flash.events.MouseEvent;
import flash.display.DisplayObjectContainer;
//
//import flash.media.Sound;//
public class FirstGame1v2 extends MovieClip
{
//Declare Global Variables
var player:MovieClip;
var ball:MovieClip;
var ball2:MovieClip;
var projectile:MovieClip;
var projectile2:MovieClip;
var vx:Number;
var vy:Number;
//var ballBounceSound:Sound;//***NEW
//var playerSound:Sound;//***NEW
var score:Number; //The score
public function FirstGame1v2()//CONSTRUCTOR FUNCTION
{
//Instantiate Variables
trace ("top of constructor")
player = new SmallVertRayGun;
ball = new SmallSaucerGuy;
ball2 = new Alien;
projectile = new SmallRay;
projectile2 = new SmallRay;
vx = 15; //setting movement rates; see much farther down
vy = 2; //setting movement rates; see much farther down
//ballBounceSound = new SoundBasso;//***NEW
//playerSound = new SoundGlass;//***NEW
trace ("Welcome to Galactic Xenophobia!");
score = 0; //This starts the game at 0
trace ("the score is " + score);
//Hide the mouse ***NEW
Mouse.hide();
//Set up the stage
addChild(player);
addChild(ball);
addChild(ball2);
addChild(projectile);
addChild(projectile2);
player.x = stage.stageWidth*.5; //positioning raygun
player.y = stage.stageHeight*.93; //positioning raygun
ball.x = stage.stageWidth*.5;
//positioning SaucerGuy, when he makes his(?) entry
ball.y = stage.stageHeight*.05;
//positioning SaucerGuy, when he makes his(?) entry
ball2.x = stage.stageWidth*.5;
//positioning Alien, when he makes his(?) entry
ball2.y = stage.stageHeight*(.001);
//positioning Alien, when he makes his(?) entry
// Event Listeners
addEventListener(Event.ENTER_FRAME, onEnterFrame);
stage.addEventListener(MouseEvent.CLICK, myClick);
//looking for mouseClick, to do something with
}
// Event Handlers
function myClick (event:MouseEvent):void
//this is for firing ray with mouseClick
{
trace ("mouse click detected");
//had problems; testing function
addChild(projectile2); //moving 'ray';
projectile2.x = (player.x - 10);
projectile2.y = stage.stageHeight*.87;
//these last 2 lines superimpose it on original 'ray'
if (projectile2.y == projectile.y)
{
removeChild(projectile);
}
trace
("Do you truly feel comfortable trying to destroy ");
//testing things
trace ("something/someone you have never even tried to talk to?");
if ((projectile2.y < projectile.y) || (projectile2.y == 0)) { //trace ("Hunh?"); //testing things removeChild(projectile); } if (projectile2.y < 0) { addChild(projectile); } } function onEnterFrame(event:Event):void { // PLAYER X CONTROLLED BY MOUSE ***NEW player.x = mouseX; projectile.x = (player.x - 10); projectile.y = stage.stageHeight*.87; //Stage Boundary Collisions if(ball.x > stage.stageWidth || ball.x < 0) { vx = -vx; //ballBounceSound.play();//***NEW } if(ball.y < 0) { vy = -vy; } //check for Saucer/RayGun collisions if(player.hitTestObject(ball)) { removeChild(ball); addChild(ball); ball.x = stage.stageWidth*.5; ball.y = stage.stageHeight*.05; //playerSound.play();//***NEW addScore(-2); //penalty for saucer crashing into your gun emplacement } //check for Projectile/Saucer collisions if(projectile2.hitTestObject(ball)) { removeChild(projectile2); removeChild(ball); addChild(ball); ball.x = stage.stageWidth*.5; ball.y = stage.stageHeight*.05; //playerSound.play();//***NEW addScore(2); } //check for 'friendly fire' collateral damage if(projectile2.hitTestObject(ball2)) { removeChild(projectile2); removeChild(ball2); trace ("What are you doing! That organism was on our side!") //playerSound.play();//***NEW addScore(-8); } //allows SmallSaucerGuy to advance down past SmallRayGun, and move off stage // and then brings in new SmallSaucerGuy if(ball.y > stage.stageHeight*.99)
{
addChild(ball);
ball.x = stage.stageWidth*.5;
ball.y = stage.stageHeight*.05;
//ballBounceSound.play();//***NEW
addScore(-2); // you snooze, you lose
}
//move stuff
ball.x += vx;
ball.y += vy;
ball2.y += 2*vy;
projectile2.y += 4*(-vy); //speed of 'ray' (projectile2)
}// end onEnterFrame function
function addScore(addThis:Number):void
//adds or subtracts certain amount to score
{
score += addThis; //computes the score
trace ("your score is " + score); //displays the score
if (score > 2)
{
vx = 30;
//increases the side-to-side speed of the saucer
}
if (score > 8)
{
trace ("Your score may be 10, but Pride goeth before the fall...");
vx = 45; //increases the side-to-side speed of the saucer
vy = 5;
//increases the speed of the saucer's vertical approach to your position
}
if (score > 10)
{
//this makes the saucerGuy very small
ball.width = ball.width*.15;
ball.height = ball.height*.15;
}
if (score > 12)
{
//now you lose your rayGuy completely
removeChild(player);
}
if (score < 12)
{
addChild(player);
}
if (score < 10)
{
ball.width = ball.width*1;
ball.height = ball.height*1;
}
if (score < -12)
{
trace ("Your defensive efforts have been sorely inadequate.");
trace ("If you have actually survived this possibly hostile ");
trace ("extraterrestrial border incursion, consider yourself");
trace ("posted to kitchen duty until the time and date of your ");
trace ("court-martial has been scheduled.");
}
}
}// end class
} // end package
Subscribe to:
Posts (Atom)