I broke my own source code - Pong

6 posts

Flag Post

Guys, this is the first time I’m posting here on Kongregate (Hello :D).

Today I’ve been working on a personal project, I made a simple pong game, which worked just fine as you can test on (http://skyxer.com/swf/pong.swf).

The problem is that I do not know what I did, when I tried to implement the score (I couldn’t get text fields updating properly,after a bit I did get it to work so I saved it) but after saving and debuging the new SWF file, the colisions are all messed up (the result is here http://skyxer.com/swf/pong2.swf).

If you want to check my latest (buggy) source code, do it so here (http://pastebin.com/GCR53zu2).

Thank you in advance, I can’t figure out what I did, because it was working 20 minutes ago just fine!

 
Flag Post

Why are you using multiple frames?
Also, are you using CS? Timeline code?

Maybe you have some code other than what you posted; I can’t think of another reason.

Also, on a different note, the vertical bouncing is glitchy; you have to update the ball’s position after multiplying it’s speed, or it stays trapped next to the top or bottom.

 
Flag Post

It seems if you right click the while the SWF file is playing and you press “Forward” the game will resume and play normally, and it wont occur again!
My mind is blown… no idea what happened here!

 
Flag Post
Originally posted by Skyxer:

It seems if you right click the while the SWF file is playing and you press “Forward” the game will resume and play normally, and it wont occur again!
My mind is blown… no idea what happened here!

This is what is happening in your case:

If ball.x is >= than 290 you multiply speed by -1, but as my experience shows as3 is not very precise, your ball.x goes to 291 then you multiply speed by -1 then it goes to 290 then you multiply it again, then 291, then 290….

Instead of multiplyng speed, try changing it like:

(loop)

ball.x += ballSpeedX;


if(ball.x >= 290)
{
   ballSpeedX = -3;
}
if(ball.x <= 0)
{
   ballSpeedX = 3;
}

 
Flag Post

ballSpeedX=-ballSpeedX might help/work?

 
Flag Post

To explain the game resuming when you press forward: on initiation of the level, you create some variables, and assign a value to them. When your game is stuck, and you reopen that frame, it initiates it, which runs your initiation code. This will reset the ballspeed.