Skip to content

Pygame Quickstarter

KA Xplorer codes edited this page Jan 29, 2026 · 1 revision

Start quick on Pygame

Screen Using easycode-infinite

import easycode as ec
import pygame

# Initialize
pygame.init()
screen = pygame.display.set_mode((800, 600))
clock = pygame.time.Clock()

# 1. Setup Features
shaker = ec.PygameScreenShake()# Start quick on Pygame
## Screen Using easycode-infinite
```python
import easycode as ec
import pygame

# Initialize
pygame.init()
screen = pygame.display.set_mode((800, 600))
clock = pygame.time.Clock()

# 1. Setup Features
shaker = ec.PygameScreenShake()
# x, y, width_per_1hp, max_health, current_health, bar_height, border_color, health_color
hp_bar = ec.PygameHealthBar(50, 50, 2, 100, 100, 20, (255, 255, 255), (0, 255, 0))

# 2. Use your ec.pg_group shortcut
all_sprites = ec.pg_group()
all_sprites.add(hp_bar)

current_hp = 100
running = True
while running:
    screen.fill((30, 30, 30))
    offset = shaker.shake()

    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            running = False
        
        if event.type == pygame.MOUSEBUTTONDOWN:
            shaker.shake(intensity=15, duration=20)
            current_hp -= 10
            hp_bar.update_hp(current_hp) # The "Easy" way to refresh the bar

    # 3. Draw the Game
    pygame.draw.circle(screen, (255, 0, 0), (400 + offset.x, 300 + offset.y), 50)
    
    # 4. Draw all Sprites
    all_sprites.draw(screen)
    
    pygame.display.flip()
    clock.tick(60)

pygame.quit()

Start with everything imported as shortcuts and sys

import easycode as ec
import pygame as pg
import sys

pg.init()
screen = pg.display.set_mode((800, 600))
clock = pg.time.Clock()

running = True
while running:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            running = False

    
    pg.display.flip()
    clock.tick(60)
pg.quit()
sys.exit()

Start with normal imports

import easycode as ec
import pygame as pg

pg.init()
screen = pg.display.set_mode((800, 600))
clock = pg.time.Clock()

running = True
while running:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            running = False

    
    pygame.display.flip()
    clock.tick(60)
pg.quit()
# x, y, width_per_1hp, max_health, current_health, bar_height, border_color, health_color
hp_bar = ec.PygameHealthBar(50, 50, 2, 100, 100, 20, (255, 255, 255), (0, 255, 0))

# 2. Use your ec.pg_group shortcut
all_sprites = ec.pg_group()
all_sprites.add(hp_bar)

current_hp = 100
running = True
while running:
    screen.fill((30, 30, 30))
    offset = shaker.shake()

    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            running = False
        
        if event.type == pygame.MOUSEBUTTONDOWN:
            shaker.shake(intensity=15, duration=20)
            current_hp -= 10
            hp_bar.update_hp(current_hp) # The "Easy" way to refresh the bar

    # 3. Draw the Game
    pygame.draw.circle(screen, (255, 0, 0), (400 + offset.x, 300 + offset.y), 50)
    
    # 4. Draw all Sprites
    all_sprites.draw(screen)
    
    pygame.display.flip()
    clock.tick(60)

pygame.quit()

Start with everything imported as shortcuts and sys

import easycode as ec
import pygame as pg
import sys

pg.init()
screen = pg.display.set_mode((800, 600))
clock = pg.time.Clock()

running = True
while running:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            running = False

    
    pg.display.flip()
    clock.tick(60)
pg.quit()
sys.exit()

Start with normal imports

import easycode as ec
import pygame as pg

pg.init()
screen = pg.display.set_mode((800, 600))
clock = pg.time.Clock()

running = True
while running:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            running = False

    
    pygame.display.flip()
    clock.tick(60)
pg.quit()

Clone this wiki locally