How to Code Realistic Physics in Python Games! PyGame Tutorial (Gravity, Bounce, Throw, Friction)

preview_player
Показать описание
In this video I show you how to use a number of realistic physics features in your python code and PyGame games! By creating a ball class with easy to change parameters we are able to see how modifying these various parameters can impact our object's movements!

Having realistic bouncing as well as friction and collision and the ability to throw objects with realistic physics is a great way to make your game feel very real and understanding the code behind it is a great way to get better at both python code in general and creating games with the PyGame module!

The code shown in this video is available here:

Check out my personal channel here!
@peterlemaster8310

Consider becoming a super supporter at the link below:

Don't forget to leave a like on the video, subscribe to the channel and leave a comment letting me know what you'd like to see more of in the future!

TIMESTAMPS:
00:00 Intro and Project Description. Physics in Pygame!
03:01 Setting up the PyGame framework
06:15 Draw Outer Walls for the Game
09:49 Setting up a Class in python for Balls
17:24 Applying Gravity to Python Objects with Pygame
20:05 Making Pygame Objects Bounce on Floor Collision
28:40 Selecting a Python Object and getting it to follow the Mouse!
36:40 Releasing and Throwing Objects with the Mouse in Pygame!
43:20 Handle Pygame Object Collision with Walls and Apply Friction!
50:54 Summary, Outro and Showcase! Thanks!
Рекомендации по теме
Комментарии
Автор

This is one of the YouTube channel that needs attention guys please share as much as possible. This man is really incredible and awesome. I've seen many youtubers but I never felt attracted towards their teaching than I did with le master tech channel. There is something magical about this channel. So I hope people who see my comment would definitely hit the link share and subscribe button

physicsinveins
Автор

ive recently been wanting to make some physics stuff but i didnt know where to start, this is very helpful thanks

bgsand
Автор

Good stuff, I really like how you broke everything down with the code and explained it.

MichaelGarcia-cgon
Автор

You deserve a lot more views for this work my friend. Five stars. Thank you!

DrBFromEarth
Автор

fun coding along on this project. One thing I noticed and not sure how this can be corrected, but when one ball is on top of another ball, when you select one, it selects both.

mjrober
Автор

Thank you! This helped me with a project I had wanted to make!

yigawaffle
Автор

Hey, amazing and informative video, I've been searching for something this good for quite some time now. I appreciate u learning it to other people, it's really helpful. I've watched this video all the way thru and prob spendt about 2 hours doing, understanding and learning from u. this is not the first video I've seen of u, amazing work all the way thru!. I see ur almost at 10k subs, and I subbed, so now ur 1 step closer and I would love to be on this journey with u. I got a question, would u mind maybe showing how to make some type of rocket that starts on the ground level, where it takes of and flies up in the air with fuel, and when the fuel runs out it goes back to the ground with the gravity we made. like maybe make it realistic. maybe put in gravity, air-resistance, and so on. thank u so much for all ur help!

joachimandresaldano-sle
Автор

Please do more classic games like pac-man, and kindly make the screen size adjustable depending on screen size. That would be awesome amigo!

loagengmaki
Автор

bro would deifntley like to look at the cocnservetion if momentum and conservatuon of energy

pqb
Автор

hi, i was also wondering on how to make the balls collide with each other, obvi with physics in the collition between the balls aswell.
and not to take to much of ur time, but I am quite new to programming, in school we had to chose a project to work with, and now I have chosen to make a "pool" game, but I do need real physics and I was wondering if u could try and make something similar to a pool game which can help and guide me and getting better at programming.

joachimandresaldano-sle
Автор

If I wanted to make a new ball on a button press, and eventually would end up with like 200 balls, do I need to write "button200.update() etc" for each one by hand? Thanks. Really helpful vid btw👍

elliottsmith
Автор

Hey, thanks for the video! Very informative! I do have a question. I'm working on a platformer (using a coding style similar to @CodingwithRuss), and I want to add a ball for the player to push around. I, now, want the ball to roll if it gets too close to an edge of a ground tile. Is there a way to implement this (preferably without drastically changing too much code)?

StormwreckerOfficial
Автор

My balls list is a left/right boolean.

ClassicCase
Автор

How did you grow a moustache like that? (not praising)

Texturedcake
visit shbcf.ru