A Flash Developer Resource Site

Page 1 of 2 12 LastLast
Results 1 to 20 of 30

Thread: the breakout game

  1. #1
    KoolMoves Moderator blanius's Avatar
    Join Date
    Jul 2001
    Location
    Atlanta GA
    Posts
    5,244
    Ok I've been working on it again. (thanks Kusco) It's somewhat playable now.

    http://deadyeti.com/blanius/breakout.html

    Souce file is there, It might be of interest to those wanting to start working in javascript.


  2. #2
    Senior Member kusco's Avatar
    Join Date
    Nov 2001
    Posts
    681
    Hello Bret,

    No probs with the helping out there. You've helped me quite a bit more than that anyway

    Did I end up sending you the version of your game where I made a change so that the ball would bounce off the paddle at a diffent angle depending on where the ball hit?

    Anyway it looks great. With a bit of javascript it would be possible to setup layers of blocks with different patterns, make some of them move (just for a challenge) and have levels where the layers come down the screen (like the aliens did in Space Invaders) - yes I do remember playing that in the arcades

    On another note, the player on player over the Internet chess game is coming along now. I've finally figured out what was causing the game play to be slow and I now only need to figure out how to get around the problem.

    Cheers,
    Kusco

  3. #3
    KoolMoves Moderator blanius's Avatar
    Join Date
    Jul 2001
    Location
    Atlanta GA
    Posts
    5,244
    Originally posted by kusco
    Hello Bret,

    No probs with the helping out there. You've helped me quite a bit more than that anyway

    Did I end up sending you the version of your game where I made a change so that the ball would bounce off the paddle at a diffent angle depending on where the ball hit?

    Anyway it looks great. With a bit of javascript it would be possible to setup layers of blocks with different patterns, make some of them move (just for a challenge) and have levels where the layers come down the screen (like the aliens did in Space Invaders) - yes I do remember playing that in the arcades
    No I don't think I saw the angle thing, actually Dkerr mentioned I should consider that as well. As for adding to it any further I don't know that I'll put too much time into it. It was mainly an experiment to try out some ideas.

    Never know though.

  4. #4
    Senior Member zoranvedek's Avatar
    Join Date
    Aug 2001
    Location
    Wagoner OK
    Posts
    893
    Originally posted by kusco


    Did I end up sending you the version of your game where I made a change so that the ball would bounce off the paddle at a diffent angle depending on where the ball hit?


    Kusco,

    If you don't mind sharing, I'd like to see how you accomplished that.

    -Jason

  5. #5
    Senior Member zoranvedek's Avatar
    Join Date
    Aug 2001
    Location
    Wagoner OK
    Posts
    893
    Originally posted by blanius
    Ok I've been working on it again. (thanks Kusco) It's somewhat playable now.

    http://deadyeti.com/blanius/breakout.html

    Souce file is there, It might be of interest to those wanting to start working in javascript.

    Bret,
    the game is great. I'm gonna tear into the JS later(I can use all the help I can get in that area right now).

    -Jason

  6. #6
    Senior Member kusco's Avatar
    Join Date
    Nov 2001
    Posts
    681

    But of course!!!

    Hello Bret and Jason,

    Here is the link to the modified movie from when I first received it.

    http://www.syssoft.net.au/3dfa/breakout.movie

    What I've done is to introduce a bit of javascript into it to get the ball to bounce off the paddle at a different angle depending on where the ball hit the paddle. If the ball hit the paddle closer to the edge then the angle would be greater.

    I think I also added a few more levels of blocks but I can't be sure as it was a while ago since I did anything to this....or did I just do it differently????

    The javascript code has a few comments line through it to help self-document the code and make it easier for debugging purposes.

    If you have any q's about anything that I've done then please ask away as I'll only be too happy to help explain any of the 'things' I've done in here.

    Bret, if you're not intending to do much more with it then what do you think about the idea of people making further changes to it and making it a community effort/collaboration? There's plenty of talent in this forum to make this more than just a game I personally would love to do more with it

    Anyway, I'm babbling again so....

    Cheers,
    Ed



  7. #7
    KoolMoves Moderator blanius's Avatar
    Join Date
    Jul 2001
    Location
    Atlanta GA
    Posts
    5,244

    Re: But of course!!!

    Originally posted by kusco
    Hello Bret and Jason,

    Here is the link to the modified movie from when I first received it.

    http://www.syssoft.net.au/3dfa/breakout.movie

    What I've done is to introduce a bit of javascript into it to get the ball to bounce off the paddle at a different angle depending on where the ball hit the paddle. If the ball hit the paddle closer to the edge then the angle would be greater.

    I think I also added a few more levels of blocks but I can't be sure as it was a while ago since I did anything to this....or did I just do it differently????

    The javascript code has a few comments line through it to help self-document the code and make it easier for debugging purposes.

    If you have any q's about anything that I've done then please ask away as I'll only be too happy to help explain any of the 'things' I've done in here.

    Bret, if you're not intending to do much more with it then what do you think about the idea of people making further changes to it and making it a community effort/collaboration? There's plenty of talent in this forum to make this more than just a game I personally would love to do more with it

    Anyway, I'm babbling again so....

    Cheers,
    Ed


    I'll look at the code. I've made the source available and I hope people WILL play with it. Right now it has two levels and two rows of blocks. There is a bug in that the ball can get trapped below the paddle right now. I did use your hidden array to work around the invisible collision problem and that is working well.

  8. #8
    KoolMoves Moderator blanius's Avatar
    Join Date
    Jul 2001
    Location
    Atlanta GA
    Posts
    5,244

    Re: Re: But of course!!!

    Oh man Kusco you're making me look bad

    You javascript is SO much more elegant. I may have to go back and work with YOUR code and abandon the kludge of code I've come up with.


    You obviously have some programming background and it shows in your coding I encourage everyone to look at the javascript as an example of the right way to do it. It's thought out in advance and clearly laid out. Mine tends to be a bit of a mess as I figure it out as I go. I suppose this comes from teaching myself how to code....

  9. #9
    Senior Member kusco's Avatar
    Join Date
    Nov 2001
    Posts
    681
    Hi Bret,

    Yes I have a number of years programming experience. To fill you and everyone in here is a little background...
    Self taught at age 12, been programming ever since I can't work out how old I am right now as I no longer have enough fingers and toes to count that high

    Anyway, thanks for the compliment. I started coding really badly too. It's just practice. What you see is my preferred method and style of programming but everyone is different.

    Some folks like to put the curly braces in-line with their code which tends to hide them from view. I prefer to put them on separate lines to help space the program out and make it easier to read and follow.

    What I'm aiming for now is to have the creative minds and genius that you and Jason possess. Do you have any tips for me on how to do this?

    Thanks again,
    Ed

  10. #10
    KoolMoves Moderator blanius's Avatar
    Join Date
    Jul 2001
    Location
    Atlanta GA
    Posts
    5,244
    Originally posted by kusco
    Hi Bret,

    Yes I have a number of years programming experience. To fill you and everyone in here is a little background...
    Self taught at age 12, been programming ever since I can't work out how old I am right now as I no longer have enough fingers and toes to count that high

    Anyway, thanks for the compliment. I started coding really badly too. It's just practice. What you see is my preferred method and style of programming but everyone is different.

    Some folks like to put the curly braces in-line with their code which tends to hide them from view. I prefer to put them on separate lines to help space the program out and make it easier to read and follow.

    What I'm aiming for now is to have the creative minds and genius that you and Jason possess. Do you have any tips for me on how to do this?

    Thanks again,
    Ed
    Perhaps we should just keep at each other eh? Maybe a little will rub off both ways... I'm looking very hard at the way you did the multible rows, I seems to me you used just one larger array where as I did a new array for each.

  11. #11
    Senior Member kusco's Avatar
    Join Date
    Nov 2001
    Posts
    681

    Spot on

    Bret,

    I'm all for sharing thoughts, ideas, concepts (have I just said the same thing 3 times with different words??), code and knowledge. Let's continue to do that

    You're right. I used a single array to handle the blocks. I did this to keep the coding simpler.

    Using separate arrays would require more loops or more conditional statements in the code. For every layer you'd need to loop through and check for collisions either by using the additional loops and a single condition or a single loop with multiple conditions.

    A single array requires a single loop and a single condition which also means less programming overhead. You still end up with the same result. It also allows you to better control the various actions you want to take place on the blocks.

    You'll also notice that I didn't specify the size of the array when I initialised it. This allows you to make an array of any size. Instead, you could set a size limit on the array and then only check the first MaxBlocks in the array for collisions.

    A multi-dimensional array could also be used but this tends to be a bit restrictive here as you need to define the number of layers for the game up front. Also, you need to introduce additional loops to cater for this which makes things a little more complicated. It's not required for this application as there is no real need to use this type of array or multple arrays. All the layer information can be obtained easily enough from the position of the block that has been hit by the ball.

    There are hundreds of different ways to achieve the same results. I used my way I'm not saying that my way is better than anyone else's either.

    I've tried to write the code so that anyone can change a value to increase/decrease the number of layers or the number of blocks in a layer as easily as possible. Using a single array is best for this and helps to make things easier to understand for those not familiar enough with programming.

    Time for bed as it's now 12:50am down here.

    HTH

    Cheers,
    Ed

  12. #12
    Senior Member zoranvedek's Avatar
    Join Date
    Aug 2001
    Location
    Wagoner OK
    Posts
    893
    OK,
    I am probably asking some real basic questions here, but please bear with me............


    In the following line:

    xVelocity = Ball.position.x - Paddle.position.x;
    xVelocity = xVelocity;
    Ball.velocity.x = xVelocity * 5;

    Why do you state xVelocity = xVelocity, if you just set it in the previous line (wouldn't it already equal itself)?




    Also this line is totally foriegn to me:

    for(ndx = 0; ndx < MaxBlocks; ndx ++)
    {
    if(Blocks[ndx].collide(Ball) && Hidden[ndx] == false)


    As near as I can tell its keeping the ball from colliding with hidden objects, but I can't figure out how. What does ndx represent here?


    Again these are probably real basic questions, but I gotta learn sometime, and alot of this is Greek to me........................

    Thanks in advance,
    -Jason

  13. #13
    Senior Member kusco's Avatar
    Join Date
    Nov 2001
    Posts
    681

    Good Questions

    Hi Jason,

    The first question is fairly easy to answer. It's a left-over line of code that I was using when I was experimenting with the game. I simply forgot to take it out.

    Now for the second answer.
    ndx is a variable which is used to keep an iNDeX into the array. I use ndx as is sounds a bit like 'index' and is shorter.

    The conditional statement checks for a collision on a block with the ball AND (&&) also if the block is not hidden. I use the array Hidden[] to keep track of which blocks have been removed from view. I probably should have used the is_showing() function (or the similar function - not at my 'real' computer right now) to check for this instead of using the Hidden[] array.

    So the statement is saying something like "if the block is being hit by the ball and the block is not currently being hidden then..."

    HTH

    Cheers,
    Ed

  14. #14
    KoolMoves Moderator blanius's Avatar
    Join Date
    Jul 2001
    Location
    Atlanta GA
    Posts
    5,244

    Re: Good Questions

    Originally posted by kusco
    The conditional statement checks for a collision on a block with the ball AND (&&) also if the block is not hidden. I use the array Hidden[] to keep track of which blocks have been removed from view. I probably should have used the is_showing() function (or the similar function - not at my 'real' computer right now) to check for this instead of using the Hidden[] array.
    Which is a work around for the fact that the ball kept triggering collision even with hidden objects.

  15. #15
    Senior Member kusco's Avatar
    Join Date
    Nov 2001
    Posts
    681

    Grey Matter

    Hi Bret,

    I completely forgot about the real reason for using the Hidden[] array.

    Thanks! ...maybe I should cut back on the coffee...

    Cheers,
    Ed

  16. #16
    KoolMoves Moderator blanius's Avatar
    Join Date
    Jul 2001
    Location
    Atlanta GA
    Posts
    5,244

    Broke it again

    LOL

    Well I started reworking Kusco's code and now I've got a wierd export problem.

    When the ball dissaprears the whole movie shifts down about a third of it's height..... really odd.

    Newest version

    http://deadyeti.com/blanius/breakout.html

    http://deadyeti.com/blanius/breakout.movie


    I've determined it has something to do with the chooser element. Bug report sent to support!


    [Edited by blanius on 05-09-2002 at 10:22 AM]

  17. #17
    KoolMoves Moderator blanius's Avatar
    Join Date
    Jul 2001
    Location
    Atlanta GA
    Posts
    5,244
    Ok this version is getting good. Unlimited levels. Gets fast really quick..... Still can't get the chooser to work right so for now remaining balls is represented by number

    Used javascript to keep ball in play now so that I could account for the width of the ball, using bounding action looked like ball particaly went off screen.

    I will try to comment additional code better next few days.


  18. #18
    Senior Member kusco's Avatar
    Join Date
    Nov 2001
    Posts
    681

    Lookin' Good!

    Hi Bret,

    It's really starting to look good now. Welldone.

    I just have a couple of comments/suggestions.
    [list=1][*] Instead of using a chooser element to show how many balls you have left, how about cloning it?[*] I noticed the ball almost going off screen around the edges too. I thought about changing the routine that checks for the bounds to allow for the width (diameter) of the ball in the calculations. Should'nt be too hard - I think.[*] When you get to the 3rd level the ball is moving too fast No, really, the movment of the ball is such that it jumps over the paddle. Will have to check if there's a way around this.[/list=1]

    The project is fun and is using quite a lot of different features of 3DFA which means it'll also make a great example.

    If you don't mind, I'd like to have a go at a few of the things I listed above as 'practice' for myself. When I've got something I'll post it up

    Cheers,
    Ed

  19. #19
    Senior Member kusco's Avatar
    Join Date
    Nov 2001
    Posts
    681
    Bret,

    I also forgot to mention that the loading movie is showing a zillion decimal places for the percentage.

    It looks like your trying to calculate PI

    Cheers,
    Ed

  20. #20
    KoolMoves Moderator blanius's Avatar
    Join Date
    Jul 2001
    Location
    Atlanta GA
    Posts
    5,244

    LOL

    Originally posted by kusco
    Bret,

    I also forgot to mention that the loading movie is showing a zillion decimal places for the percentage.

    It looks like your trying to calculate PI

    Cheers,
    Ed
    I never really see it goes by so fast now that I have DSL
    Just need to round it

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center