For the Glory and Honor, we bring you; The First Even Open Source Coding Challenge!
This challenge's theme is Pong and is due January 16th, 2009.
THE DISCUSSION Are you having any problems writing your code? Ask for help here before submitting your final project.
Was there anything you liked or would like to point out about your own or someone else's code?
Who do you think deserves to win so far, and why?
Do not post any of this information in the Submissions thread! Instead, post here. Non developers are more than welcome to join in the discussion.
JUDGING Players may judge even if they submitted a game, and even if they are not programmers. Please keep an open mind, and to not be too overly obsessed with your own code to accept anyone else's success.
Unless no agreement can be made, there is no official voting. Instead, the winner will be selected based on a general consensus. The real discussion will be done on the 17th and 18th (but feel free to post your opinions before that), and a winner will be selected on the 19th.
OTHER CONCERNS Also, should we allow developers to submit more than one game, since there are perhaps not very many developers?
Also, can anyone get ahold of some experienced developers who would be willing to join in the challenge?
I will be setting up an official site somewhere where you can view all submitted content from past challenges which you can learn from.
I can get you somewhere to host if you need it. The best way to get more developers is going to be by publicity. Maybe some nice prizes will boost their willingness.
thought I'd show my progress so far, but this time without the source code, in the interests of healthy competition. Don't worry, come the deadline, all will be revealed!
So now I have the ball bouncing around. Check it out here:
Send some sample code, and I can try to help you out with it. Don't worry, I won't steal your code. I am trying to avoid using hitTest as much as possible.
The problem is that sometimes the ball will be moving faster than the width of your paddles. So on one frame the ball is to the left of the paddle, but on the next frame it is on the right of the paddle. This means no collision is detected.
You need to do a sweep test. That is, you check the position of the ball before and after moving, to see if it went through the paddle during the frame. It can be a bit tricky. In the interests of keeping this fun, shall I put up some code to help with collision detection? Or should I wait until submission time?
Ok guys, I've got the collision more or less working. it's a bit messy, but at least it works...
I'm using my Vector2D class (you can see it on my blog here) to define the velocity of both the ball and the paddles. This is the function for detecting collision between the ball and a paddle:
public function checkPaddleCollision(paddle:Paddle) { var hitHorizontal:Boolean = false; var hitVertical:Boolean = false; var fromHorizontal:Boolean = false; var fromVertical:Boolean = false; //trace("collision" //calculate the previous positions of ball and paddle var paddlePrevX:Number = paddle.x - paddle.velocity.x; var paddlePrevY:Number = paddle.y - paddle.velocity.y; var relativeVelocity:Vector2D = new Vector2D(); relativeVelocity.x = x - prevX - paddle.velocity.x; relativeVelocity.y = y - prevY - paddle.velocity.y; //SWEEP TESTS: //check horizontal if(relativeVelocity.x < 0) { //ball coming from right, so check with right hand side of paddle if(prevX - ballRadius >= paddlePrevX + paddle.paddleWidth && x - ballRadius <= paddle.x + paddle.paddleWidth) { hitHorizontal = true; fromHorizontal = true; } } if(relativeVelocity.x > 0) { //ball coming from left, so check with right hand side of paddle if(prevX + ballRadius <= paddlePrevX && x + ballRadius >= paddle.x) { hitHorizontal = true; fromHorizontal = true; } } //check vertical if(relativeVelocity.y < 0) { //ball coming from below, so check with bottom of paddle if(prevY - ballRadius >= paddlePrevY + paddle.paddleHeight && y - ballRadius <= paddle.y + paddle.paddleHeight) { hitVertical = true; fromVertical = true; } } if(relativeVelocity.y > 0) { //ball coming from above, so check with top of paddle if(prevY + ballRadius <= paddlePrevY && y + ballRadius >= paddle.y) { hitVertical = true; fromVertical = true; } } //BASIC TESTS: if(x - ballRadius <= paddle.x + paddle.paddleWidth && x + ballRadius >= paddle.x) hitHorizontal = true; if(y - ballRadius <= paddle.y + paddle.paddleHeight && y + ballRadius >= paddle.y) hitVertical = true; if(hitHorizontal && hitVertical) //collision has occurred { if (fromHorizontal) { relativeVelocity.x < 0 ? x = paddle.x + paddle.paddleWidth + ballRadius : x = paddle.x - ballRadius; velocity.x *= -1; if(Math.abs(velocity.x) < Math.abs(paddle.velocity.x)) velocity.x = paddle.velocity.x * 1.4; else velocity.x += paddle.velocity.x/8; velocity.y += paddle.velocity.y/((Math.random() + 1) * 3); } if (fromVertical) { relativeVelocity.y < 0 ? y = paddle.y + paddle.paddleHeight + ballRadius : y = paddle.y - ballRadius; velocity.y *= -1; if(Math.abs(velocity.y) < Math.abs(paddle.velocity.y)) velocity.y = paddle.velocity.y * 1.4; else velocity.y += paddle.velocity.y/8; velocity.x += paddle.velocity.x/((Math.random() + 1) * 3); } } }