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.
Printable View
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.
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 :D 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
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.Quote:
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 :D 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 :)
Never know though.
Kusco,Quote:
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?
If you don't mind sharing, I'd like to see how you accomplished that.
-Jason
Bret,Quote:
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.
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
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 :D 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.Quote:
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 :D I personally would love to do more with it :)
Anyway, I'm babbling again so....
Cheers,
Ed
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....
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 :D
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.Quote:
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 :D
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
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. :D
HTH
Cheers,
Ed
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
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
Which is a work around for the fact that the ball kept triggering collision even with hidden objects.Quote:
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.
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
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]
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.
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
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 :D
Cheers,
Ed
I never really see it goes by so fast now that I have DSLQuote:
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 :D
Cheers,
Ed
Just need to round it
I've been "eavesdropping" here. Things have been so busy that my 3dfa javascript tutorializing (is that a word?) has been on hold - but your statement reminds me that I was working on a project that involved showing and removing squares (sort of minesweeper-like) - I used cloning in the previewer and the idea worked great. As soon as I exported to the browser (IE5.5) however, the clones disapeared. Can we get clones to appear and disappear in the browser?Quote:
Originally posted by kusco
Instead of using a chooser element to show how many balls you have left, how about cloning it?
thanks!
Jon
elementname.show()Quote:
Originally posted by JDE
I've been "eavesdropping" here. Things have been so busy that my 3dfa javascript tutorializing (is that a word?) has been on hold - but your statement reminds me that I was working on a project that involved showing and removing squares (sort of minesweeper-like) - I used cloning in the previewer and the idea worked great. As soon as I exported to the browser (IE5.5) however, the clones disapeared. Can we get clones to appear and disappear in the browser?Quote:
Originally posted by kusco
Instead of using a chooser element to show how many balls you have left, how about cloning it?
thanks!
Jon
elementname.hide()
Hi JDE,
In addition to Bret's response cloned elements do not work correctly in child movies. So if you have these elements in a child movie I would suggest (at least until vers. 3.6 becomes available) to put all of the elements you wish to clone in the main movie.
As to whether the word 'Tutorializing' is a word - I don't know but if it isn't let's put it in the dictionary :D.
Cheers,
Ed
Hi,
I've dabbled with this beast a little more :)
Bret, I really hope you don't mind? It's a great project to learn from.
Anyway, here is the link to the modifications I've made.
http://www.syssoft.net.au/3dfa/breakout2.movie
I've renamed this version so as not get it mixed up with the previous one/s just in case.
What I have done in this example is the following...[list=1][*] Modified just about all of the action scripts containing a javascript element with various stuffs (most listed below).[*] Removed any occurances of varname++ and replaced it with varname = varname + 1. This was done to prevent the possibility of memory leaks. (varname is the name of any variable using the ++ operator)[*] Resized the ball slightly (more of an accident than anything else).[*] No longer using the velocity.x/y for the ball. Instead, I'm using an action script running 60 times per second to move the ball around. This makes the ball move around the screen a bit smoother and faster. I did this because the maximum frame rate is 30 but action script elements can run up to 60 (so I've discovered) which makes movement smoother. Otherwise the ball appears to move in a more jagged fashion.[*] Changed the frame rate from 16 to 30 to smooth things out a little more.[*] Changed the other action script elements to run at 60 time per second.[*] Reworked the bounds checking for the screen. I found that in using either the original bounds checking or this version the ball would sometimes get stuck on the left or right edges.[*] Reworked the bounds checking for the ball colliding with the blocks. Now the ball will bounce off the sides of the blocks making it ricochet a little nicer.[*] Reworked the angle variance for when the ball hits the paddle.[/line=1]
Anyway, have fun. I know I have in both playing it and working on it :)
Bret, again - hope you don't mind. But .... this game you've come up with should be posted somewhere! It's fun!!!
Cheers,
Ed
I swear I'm gonna smack you if you apologise again....Quote:
Originally posted by kusco
Anyway, have fun. I know I have in both playing it and working on it :)
Bret, again - hope you don't mind. But .... this game you've come up with should be posted somewhere! It's fun!!!
Cheers,
Ed
I've learned so much from this. Anyway I've posted the newest version at
http://deadyeti.com/blanius/breakout.html
Near future I'm going to do some sort of high score thing and I've added a couple of menus, Ed what link would you like to you in the credit page?
Very Nicely done.
Ok, ok, I'm sorry :D
Anyway, I couldn't help myself, I've done it again.
Anyone using the keyboard to start something in a movie (as in this game) may be interested in the accompanying html document.
What I've done is to set the focus on the movie when the page has loaded or when the web browser gains focus. This means that the user doesn't need to click somewhere on the movie first before keyboard keys can be used. It's all documented in the html document and may prove useful.
Dkerr (if your watching) I would like to suggest putting this code as an option in 3DFA (as in a checkbox) so that developers can set the focus of the movie by default or not. In essence 3DFA could produce two versions of the html code. One being what is generated now and the other that includes the "auto-focus".
I use IE5.something so anyone that has Navigator, could you test the focus method and let us all know if it does or doesn't work - thanks.
Now back to the game:
Bret, I noticed that there's a bit of text in the webpage (for the game) that states that the movie has to be reloaded in order to begin a new game. Not anymore, I've added a new action script element that resets all the variables of the game, modified the show/hide element for the New Game button and it seems to work fine.
Again I've renamed the movie. I do this as a means to protect your original incase what I've done doesn't work properly.
Here's the link...
http://www.syssoft.net.au/3dfa/breakout3.zip
Bret, as for a link to my site, thanks. As soon as I have a page ready (I'm working on one) I'll give you the link.
...now for some breakfast
Cheers,
Ed
Great job guys. Bret, what kind of server does your site run? Maybe I could create a cool high-score system for it. Anyway, thanks to you, I'm creating my own snake clone. Thanks for the great javascript!
Cool can't wait to see it. The praise for the javascripting should mostly go to Kusco, he's brilliant at this. I've gleened alot from him already.... I haven't even put in everything he's contributed yet, still looking it over. As for the high scores, I have full hosting with mysql and php so it won't be hard to add just have to get around to it.Quote:
Originally posted by ajcompany
Great job guys. Bret, what kind of server does your site run? Maybe I could create a cool high-score system for it. Anyway, thanks to you, I'm creating my own snake clone. Thanks for the great javascript!
ok, thanks kusco! on the high score note, PHP eh? I'll see If I can get something up for mysql and that. I haven't done much PHP recently, but I'd like to try.
'tis a pleasure to help out.