Using Python to develop a super simple fruit game, the 0 Foundation can also learn

Source: Internet
Author: User

Pylash Project Address

Create a project

In this case our project will be created, and then just fill in the code in main.py to run.

Write Hello World Applet

Writing games

With a little understanding of pylash, we can begin to write the game. First we delete all the code after line fourth.

Introduce the required

Global variables

In the game to use some of the global variables, we first browse again, different know what they are doing, then will use:

Load Resources

Create Start interface

In the main function we call the Gameinit function, so add this function:

Start the game

The listener of the stage-level mouse Click event is the Startgame function, which means that we start the game by clicking on the Start screen. To modify the Startgame function:

Player character class

Drop Item Category: Item

Modifying event listeners

Bonus points and Game over

Our fruit-picking game is here to finish. So it is very convenient to develop small games with Python+pylash.

Reprint statement: Reprint-Life is too short, I used to send Sen


Using Python to develop a super simple fruit game, the 0 Foundation can also learn

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.