Skip to content

Pirates Invasion game based on Eric Matthes tutorial in Python Crash Course

Notifications You must be signed in to change notification settings

operator-paramedyk/pirates_invasion

Repository files navigation

Pirates Invasion

by Janek SQ9NIL, www.operator-paramedyk.pl

Thanks @majki09 for your contribution!

Introduction

Pirates Invasion is a simple Space Invaders clone based on tutorial in Eric Matthes Python Crash Course: A Hands-On, Project-Based Introduction to Programming (2nd Edition by No Starch Press, Inc.). I followed his instructions when I started to learn Python and then made some changes:

  • changed topic from alien invasion to sea battle with pirates (my son loves them!) by adding graphics by myself,
  • added random distribution of pirates in the fleet,
  • improve graphics by flipping ships when they reach the boarder of the screen.

Gameplay

You are the captain of a ship fighting the pirates fleet that wants to enter the port. Your task is to shoot all pirates ships before they cross your position.

Screen that appears when you run the game.

To start the game, press Click to play button.

Use left and right arrows keys to move your ship left and right, and press spacebar to shoot the cannon. You can shoot three cannonballs at the same time.

You can quit the game by pressing q at any time.

Every time you shoot all the pirates ships, you progress to next level. This means that new pirates fleet, that is faster than the previous one, is generated, and you will get more points for every pirates ship shoot down.

if pirates ship collides with yours or reaches the bottom of the screen, you will loose one ship. Game ends if you loose three ships (by default).

Game settings

You can control the game with Settings class, stored in settings.py file. Below all of them are clarified, together with the default values.

Static settings

These are the settings that are set-up once for the whole game.

Screen settings

  • screen resolution: self.screen_width = 1200 and self.screen_height = 720

  • background color (seawater) self.bg_color = (0, 162, 232)

Ship settings

  • number of lives (presented in the top-left corner of the screen): self.ships_limit = 3

Bullet settings

  • cannonball dimensions: self.bullet_width = 10 and self.bullet_height = 10

  • cannonball color: self.bullet_color = (105, 105, 105)

  • number of cannonballs that can be shoot at the same time (it wasn't so easy to load the cannon): self.bullets_allowed = 3

Pirate settings

  • pirates fleet vertical speed: self.fleet_drop_speed = 20

  • probability (set as a value between 1 and 10) that position in pirates fleet is filled with a ship during fleet creation: self.pirate_probability = 8

Level increase settings

  • factor to increase fleet horizontal speed when the level changes: self.speedup_scale = 1.1

  • factor to increase the score per pirates ship shoot down with the level change: self.speedup_score = 1.5

Speed

  • horizontal speed of player's ship: self.ship_speed = 2

  • vertical speed of player's bullets (negative as they are moving upwards): self.bullet_speed = 2

Dynamic settings

These settings will change during the gameplay.

Speed

  • horizontal speed of pirates ships: self.pirate_speed = 0.75
Fleet direction: 1 - right, -1 - left
  • fleet's direction (changes when fleet reaches screen's boarder): self.fleet_direction = 1

Points for shooting a pirate

  • initial points value for a pirate ship shoot down: self.pirate_points = 20

About

Pirates Invasion game based on Eric Matthes tutorial in Python Crash Course

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages