Giter Site home page Giter Site logo

draw-order-challenge's Introduction

Draw Order Challenge

This is a challenge designed for /r/pygame
Link to challenge thread.

This challenge should be pretty straight forward for those familiar with pygame. It may take a little more effort for those who aren't, but I think it should be accessible to most. If you participate I would be interested in whether or not you think it was way too easy, or way too hard (or just right for that matter).

Challenge:

When creating a topdown rpg it is important that sprites are drawn in the correct order. We want to avoid sprites overlapping like this:

And instead make sure they look like this:

When all the sprites can move independently, this means that the draw order is always changing. The goal of this challenge is to make sure that sprites are always drawn in the correct order.

Base code:

Running main.py will give you a screen with a number of NPCs running around and one user controlled character (with the arrow keys). All of the sprites are members of a single sprite group (player included) called App.all_Sprites.

Suggestions:

In order to solve this challenge, you only need to edit the main.py file, though you are free to edit whatever you want.
I suggest investigating different types of sprite groups:
http://www.pygame.org/docs/ref/sprite.html
The base problem can be solved by adding/editing about three lines of code if you know what you are aiming at. If you want to go the extra mile, make your implementation use dirty sprites. This will require changing the class from which actors.RPGSprite inherits, as well as possibly some other minor parts of the code in that file.

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.