Giter Club home page Giter Club logo

py-bomberman-one's Introduction

Bomberman pygame application day 1

Games! Games are a perfect example to show OOP principles at work. You could play the game Bomberman in your youth or childhood, now it is time to write your own a little modified version. You already have an initial structure of the game Bomberman.

Example

There are player (green rectangle) and walls (white squares). You should implement these features:

  1. Player movements. The player should be able to move left, right, up, down. Sprites update method is called every frame, so use self.rect.move_ip the method inside update to move the player. Movement direction depends on the pressed key by the user. Use pygame.key.get_pressed to get the keys that are currently pressed. Use arrows to move the player. Player
  2. Player cannot walk away from the field. Use player's self.rect.left, self.rect.right, self.rect.top, self.rect.bottom - coordinates of player borders and compare them to field borders SCREEN_WIDTH, SCREEN_HEIGHT. If the player coordinate is out of bound, it should change it to field border.
  3. Player cannot walk over the walls. Walls are stored in group walls. Use pygame.sprite.spritecollideany with the player and walls group to check if the player is colliding with any sprite in that group. (If after self.rect.move_ip player starts colliding - just move it back). Collision detection
  4. Player should plant the bomb when the user presses the space button. Implement class Bomb that should be a sprite. Bomb should be planted on the current player's coordinates. But the player cannot walk over the bomb, think about how the player gets off the bomb after the planting.
  5. Player cannot put bomb if less than 1 second has passed from last planting (the logic of the explosion you will implement later). There are 60 frames per second. You can store timeout in the attribute and reduce it in update method.
  6. Replace simple colored rectangles with images given in "app/images/. Use pygame.image.load("source.png").convert_alpha() instead of Surface. The player image should change when he goes in different directions. Sprite images

All information you can find in guides links on the top of the tasks.

Also, it is a bad idea to store full application logic in main.py.

  • Implement your architecture ideas

Hint: it will be good to have a class that stores and handles such things as: clock, screen, running, events, groups etc. If sprites store link to this class, they can interact with these things in methods instead of module level.

Example

py-bomberman-one's People

Contributors

masterpieceelbow 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.