Code Monkey home page Code Monkey logo

pirates_invasion's Introduction

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.