Skip to content

Different Python graphics stuff. Fun to watch and mess with.

Notifications You must be signed in to change notification settings

KD5VMF/CHAT-GPT4-3D-Fun

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CHAT-GPT4-3D-Fun

This program simulates a dynamic environment where a specified number of cubes, balls, and triangles interact with each other and bounce off the edges of the screen. It uses the Pygame library for rendering graphics and the Pymunk library for handling physics. The unique aspect of this program is how it changes the shapes and colors of the objects upon collision, giving a fascinating visual effect.

In more detail:

  • The configuration allows customization of various aspects such as color of the objects, gravity, object speed, size, and number, mass of the cubes, elasticity, friction, screen size, frame rate, etc.
  • The Cube class is an object-oriented representation of the objects on the screen. Despite its name, it can represent a cube, a ball, or a triangle. It contains data about the object, such as its size, color, and shape type, and methods for its functionality, such as draw.
  • The handle_collision function changes the color and shape type of the objects upon collision. A green object changes to white, and vice versa. The shape cycles through cube, triangle, and ball.
  • The main function is the driver function of the program. It initializes Pygame and Pymunk, creates the objects, adds them to the space, and handles the game loop. It also finds the slowest moving object at each frame and changes its color to red.
  • The objects move in the space with a speed in a random direction, and they bounce off the edges of the screen. When a collision between two objects occurs, their colors and shapes change. The slowest moving object at any frame is always colored red.
  • The program renders the scene at each frame, displaying the objects and the count of objects of each color at the top-left corner of the screen.

This code demonstrates how to use Pygame and Pymunk to create a dynamic environment with objects interacting with each other and their environment. It provides a visually engaging way to understand the basic principles of physics and object-oriented programming. It's perfect for those looking to delve into the world of game development or simulation creation.

About

Different Python graphics stuff. Fun to watch and mess with.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages