Space Invaders in Python
Overview
This project implements a version of the classic Space Invaders video game using Python, with a graphical interface built on Tkinter and additional libraries for image processing, sound, and keyboard input.
The game includes both a single-player mode and a local multiplayer mode, following the traditional mechanics of horizontal movement, projectile shooting, enemy elimination, defensive barricades, and level progression.
The code combines object-oriented programming, real-time animation, event handling, and graphical rendering, making it a complete example of a 2D arcade-style game developed in Python.
Main Features
- Graphical interface built with Tkinter
- Sound effects handled with pygame
- Image loading and resizing using Pillow (PIL)
- Keyboard input management through the keyboard library
- Single-player mode
- Local multiplayer mode
- Progressive level system
- Enemies with randomized shooting behavior
- Destructible barricades with visual damage
- Start menu, transition screen, and game-over menu
- Custom mouse cursor inside the game
- Animated scrolling background
Project Structure
The program is organized around several classes that represent the main elements of the game.
Figura
Abstract base class used as a template for all graphical game objects.
It defines common attributes such as:
- canvas
- position
- velocity
- width and height
- image path
It also provides basic methods for loading images, moving objects, and deleting them from the canvas.
Nau
Represents the player spaceship.
Main responsibilities:
- horizontal movement
- life management
- collision detection with enemy bullets
Bala
Represents a projectile fired either by the player or by an enemy.
Main responsibilities: