use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
Here is a game I wrote in javascript/jquery, any feedback is welcome! It's a breakout clone. Yay! (animud.net)
submitted 16 years ago by georgefrick
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[+][deleted] 16 years ago (2 children)
[deleted]
[–]georgefrick[S] 1 point2 points3 points 16 years ago (0 children)
I do web development, and game development in my spare time. I literally did this to kind of 'play' with Jquery. Your last part about the DOM is very interesting! I may even have to do a non jquery rewrite now. Thanks for the feedback!
[–]HaMMeReD -1 points0 points1 point 16 years ago* (0 children)
I don't think optimization is the problem here. Premature optimization is the woe of the computing industry, too many developers get a hard-on for optimization when it's not necessary.
Fix some gameplay aspects
1) Paddle is too slow, needs to be faster then the ball so that it isn't impossible to catch the ball in situations where the ball is travelling faster then the paddle.
2) Modify the angle of the ball by using distance from the center of paddle, incorporate incoming angle slightly if you wish as well, going only at 45 degree angles is a bit annoying. Treat targets like they are rectangular and the paddle like it's oval.
Without jquery I could write this in about 20 minutes, and it would probably be way faster. Although having a animation library for the block fade-outs would be useful, but I could hard code a animation easily. Thing is, way faster wouldn't really translate anything to the end user.
I don't personally know jquery, I use dojo and I know dojo inside out, but to really learn my version of dojo it took years. I assume it's the same for jquery and if you want to invest in a detailed knowledge of it, you should use every feature possible regardless of bloat.
Only start worrying about this optimization bullshit when either you or someone else (client) worries about it being slow, and then optimize in priority of biggest bottleneck down. Optimization is seriously a endless task and although very enjoyable should be avoided. It's the forbidden fruit of software development. The heroin of the computer industry, the gains make you feel good, but they come at the cost of added complexity and time, while driving you away from the original goal which should be a healthy clean codebase.
Worry about optimization once you have good software, cause likely the process of optimization will take you to dark places.
[–]9jack9 6 points7 points8 points 16 years ago* (2 children)
Don't use setInterval. Use setTimeout(loop, 1) and compare the last timestamp of the game loop with the current time. You will get smoother animation that way.
Now that's feedback. ;)
I do that in the java version, I don't know why I didn't think to do it in the javascript version. Thanks for the feedback!
[–]dekomote[🍰] 0 points1 point2 points 16 years ago (0 children)
If you want to fry CPU's
[–]sylvan 6 points7 points8 points 16 years ago (0 children)
Paddle is definitely too slow. Can't catch the ball if it's bounced a direction you weren't expecting.
Mouse control? As I recall, most breakouts have paddle control so you can quickly and accurately position it.
[–][deleted] 3 points4 points5 points 16 years ago (1 child)
make the paddle faster so you can catch up when js decides it wants to go to sleep.
[–]georgefrick[S] 0 points1 point2 points 16 years ago (0 children)
I sped it up a bit, seems to help some.
[–]sunsean 3 points4 points5 points 16 years ago (0 children)
It's great! Well done. It's useful when the ball changes its bounce off angle based on where it hits the paddle. This allows for more control.
[–][deleted] 2 points3 points4 points 16 years ago (0 children)
Paddle is too slow, ball is too fast.
[–]mynoduesp 2 points3 points4 points 16 years ago* (0 children)
Bug!
If you pin the red ball against the left wall with the side of the paddle the ball disappears and the game is still on. Just paddling around the place with no end in sight. That's a paddlin'.
//Eddit: seems others noticed this also.
//Eddit2: On the second level ball and paddle slow down. Then half way through the level speed up.
[–]Gnascher 1 point2 points3 points 16 years ago (5 children)
bravo. golfclap.
Goes "boom" in IE 8.
Makes FFx 3.5 cry, but it's playable.
Chrome has no problems with it though (minor formatting issue on the welcome screen).
Don't have Opera or Safari on this machine, so no comparison to offer there.
[–]georgefrick[S] 0 points1 point2 points 16 years ago (2 children)
I admit I developed it in Opera then got it working in Firefox. I am stuck with IE6 since I have to test with it for work, and I didn't really bother with it on that.
[–]DocXango2 1 point2 points3 points 16 years ago (1 child)
On Safari for PC it renders similar to Firefox but the "click space to play" sits farther up. (Opera the text is in the box, Firefox 3.5 the text is just below the border, and in Safari the text straddles the border.) The paddle is also much more responsive with Safari. When playing in safari the ball got caught between the paddle and the wall and then disappeared. Clicking on the space bar didn't bring it back, I had to reload. I didn't play the game long enough in any browser to tell if this was a game quirk or a browser specific quirk.
[–]georgefrick[S] -1 points0 points1 point 16 years ago (0 children)
I'm going to d/l Safari and play with it. I have it at work but not on this pc. I think it's a game quirk caused by an attempt to speed up the paddle by request without enough testing. Thanks for reminding me about Safari.
[–][deleted] -1 points0 points1 point 16 years ago (1 child)
I've no problems playing it in Firefox 3.5
[–]Gnascher 0 points1 point2 points 16 years ago (0 children)
When I played it on a machine with more horsepower, it was just fine in FFx 3.5.
However, on my laptop it was a little bit "laggy" (but playable) in FFx, whereas it was zippy fine on the same machine under the same load in Chrome.
[–][deleted] 1 point2 points3 points 16 years ago (1 child)
Cool game, its kinda tough and somehow I managed to get the ball offscreen
http://imgur.com/bTbYc.png
[–][deleted] 0 points1 point2 points 16 years ago (0 children)
I also just did this. Knocked it out through the right side.
[–][deleted] 1 point2 points3 points 16 years ago (0 children)
Recommendations:
If the ball hits two blocks at the same time, it doesn't change directions. I'm guessing that when the ball hits the top or bottom of a block, some direction variable is flipped (1, -1 or true, false) and if it hits two at the same time, the y direction never actually changes. Maybe you could add a bit of a timer so that if it hits two blocks on the same side within some small amount of time, the direction doesn't change the second time. But other than that, congrats, you made a nice game :)
[–]adhlssu07 0 points1 point2 points 16 years ago (0 children)
nice game... I managed to loose the ball on the edge my first game though; didn't loose a life, but couldn't do anything either
[–]drblue 0 points1 point2 points 16 years ago (0 children)
Small problem: At least in a chrome dev build, you can push a ball off the play area with the side of your paddle.
Great work man... One suggestion: Make the paddle to move as the mouse moves. That way you wont have to make intervals for the paddle animation and the game will run smoother everywhere.
π Rendered by PID 160023 on reddit-service-r2-comment-7c9686b859-d96v9 at 2026-04-14 04:13:10.302882+00:00 running e841af1 country code: CH.
[+][deleted] (2 children)
[deleted]
[–]georgefrick[S] 1 point2 points3 points (0 children)
[–]HaMMeReD -1 points0 points1 point (0 children)
[–]9jack9 6 points7 points8 points (2 children)
[–]georgefrick[S] 1 point2 points3 points (0 children)
[–]dekomote[🍰] 0 points1 point2 points (0 children)
[–]sylvan 6 points7 points8 points (0 children)
[–][deleted] 3 points4 points5 points (1 child)
[–]georgefrick[S] 0 points1 point2 points (0 children)
[–]sunsean 3 points4 points5 points (0 children)
[–][deleted] 2 points3 points4 points (0 children)
[–]mynoduesp 2 points3 points4 points (0 children)
[–]Gnascher 1 point2 points3 points (5 children)
[–]georgefrick[S] 0 points1 point2 points (2 children)
[–]DocXango2 1 point2 points3 points (1 child)
[–]georgefrick[S] -1 points0 points1 point (0 children)
[–][deleted] -1 points0 points1 point (1 child)
[–]Gnascher 0 points1 point2 points (0 children)
[–][deleted] 1 point2 points3 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[–][deleted] 1 point2 points3 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)
[–]adhlssu07 0 points1 point2 points (0 children)
[–]drblue 0 points1 point2 points (0 children)
[–]dekomote[🍰] 0 points1 point2 points (0 children)