You are browsing as a guest. Sign up (or log in) to start making projects!

1h 9m 19s logged

We’ve got some movement!!


The Work So Far:
The paddles can now move! The left paddle is controlled using ‘W’ and ‘S’ and the right paddle is controlled using the ‘Up’ and ‘Down’ arrow keys. Originally, my basic movement functions only allowed for one paddle to move at a time, which was not ideal. The movement was also very choppy (moving about 15 pixels per key press). So, I made a dictionary of all the possible key presses (false means the key is not touched and true means its being held down), created press/release functions which change the value of the key presses in the dictionary accordingly, and added event listeners. These event listeners were .onkeypress and .onkeyrelease. They execute movement functions the moment a key is pressed/released (def pad_move(): if keys_pressed["w"]: y = pad_1.ycor() y += 5 pad_1.sety(y)). I used the function .ontimer to loop the movement function every 16 milliseconds, making the paddles move smoother.

I added boundaries to the window so the ball didn’t fly into oblivion. At one point, I accidentally made the balls too fast (literally saw them for a second and then they were gone). Lowkey want to incorporate that into one of the modes I’ll make in the future. There are also boundaries for the paddles so they don’t go too far off the screen. I did these through a bunch of compound conditionals (I love logic so much dude).


Next Course of Action:
Sometimes, when the ball moves across the screen, it slows down considerably and doesn’t speed back up until it collides with either the walls or the paddles. Thinking of making a function like I did with the paddles to see if it’ll fix it. Haven’t seen any other issues but that. Need to work on the point system and probably a start menu to choose the different modes.

0
5

Comments 0

No comments yet. Be the first!