Code Monkey home page Code Monkey logo

puzzle-fighter's Introduction

PuzzleFighter in Python
By Ceasar Bautista and Jason Lucibello

To run the game:
   1. Double-click main.py.
Alternatively:
   1. Open the Terminal/Commandline
   2. Change directory to the location of the python files (cd ../Python PF)
   3. Type python main.py to begin!

Game Details:

PuzzleFighter pits the player against an AI. Gems fall in pairs, one pair at a time. When a special "crash gem" (denoted by a circle) touches blocks of the same color, that block and all adjacent blocks of the same color are destroyed. In addition, destroying large chains of blocks will cause additional blocks to appear on the opponent's grid. The first to fill the opponents grid with blocks wins!

To PLAY:

Use the RIGHT and LEFT arrow keys to rotate the object clockwise/counterclockwise.
Use the A key to move the block left and the D key to move the block right. The DOWN arrow key will cause the block to drop immediately. Play fast to stay in the game!

Modules Used: pygame, random, time, math

Description of each file

gem.py: Creates instances of the individual blocks that go into the game. We use gem to move/update gems in the 2D grid array and to draw the gems.

rotate.py: Rotate takes 2 instances of the gem class and constructs a rotate object. This is the actual object that is used in the game. The rotate object can rotate clockwise and counterclockwise, determine whether it is still active or not, and move itself in the grid in a variety of ways. We also use rotate to monitor the theta of the rotate object to keep track of the current orientation of the rotation object.

grid.py: Controls and manipulates the two grid arrays in the game. grid.py updates the grid array for all events such as movement, rotation and explosions and allows us to have a location to create gems/rotate objects.

player.py: Creates instances of the players of the game. More importantly, this is the class that houses the AI for the game, as an instance of the player. Player.py controls the computation of the AI, the updating for explosions, and the control of the counter gems that are created as a result of explosions.

main.py: This is the file that actually runs the game. Main instantiates the game itself, the multiple threads that we use in the game to control the AI, the updater and other actions, and handles keyboard events.

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.