MXVK Vulkan Framework 0.35.0
C++20 Vulkan rendering framework for practical 2D and 3D application development with SDL3.
Loading...
Searching...
No Matches
asteroids.py File Reference

Interactive MXVK Asteroids game implemented in Python. More...

Go to the source code of this file.

Classes

class  asteroids.Asteroid
class  asteroids.AsteroidsWindow
class  asteroids.Particle
class  asteroids.Projectile
class  asteroids.Ship
class  asteroids.Star

Namespaces

namespace  asteroids

Functions

None asteroids.main ()
argparse.Namespace asteroids.parse_args ()

Variables

int asteroids.ASTEROID_VERTICES = 8
str asteroids.DATA_DIR = EXAMPLE_DIR / "data"
 asteroids.EXAMPLE_DIR = Path(__file__).resolve().parent
int asteroids.EXPLOSION_DURATION = 90
int asteroids.FIRE_COOLDOWN = 5
int asteroids.FIRE_DELAY = 3
int asteroids.GAME_H = 360
int asteroids.GAME_W = 640
int asteroids.LARGE_ASTEROID_POINTS = 20
int asteroids.MAX_ASTEROIDS = 30
int asteroids.MAX_PARTICLES = 40
int asteroids.MAX_PROJECTILES = 50
int asteroids.MEDIUM_ASTEROID_POINTS = 50
float asteroids.MIN_ASTEROID_RADIUS = 8.0
int asteroids.PROJECTILE_LIFETIME = 60
float asteroids.PROJECTILE_SPEED = 5.0
int asteroids.SHOTS_PER_BURST = 5
int asteroids.SMALL_ASTEROID_POINTS = 100
int asteroids.STAR_COUNT = 800
float asteroids.TARGET_FRAME_TIME = 1.0 / 60.0

Detailed Description

Interactive MXVK Asteroids game implemented in Python.

Demonstrates a Python VK_Window subclass, NumPy-backed sprite rendering, keyboard input, particles, collision handling, and a fixed-step arcade game loop. The game renders to a 640-by-360 logical canvas before it is scaled to the current swapchain extent.

Running the example

python3 python-examples/asteroids/asteroids.py --width 1280 --height 720 --vsync

Controls

  • Left/Right: rotate the ship.
  • Up: thrust.
  • Space: fire; after game over, start a new game.
  • Escape: exit.

Design notes

AsteroidsWindow owns gameplay state, while the Ship, Projectile, Asteroid, and Particle data classes remain renderer-independent. NumPy supplies the dynamic pixel buffers uploaded to the MXVK sprites each frame.

Definition in file asteroids.py.