I need help to make pong since im still kinda new

this is a school assignment that im failing i rlly need ur guys help

https://replit.com/@sanstheskeleton22/NauticalEarnestSpellchecker#main.py

Hi, @JackKayser1 I really don’t think you should be posting your school assignment tasks to this forum. It’s not right to expect others to do the work for you and your tutor will not understand how to help you if you are submitting work from someone else.

Please feel free to post questions that will help you understand the building blocks of programs, but don’t post tasks again.

2 Likes

i dont have a tutor sadly

sorry for posting this

i need help with my collision tho and to make a ball

can you guys give me suggestions

im using pygame and its really hard to make this

please tell me how to make a ping pong ball

As this is a school assignment, we can only point you in the right direction.

The generic function to detect rectangle collisions goes like this (rough pseudocode):

boolean rectangleCollision(rectangle1, rectangle2) {
    if (rectangle1 x-coordinate < rectangle2 x-coordinate + rectangle2 width and
        rectangle1 x-coordinate + rectangle1 width > rectangle2 x-coordinate and
        rectangle1 y-coordinate < rectangle2 y-coordinate + rectangle2 height and
        rectangle1 height + rectangle1 y-coordinate > rectangle2 y-coordinate) {
        return true; // collision
    } else {
        return false; // no collision
    }
}

For simple collisions, you first want to check if a collision is detected using that formula and the dimensions of the paddles and the ball. If there’s a collision, you want to find out how far the ball overlaps the paddle on each axis (x and y), then on whichever axis has the least overlap, move the ball based on that overlap.

1 Like

This topic was automatically closed 6 hours after the last reply. New replies are no longer allowed.