Sign in to follow this  
Judah Smith

Array Problem: Flash AS2.0

Recommended Posts

I am trying to write my first game which is a mix of pong and breakout, the old Atari bat and ball game. Its been a helluva way to try to learn my first programming language and I've got a lot of learning from it. I have got the pong bit working but I'm struggling with the bricks on the breakout section. I decided that the best way to handle bricks is to hold them in an array (I need to learn arrays anyway) and I've gotten my bricks to form in a neat line, but I now need them to start a new line of bricks every time thay get to the edge of the screen (the stage height, my bricks run vertically). Is there anyone out there who I could send my code to, who could take a look and perhaps steer a n00b in the right direction? Many thanks

Share this post


Link to post
Share on other sites
var foo:Array = new Array();
var brickWidth:Number = 60;
var brickHeight:Number = 30;
var spacing:Number = 5;
var offsetX:Number = 0;
var offsetY:Number = 0;
for(int x = 0; x < width; ++x){
for(int y = 0; y < height; ++y){
foo.Push(new Brick(x*(brickWidth+spacing)+offsetX, y*(brickHeight+spacing)+offsetY));
}
}

That's one way to handle it. Are you using bitmap rendering?


http://www.kirupa.com/forum/showpost.php?p=2229691&postcount=9

follow that and use AS3 if you want to learn how to really handle games in flash. AS2 is kind of old.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this