Skip to main content

A lite,simple package for game makeing based on pygame

Project description


typora-root-url: https://github.com/zhangfeibao/pygame-for-chinese-children/tree/main/images

pygame simple wraper

A lite,simple package for game makeing based on pygame.

more:https://github.com/zhangfeibao/pygame-for-chinese-children

安装

pip install nngame

Hello World

1.导入模块

import nngame.easygame as game

2.创建窗口

game.创建窗口("Hello World",800,600)

3.创建字体和文本框

字体1 = game.创建字体()
文本框1 = game.创建文本框(字体1,"Hello World")

4.循环(检测各种按键,鼠标,定时器等事件,刷新界面)

while True:
    game.检测事件()

    game.窗口填充颜色(255,255,255)
    game.添加文本框到窗口(文本框1,200,200)

    game.刷新画面()

现在如果运行程序,应该能看到一个简单的窗口,显示Hello World文本

窗口

但是,你会发现,我们无法关闭这个窗口,那是因为我们还没有编写代码对这个用户点击关闭按钮的动作做出响应。

在主循环之前添加如下代码:

def 用户点击了关闭按钮():
    game.退出()

game.添加退出事件处理函数(用户点击了关闭按钮)

现在应该可以正常关闭窗口了

完整代码

import nngame.easygame as game

game.创建窗口("Hello World",800,600)

字体1 = game.创建字体()
文本框1 = game.创建文本框(字体1,"Hello World")

def 用户点击了关闭按钮():
    game.退出()

game.添加退出事件处理函数(用户点击了关闭按钮)

while True:
    game.检测事件()

    game.窗口填充颜色(255,255,255)
    game.添加文本框到窗口(文本框1,200,200)

    game.刷新画面()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nngame-0.0.3.tar.gz (13.8 kB view details)

Uploaded Source

Built Distribution

nngame-0.0.3-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

Details for the file nngame-0.0.3.tar.gz.

File metadata

  • Download URL: nngame-0.0.3.tar.gz
  • Upload date:
  • Size: 13.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.13

File hashes

Hashes for nngame-0.0.3.tar.gz
Algorithm Hash digest
SHA256 b62846389a5d524254df45456b27ae9a03c065719808b19b872a01ab9f33ac3a
MD5 437eeff6c67f06a4f7f7c640af06b2b4
BLAKE2b-256 85a7de62f0409f0ad7e6b476156350435f5eb1addd44406b970b9b9b2abe2180

See more details on using hashes here.

File details

Details for the file nngame-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: nngame-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 5.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.13

File hashes

Hashes for nngame-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 c4d4446be8eec0832342b2f8e5cc716347e43b77a0d811a84b1a83ff20a5127c
MD5 4c1bbb9fe363563929ba3f08b246cb92
BLAKE2b-256 2b1ac7a3e14663c1f992badef3d6b7b39b6f32ce5f7d2e8adccc0c7e86a8d584

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page