Skip to content

A single-player 2D game based on the Pygame library.

Notifications You must be signed in to change notification settings

Intenzo21/mars-lander

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Mars Lander 2D

A single-player game based on the Pygame library.

Introduction

The Python Pygame package is an open source library for making multimedia applications and games. It is built on top of the excellent SDL library, and like that library, it is highly portable and runs on nearly every platform and operating system. Pygame, is excellent for reproducing classic arcade games from the 1970s and 80s, and it has been used to recreate Pong, Pacman, Snake, Defender, and Asteroids amongst many others.

Background

One of the first arcade games to be based on a real space mission and using pseudo-realistic physics was Lunar Lander (Atari, 1979). In the game, players control a space vehicle as it makes its approach to the surface of the moon. By pressing various keyboard keys, the vehicle can be rotated right or left, or the main rocket engine fired (to decelerate the vehicle). Fuel is limited, so the player has to carefully manage the use of the main engine. Points are scored by landing on various landing zones, but the vehicle must have horizontal and vertical velocity below certain acceptable limits or it is destroyed. Similarly, attempting to land outside a landing zone results in a crash. A successful landing triggers an award of points, and a new landing mission (with landing zones in new, random locations).

Motivation

This mini-project was all about creating an updated version of one of the first arcade games to be based on a real space mission and using pseudo-realistic physics. It is called Lunar Lander by Atari and was launched back in 1979. Mars Lander game was designed and built using the Python Pygame package which is an open-source library for making multimedia applications and games. It was pretty challenging and required to bring all the knowledge and skills one has acquired during the CS1527 course. However, it was all fun and worth the effort kind of experience which I believe motivated me and vastly expanded my knowledge in the field of Pygame and Python.

Description

The player begins with 3 "lives", with the lander positioned at the top of the screen with random vertical and horizontal velocities. It also has 500 kg of fuel being reduced by 5 every time the main engine thrust is fired ("space" key). Whenever the lander goes beyond the right or the left of the screen it wraps onto the opposite side of it. Besides, the Mars lander is not allowed to fly off the top of the screen.

At the top left-hand corner of the game window the user is provided with an instrument panel which displays the changing time, altitude, fuel reserves, velocity (x, y), damage sustained and lives left. The player's main goal is to successfully land on one of the three landing pads placed on different locations on the Martian surface. Proper land adds 50 points to the total game score which the user should aim to increase as much as possible. Furthermore, "You Have Landed Successfully! +50 pts" message is shown on the screen while the program is paused and waits for a key press. Each time the lander starts with 0% damage which instantly jumps to 100% in case the lander reaches the bottom of the screen or a hard landing occurs. This results in a "You Have Crashed!" message being displayed on the game screen and costs the player 1 life and the game pause till a key is pressed.

Moreover, the Mars lander's velocity (y) is incremented by a small amount every game cycle in order to introduce the acceleration due to gravity effect. There are random control failures which occur for a duration of 2 secs preventing the player from using one randomly chosen control feature of the lander. The user is notified by the "ALERT" message displayed at the bottom left-hand side of the instrument panel. The program also demonstrates 5 fixed position obstacle sprites which cause 10% damage to the lander when hit which destroys them (makes them invisible). It also displays random meteor storms consisting of 5 to 10 meteors every one of which deals 25% damage to the Mars lander. If the lander sustains 100% damage (meteors and/or obstacles), all the controls are disabled (resulting in a crash).

If one wishes to exit the game he/she can do so by pressing the "Esc" key or by clicking the red "X" button.

About

A single-player 2D game based on the Pygame library.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages