-
[CS3] [HELP] Questions concerning school project
Im taking an Internet Programming course focusing on beginner AS. For my final project i have to make a game, and so i decided to try my hand at a platform game, since Ive had interest in that for a long while. I decided to use backgrounds from the Metal Slug game series (taken from here:http://www.metalslugsprites.net/backgrounds/) .
So my question is concerning where characters will be walking, since this is obviously not a tile-based game. I figured that I would have to make 2 layers for the background: One with the background image, and then on the other, I would draw where I want characters to be able to walk/jump/hit. I happened to come across this tutorial which supported my theory:http://www.gotoandplay.it/_articles/2003/10/bubble.php, but I still feel unsure. I guess Im a bit nervous about this, seeing as its my first time attempting such an endeavor.
Another question I have is about animation. Do I have to make 2 sets of animations for characters, one for each direction? If that wasnt clear enough, I mean that do I have to make an animation for a character moving left and then another for it moving right? Or is there an easier way around that?
I also have a question not pertaining to this project, but to the course. We recently had a mid-term where we had to modify a program. One of the things we had to do was make objects bounce off the sides of the stage. I didnt know how to do it, so I googled and found a few sites that mentioned it, but I couldnt get it to work.
Here's my code. The code I tried to use for the stage wall bouncing is in comments.
code:
import flash.geom.ColorTransform;
newBallButton.buttonMode =true;
var ballArray:Array = new Array();
var ballColor:uint;
var speed:Number= 2;
var newBallIndex:Number =0
ballArray[newBallIndex] = new Ball();
ballArray[newBallIndex].y=200;
var timer:Timer = new Timer(100);
timer.addEventListener(TimerEvent.TIMER,moveBall);
timer.start();
function moveBall(evt:TimerEvent):void{
for (var i:Number=0;i<ballArray.length;i++) {
if(i%2==0){
ballArray[i].x += speed * 5;
ballArray[i].y += speed * 5;
}
else{
ballArray[i].x -= speed * 10;
ballArray[i].y -= speed * 10;
}
}
}
//ballArray[newBallIndex].addEventListener(Event.ENTER_FRAME, bounceBall);
//function bounceBall(event:Event):void{
//if(ballArray[newBallIndex].x >= stage.stageWidth-ballArray[newBallIndex].width){
//ballArray[newBallIndex].x *= -1;
// }
//if(ballArray[newBallIndex].x <= 0){
//ballArray[newBallIndex].x *= -1;
//}
//if(ballArray[newBallIndex].y >= stage.stageHeight-ballArray[newBallIndex].height){
//ballArray[newBallIndex].y *= -1;
//}
//if(ballArray[newBallIndex].y <= 0){
//ballArray[newBallIndex].y *= -1;
// }
//}
newBallButton.addEventListener(MouseEvent.MOUSE_UP ,newBall);
function newBall(evt:MouseEvent):void{
ballArray[newBallIndex] = new Ball();
ballArray[newBallIndex].x = Math.random()*200;
ballArray[newBallIndex].y = Math.random()*400;
var newColorTransform:ColorTransform = new ColorTransform();
newColorTransform.color = Math.random() * 0xffffff;
ballArray[newBallIndex].transform.colorTransform = newColorTransform;
addChild(ballArray[newBallIndex]);
newBallIndex++;
}
The code I tried to use for the stage wall bouncing is in comments.
What am I doing wrong? Im pretty sure its something simple..
Thank you for your help, in advance.
-
for the animations thing, you can just flip the xscale, like:
PHP Code:
if(Key.isDown(68))
{
whatever._xscale = 100;
//stuff
}
if(Key.isDown(65))
{
whatever._xscale = -100;
//stuff
}
and what are you trying to do with that code? make a game like pong?
cuz that code looks way overdone imo. It could be done a lot simpler than that.
-
for better readability:
PHP Code:
import flash.geom.ColorTransform;
newBallButton.buttonMode =true;
var ballArray:Array = new Array();
var ballColor:uint;
var speed:Number= 2;
var newBallIndex:Number =0
ballArray[newBallIndex] = new Ball();
ballArray[newBallIndex].y=200;
var timer:Timer = new Timer(100);
timer.addEventListener(TimerEvent.TIMER,moveBall);
timer.start();
function moveBall(evt:TimerEvent):void{
for (var i:Number=0;i<ballArray.length;i++) {
if(i%2==0){
ballArray[i].x += speed * 5;
ballArray[i].y += speed * 5;
}
else{
ballArray[i].x -= speed * 10;
ballArray[i].y -= speed * 10;
}
}
}
newBallButton.addEventListener(MouseEvent.MOUSE_UP ,newBall);
function newBall(evt:MouseEvent):void{
ballArray[newBallIndex] = new Ball();
ballArray[newBallIndex].x = Math.random()*200;
ballArray[newBallIndex].y = Math.random()*400;
var newColorTransform:ColorTransform = new ColorTransform();
newColorTransform.color = Math.random() * 0xffffff;
ballArray[newBallIndex].transform.colorTransform = newColorTransform;
addChild(ballArray[newBallIndex]);
newBallIndex++;
}
-
Thank you for the help.
The code was from my midterm(has nothing to do with the game Im planning). Here's what we had to do:http://media.lehman.cuny.edu:16080/~...ow/BowWow.html
After the midterm, my professor told us to finish what we didnt do. I was unable to get the balls to bounce off of the stage boundaries, because I had never done that before, and because he didnt teach us. I tried using examples that I found thru Google searching (thats the part of the code that I put in comments) but it didnt work properly. So I was just hoping that someone could see what the problem was, cuz I sure cant.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|