... seams pygame team development works and released a new version, see the GitHub project.
pygame-catalin
windows,linux, tutorials, tutorial, pygame, ,development,programming,source code,code,example,examples,All with pygame python module. The pygame-catalin is a blog created by Catalin George Festila.
marți, 23 septembrie 2025
sâmbătă, 19 octombrie 2024
PyGame : 5by5 linux game project - part 001.
The game is about your brain skills to hack the code based on minimal information versus total information.
The code has 5 distinct letters.
- click on the letters on the keypad
- the number of guessed letters is displayed in the form: centered - guessed letters on positions and moved guessed letters but on other positions
I used agentpy python module and pygame python module
The game can be found on my fedora pagure account.

sâmbătă, 21 septembrie 2024
PyGame : 8in8 linux game project - part 001.
I started a game project with the python packages pygame and agentpy in the Fedora Linux distribution.
You can find it on my fedora pagure repo
duminică, 16 iunie 2024
PyGame : Game development in PyGame: making a basic map.
Example with PyGame with 3D features ...
The project can be found on the GitHub repo - stage 11 ...
sâmbătă, 30 martie 2024
PyGame : ... antialiased filled circle !
The pygame python module does not implement an antialiased filled circle and this is the scope of this tutorial.
The pygame module for drawing shapes are:
- pygame.draw.rect - to draw a rectangle
- pygame.draw.polygon - to draw a polygon
- pygame.draw.circle - to draw a circle
- pygame.draw.ellipse - to draw an ellipse
- pygame.draw.arc - to draw an elliptical arc
- pygame.draw.line - to draw a straight line
- pygame.draw.lines - to draw multiple contiguous straight line segments
- pygame.draw.aaline - to draw a straight antialiased line
- pygame.draw.aalines - to draw multiple contiguous straight antialiased line segments.
Let's install pygame python module.
pip install pygame
Collecting pygame
Downloading pygame-2.5.2-cp312-cp312-win_amd64.whl.metadata (13 kB)
...
Installing collected packages: pygame
Successfully installed pygame-2.5.2
Let's see the source code:
import pygame
import pygame.gfxdraw
TARGET_SIZE = 200
BG_ALPHA_COLOR = (0, 0, 0, 100)
class Target(pygame.sprite.Sprite):
def __init__(self):
super().__init__()
self.image = pygame.Surface((TARGET_SIZE, TARGET_SIZE), pygame.SRCALPHA)
self.rect = self.image.get_rect()
self.color = (255, 0, 0)
self.filled = False
self.width = 1
def DrawTarget(self):
pygame.gfxdraw.aacircle(self.image, int(self.rect.width/2), int(self.rect.height/2),\
int(self.rect.width/2 - 1), self.color)
pygame.gfxdraw.filled_ellipse(self.image, int(self.rect.width/2), \
int(self.rect.height/2), int(self.rect.width/2 - 1), int(self.rect.width/2 - 1), self.color)
temp = pygame.Surface((TARGET_SIZE, TARGET_SIZE), pygame.SRCALPHA)
if not self.filled:
pygame.gfxdraw.filled_ellipse(temp, int(self.rect.width/2), int(self.rect.height/2), \
int(self.rect.width/2 - self.width), int(self.rect.width/2 - self.width), BG_ALPHA_COLOR)
pygame.gfxdraw.aacircle(temp, int(self.rect.width/2), int(self.rect.height/2), \
int(self.rect.width/2 - self.width), BG_ALPHA_COLOR)
self.image.blit(temp, (0, 0), None, pygame.BLEND_ADD)
pygame.init()
screen = pygame.display.set_mode((400, 400))
target = Target()
target.DrawTarget()
running = True
while running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
screen.fill((255, 255, 255))
screen.blit(target.image, (100, 100))
pygame.display.flip()
pygame.quit()luni, 10 iulie 2023
News : About my work and one of my websites.
I would like to bring to the attention of those who follow my activity on my websites and appreciate the inability to continue with one of the websites: free-tutorials.org. It is currently hosted on a free host, but I cannot import it 100%, which has led me not to complete it with new posts. The continuation of the activities there, considering the limited time, will be carried out on my blogs with the defined theme with which I started: Linux - Fedora, Graphics, Python, Pygame.
In the meantime, because the host is expensive and until now someone has helped me to host it on his server, it is possible to sell the domain: free-tutorials.org - I receive purchase offers at my personal Yahoo email address catafest@yahoo.com.
Minimum starting price 250 euros, because the domain is old from 2018.
sâmbătă, 8 aprilie 2023
PyGame : ovoid with a random pattern.
Here's how to create an ovoid with a random pattern. Run the script several times to see the differences:
import pygame
import random
pygame.init()
# Set up the display window
screen_size = (400, 400)
screen = pygame.display.set_mode(screen_size)
# Set window title
pygame.display.set_caption("Ovoid with Random Pattern")
# Define the ovoid
ovoid_pos = (150, 100)
ovoid_size = (100, 200)
# Create the ovoid surface
ovoid_surface = pygame.Surface(ovoid_size, pygame.SRCALPHA)
# Define the pattern
pattern_size = (random.randint(1, 9), random.randint(1, 9))
pattern_surface = pygame.Surface(pattern_size)
pattern_surface.fill((255, 255, 255))
pygame.draw.line(pattern_surface, (0, 0, 0), (0, 0), pattern_size)
# Create the mask surface
mask_surface = pygame.Surface(ovoid_size, pygame.SRCALPHA)
pygame.draw.ellipse(mask_surface, (255, 255, 255), mask_surface.get_rect(), 0)
# Apply the pattern to the ovoid surface
for x in range(0, ovoid_size[0], pattern_size[0]):
for y in range(0, ovoid_size[1], pattern_size[1]):
ovoid_surface.blit(pattern_surface, (x, y))
# Apply the mask to the ovoid surface
ovoid_surface.blit(mask_surface, (0, 0), special_flags=pygame.BLEND_RGBA_MULT)
# Draw the ovoid to the screen
screen.blit(ovoid_surface, ovoid_pos)
# Update the display
pygame.display.flip()
# Wait for the user to close the window
done = False
while not done:
for event in pygame.event.get():
if event.type == pygame.QUIT:
done = True
# Quit pygame properly
pygame.quit()
Posted by
Cătălin George Feștilă
Labels:
2023,
module,
modules,
pygame,
python 3,
python 3.11,
python module,
python package,
tutorial,
tutorials
vineri, 3 martie 2023
PyGame : simple web camera !
In this simple tutorial, I'll show you how to use pygame to use it with a webcam.
Let's install the pygame with the pip tool:
C:\PythonProjects\pygamecamera001>pip install pygame --user
Collecting pygame
Downloading pygame-2.2.0-cp311-cp311-win_amd64.whl (10.4 MB)
---------------------------------------- 10.4/10.4 MB 9.0 MB/s eta 0:00:00
Installing collected packages: pygame
Successfully installed pygame-2.2.0This is the source code for web camera:
import pygame.camera
import pygame.image
import sys
pygame.camera.init()
cameras = pygame.camera.list_cameras()
webcam = pygame.camera.Camera(cameras[0])
webcam.start()
img = webcam.get_image()
WIDTH = img.get_width()
HEIGHT = img.get_height()
screen = pygame.display.set_mode( ( WIDTH, HEIGHT ) )
pygame.display.set_caption("pyGame webcam")
while True :
for e in pygame.event.get() :
if e.type == pygame.QUIT :
sys.exit()
screen.blit(img, (0,0))
pygame.display.flip()
img = webcam.get_image()
Posted by
Cătălin George Feștilă
Labels:
2023,
pygame,
python,
python 3,
python 3.11,
python module,
python package,
tutorial,
tutorials
luni, 2 ianuarie 2023
PyGame : simple digital clock.
This is the source code I used and is very simple.
import pygame
import time
# init the Pygame
pygame.init()
# this set the window size
window_size = (640, 100)
# this create the window
screen = pygame.display.set_mode(window_size)
# this set the title of the window
pygame.display.set_caption("Digital Clock")
# this fill the background color to white
screen.fill((255, 255, 255))
# settings for the font and size
font = pygame.font.Font(None, 36)
# the game loop area
running = True
while running:
# use an event to quit
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
# get the current time
current_time = time.strftime("%H:%M:%S")
# render the time as text
text = font.render(current_time, True, (0, 0, 0))
# clear the screen
screen.fill((255, 255, 255))
# draw the text on the screen
screen.blit(text, (10, 10))
# update the screen
pygame.display.flip()
# quit Pygame application
pygame.quit()
The result of the running source code is this:

Posted by
Cătălin George Feștilă
Labels:
2022,
clock,
pygame,
python,
python 3,
python 3.9,
python module,
python package,
tutorial,
tutorials
joi, 22 decembrie 2022
News : pygame-menu version 4.3.2.
This python package let you to use a menu for pygame.
You can find it on this webpage and documentation on this webpage.
This is simple to use it:
You can install easy like any python package using the pip3 python tool:
pip3 install pygame-menu==4.3.2 --userI created a python file named pygame-menu_001.py and I add this simple example to test it:
import pygame
import pygame_menu
from pygame_menu import Theme
pygame.init()
surface = pygame.display.set_mode((640, 480))
def set_difficulty(value, difficulty):
# Do the job here !
pass
def start_the_game():
# Do the job here !
pass
mytheme = pygame_menu.themes.THEME_BLUE.copy()
mytheme.title_background_color=(0, 19, 76)
mytheme = Theme(widget_font=pygame_menu.font.FONT_FRANCHISE)
menu = pygame_menu.Menu('Main menu', 400, 300,
theme=mytheme)
menu.add.text_input('User :', default='catafest')
menu.add.selector('Difficulty :', [('Hard', 1), ('Easy', 2)], onchange=set_difficulty)
menu.add.button('Play', start_the_game)
menu.add.button('Quit', pygame_menu.events.EXIT)
menu.mainloop(surface)This is the result of the running script:

marți, 22 februarie 2022
PyGame : Testing Pygame GUI - part 03.
In this article tutorial I show you how can create a progressbar and set it with value 76.
This example looks like this:
The source code is not very complicated and is very readable for any developer with minimal knowledge in the programming area.
import pygame
import pygame_gui
pygame.init()
pygame.display.set_caption('Quick Start')
window_surface = pygame.display.set_mode((640, 480))
background = pygame.Surface((640, 480))
background.fill(pygame.Color('#0076AB'))
manager = pygame_gui.UIManager((640, 480))
print(dir(pygame_gui.elements.UIProgressBar))
myProgressBar = pygame_gui.elements.UIProgressBar(relative_rect=pygame.Rect((50, 100), (300, 40)),
visible= 1,
manager=manager)
myProgressBar.set_current_progress(76)
clock = pygame.time.Clock()
is_running = True
while is_running:
time_delta = clock.tick(60)/1000.0
for event in pygame.event.get():
if event.type == pygame.QUIT:
is_running = False
if event.type == pygame_gui.UI_BUTTON_PRESSED:
if event.ui_element == hello_button:
print('Hello World!')
manager.process_events(event)
manager.update(time_delta)
window_surface.blit(background, (0, 0))
manager.draw_ui(window_surface)
pygame.display.update()
Posted by
Cătălin George Feștilă
Labels:
2022,
pygame,
pygame_gui,
python,
python 3,
python 3.9,
python module,
python package,
tutorial,
tutorials
duminică, 20 februarie 2022
PyGame : Testing Pygame GUI - part 02.
I repeat, Pygame GUI is a module to help you make graphical user interfaces for games written in pygame.
In this short tutorial I will show you a source code that creates a HealthBar.
This example looks like this:
The source code is not very complicated and is very readable.
import pygame
import pygame_gui
pygame.init()
pygame.display.set_caption('Quick Start')
window_surface = pygame.display.set_mode((640, 480))
background = pygame.Surface((640, 480))
background.fill(pygame.Color('#0076AB'))
manager = pygame_gui.UIManager((640, 480))
HealthBar = pygame_gui.elements.UIScreenSpaceHealthBar(relative_rect=pygame.Rect((50, 100), (300, 40)),
visible= 1,
manager=manager)
clock = pygame.time.Clock()
is_running = True
while is_running:
time_delta = clock.tick(60)/1000.0
for event in pygame.event.get():
if event.type == pygame.QUIT:
is_running = False
if event.type == pygame_gui.UI_BUTTON_PRESSED:
if event.ui_element == hello_button:
print('Hello World!')
manager.process_events(event)
manager.update(time_delta)
window_surface.blit(background, (0, 0))
manager.draw_ui(window_surface)
pygame.display.update()
Posted by
Cătălin George Feștilă
Labels:
2022,
pygame,
pygame_gui,
python,
python 3,
python 3.9,
python module,
python package,
tutorial,
tutorials
vineri, 11 februarie 2022
PyGame : Testing Pygame GUI - part 01.
Pygame GUI is a module to help you make graphical user interfaces for games written in pygame.
The module is firmly forward-looking and is designed to work on Pygame 2 and Python 3.
You can read more about these features for this python package on the official website.
This is a simple interface with python and python pygame and pygame_gui python packages.
You can see a simple example on my GitHub account.
Posted by
Cătălin George Feștilă
Labels:
2022,
pygame,
pygame_gui,
python,
python 3,
python 3.9,
python module,
python package,
tutorial,
tutorials
Abonați-vă la:
Comentarii (Atom)
