GithubHelp home page GithubHelp logo

ghost-versus-alien's Introduction

Ghost versus Alien

Description:

๐Ÿ‘ป Ghost versus ๐Ÿ‘ฝ Alien game.
This is a simple python game played in the terminal window.
In this game, you will play as a ghost character and your rival is an alien. Each character has corresponding attributes. Each character also has an attack function and a defense function, if the character is attacked, it will reduce HP which use โค๏ธ as the symbol, and if actively defending, it can avoid receiving damage. Finally, the winner will receive a shiny award cup ๐Ÿ†

  • How to play

just run project.py

  • Attributes

name the name of the character
level the level of the character
maxhp a character's max health point initialized at the beginning of the game
hp a character's current health point
lasthp lasthp means a character's health point in the previous round of battle

  • Methods

attack to attack your rival
defense defend against attacks from rival
The script uses random and sys libraries to generate the alien's level randomly as its hurt value, sys is used to catch exception during the game and avoid interrupt the program unfriendly. Notice, there may be slight differences in the display of Emoji on different systems. The script can be interrupted at any time by pressing Ctrl + D, which will print a goodbye message and exit gracefully.

  • Possible ways to optimize this program in the future

Optimize the structured writing logic of this program to reduce redundancy and contact coupling situations
Add more special method for each character with interesting functions
generate more character for user to choose
Add a beautiful user graphical interface
......

ghost-versus-alien's People

Contributors

zhangxume avatar

Watchers

 avatar

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.