Sunday, May 15, 2011

Rubber Ducky Bounce or Rubber Ducky Revenge!

Rubber Ducky Bounce or Rubber Ducky Revenge!

I will be starting a completely new game than the pong game, but still deciding between two different games. I will do this on my own without any partnership with anyone else.

The first game will be a basic “bounce” game. Incorporating the angle direction with hitting the paddle in the pong game it will be when the mouse clicks on the ball, it will go wherever based on where it is clicked. The ball will have a restricts to how high it can go and an angle to it coming up and down based on where the ball is clicked. The ball will not get harder to click the more times it is hit in the air. It will be a endurance. There will be high score counter and a normal counter based on how many times the ball is clicked without touching the base of the window. The ball will be a rubber ducky instead (aka rubber ducky bounce). This game will start with the click of a mouse and then will be played based on the mouse clicking and mouse movement. I hope to put a sound of a squeaking rubber duck every time clicked.

The second game is a bit more difficult. This still has a bit more thinking to do.
This game will be either a rubber duck walking through a level with scrolling background or a rubber duck flying and shooting down other things (different rubber ducks, planes, whatever.), most likely the flying duck. The controls will either be up and down the y axis or will move all around (up, down, all round). The opponents will fly in from the right side and shoot at the user and will only shoot at the user if in their sights, not at random. There will be random objects that are not destroyable and will destroy to user if it hit the rubber duck. The user will use a mouse and click or the arrow keys and spacebar for controlling the rubber duck. The opponents will move slowly toward the left side of the screen. The sound will be a rubber duck squeak when it fires and a blast sound when it hits the opponent. After a certain amount of time there will be a boss that will appear that will have a larger life span than the normal opponents.

I am thinking more of the Rubber Duck Bounce game just because it will be easier to create and not to difficult to comprehend. But to do Rubber Ducky Revenge would be a neat achievement if done appropriately.

Thursday, May 5, 2011

Project 5: First Game

-Pong paddle does hit the ball depending on where it hits the paddle.
-The bears(targets) are at different speeds.
-If you play it in flash, it will output a hitcount, high score depending if you exit the game, and how many times you lost since last entered.

Tried to go score in game, but couldn't get it to work appropriately.
Will try to expand apawn this later.

Removed for repairs. haha A bit glitchy. But is added now. Removed because the text on the stage makes it glitchy. Maybe because it is called every frame.


Here is the code:
package
{
import flash.display.MovieClip;
import flash.events.Event;
import flash.ui.Mouse;
import flash.media.Sound;
import flash.text.*;

public class FirstGame extends MovieClip
{
var myText:String;
var myText1:String;
var myText2:String;
var myTextBox:TextField;
var myTextBox1:TextField;
var myTextBox2:TextField;

var player:MovieClip;
var ball:MovieClip;
var vx:Number;
var vy:Number;
var losercount:Number;
var hitcount:Number;
var hs:Number;
var t1:MovieClip;
var t2:MovieClip;
var t3:MovieClip;
var maxVx:Number = 15;
var targetyx:Number = 5;
var block:MovieClip;

public function FirstGame()
{
player = new SpaceShipcopy;
ball = new Aircopy;
t1 = new Rupertcopy;
t2 = new Rupertcopy;
t3 = new Rupertcopy;
block = new AutoBotscopy;
block.scaleX = .2;
block.scaleY = .2;
ball.scaleX = .18;
ball.scaleY = .18;
t1.scaleX = .15;
t1.scaleY = .15;
t2.scaleX = .15;
t2.scaleY = .15;
t3.scaleX = .15;
t3.scaleY = .15;
player.scaleX = .3;
player.scaleY = .2;
vx = 5;
vy = 5;
losercount = 0;
hitcount = 0;
hs = 0;

Mouse.hide();

addChild(player);
addChild(ball);
addChild(t1);
addChild(t2);
addChild(t3);
addChild(block);

player.x = stage.stageWidth*.5;
player.y = stage.stageHeight*.85;
t1.x = stage.stageWidth*.15;
t1.y = stage.stageHeight*.2;
t2.x = stage.stageWidth*.75;
t2.y = stage.stageHeight*.25;
t3.x = stage.stageWidth*.35;
t3.y = stage.stageHeight*.3;
ball.x = stage.stageWidth*.3;
ball.y = stage.stageHeight*.1;
block.x = stage.stageWidth*.5;
block.y = stage.stageHeight*.1;
t1.vx = 6;
t1.vy = 5;
t2.vx = 15;
t2.vy = 5;
t3.vx = 9;
t3.vy = 5;

addEventListener(Event.ENTER_FRAME, onEnterFrame);
}


function onEnterFrame(event:Event):void
{

ballPaddleCollision();

checkStageCollision(player);
checkStageCollision(ball);
checkStageCollision(t1);
checkStageCollision(t2);
checkStageCollision(t3);

bounceWall(t1);
bounceWall(t2);
bounceWall(t3);


player.x = mouseX;

if(ball.x > stage.stageWidth || ball.x < 0)
{
vx = -vx;

}

if(ball.y > stage.stageHeight)
{
ball.x = stage.stageWidth*.3;
ball.y = stage.stageHeight*.1;
losercount += 1;
trace("You are a loser " + losercount + " times over...");
vx = 5;
vy = 5;

if(hs >= hitcount)
{
trace("You had " + hitcount + " hits!");
}

if(hs < hitcount)
{
hs = hitcount;
trace("NEW HIGH SCORE!");
trace("High score: " + hs);
}
hitcount = 0;

}

if( ball.y < 0)
{
vy = -vy;
}

ball.x += vx;
ball.y += vy;
ball.rotation += 5;

addText();

}

function addText():void
{
myText= "Hitcount = " + hitcount + " Highscore = " + hs + " Loser = " + losercount;
myTextBox = new TextField();
addChild(myTextBox);
myTextBox.text = myText;
myTextBox.x = stage.stageWidth*.1;
myTextBox.y = stage.stageHeight*.9;
myTextBox.width = 100;
myTextBox.height = 50;
myTextBox.multiline = true;
myTextBox.wordWrap = true;
myTextBox.background = true;



var format:TextFormat = new TextFormat();
format.font = "Verdana";
format.color = 0xFF0000;
format.size = 10;

myTextBox.defaultTextFormat = format;


}
function ballPaddleCollision():void
{
if(ball.hitTestObject(player))
{
var relativeX:Number=ball.x-player.x;
var relativePercentage:Number=(relativeX/player.width)*2;
var newVx:Number=(relativePercentage*maxVx);
vx=newVx;
vy=-vy;
hitcount += 1;
}

// If ball hits block, bounce off.
if(ball.hitTestObject(block))
{
vx=-vx;
vy=-vy;
}

}


function moveThis(objectA:MovieClip):void
{
objectA.x += objectA.vx;
objectA.y += objectA.vy;
}

function bounceWall(objectA:MovieClip):void
{
objectA.x += objectA.vx;
}

function checkStageCollision(objectA:MovieClip):void
{
if (objectA.x <= 0 || objectA.x > stage.stageWidth)
{
objectA.vx = - objectA.vx;
}
if (objectA.y <= 0 || objectA.y > stage.stageHeight)
{
objectA.vy = - objectA.vy;
}


}

}
}