Skip to main content

A pygame role package

Project description

codebear Package

This is a simple example package. You can use Github-flavored Markdown to write your content.

源码熊 codeby yy

小武酷跑 简易封装 文件 背景类 BackGround() : 传入窗口对象

方法: .load() 加载背景图片 .update() 显示到屏幕 .update (是否交替(True/False),移动速度(int)) move_speed: 移动速度is_change=False :是否交替

角色类 Role(self,image, x, y, action=False, rate=5): 管理 角色更好地 类 创建对象实例化 .x 当前的x坐标 .y 当前角色的 y 坐标 .action bool 值 用来判断是否是动图 如果是一组图 需要设置为True .rate 图片切换的速率

一些方法

update() 方法 更新下一个动作图片 get_pos() 方法 获取当前角色的x,y坐标 返回值为 [] 列表 set_speed() 方法 设置角色的移动速度 参数为speed get_speed() 方法 获取角色当前的移动速度 setAlive() 方法 bool值 设置角色是否活着 参数为bool值 getAlive() 方法 bool值 获取角色是否活着 setBlood() 方法 给该角色设置生命值 getBlood() 方法 获取该角色的生命值 move(face="left") 方法 移动角色 参数 朝某个方向移动 up down left right setJumpHeight(self, speed=5)方法 设置角色的跳跃高度’ 参数为角色的跳跃高度 正数 jump(floor = floor)方法 让角色调整为跳跃状态 是用之前需要设置跳跃高度 参数为初始起跳的高度 distance(self, pos, center_d2=5) 当前角色和 角色2之间的距离 参数 角色2的pos元组坐标 角色2 坐标到图中心的平均值 默认为5

坐标到图中心的平均值计算方法 平均值 = (角色2 的宽除以 2 + 角色2 的高除以2) // 2

给角色赋予新的能力

setMyDefine(self, **kwargs): 当角色已有的属性不被满足时可以自己添加键值对的形式添加 getMyDefine(self, key) 获取自己设定属性的值 example: # 设置得分= 5 Role.setMyDefine(point = 5) point = Role.getMyDefine("point")

v1.0.3更新 加入了雪花飘落元素 优化碰撞检测 优化自定义属性 Fall() 飘落物落下物体类 f = Fall(img, milliseconds=500): 初始化需要一个下落的图片路径和 几毫秒创建一个飘落物, 方法: getEvent(self): 获取创建漂浮物体的事件返回一个漂浮事件

创建一个飘落物体

create(self, pos, crosswise_speed=-1, vertical_speed=1): 参数 pos>>>[x,y] 元组或者列表格式的x,y坐标 ,为元素出现的位置 crosswise_speed: 横向漂浮的速度 vertical_speed: 竖向漂浮的速度

漂浮物落下,需要一个屏幕对象,在屏幕对象上绘制

descent(self, screen):

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

codebear-1.0.3.tar.gz (6.3 kB view details)

Uploaded Source

Built Distribution

codebear-1.0.3-py3-none-any.whl (7.8 kB view details)

Uploaded Python 3

File details

Details for the file codebear-1.0.3.tar.gz.

File metadata

  • Download URL: codebear-1.0.3.tar.gz
  • Upload date:
  • Size: 6.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.7.8

File hashes

Hashes for codebear-1.0.3.tar.gz
Algorithm Hash digest
SHA256 02ec2d63a8d6877c349ec818be76d13c59f0beb2b30c82243dd498e2166831dd
MD5 ad04af0427155d730338ba8220de06ad
BLAKE2b-256 255255e5eb3e233f78566e7284402b2e91e822b5aa8a31e400350ae3bd52bf39

See more details on using hashes here.

File details

Details for the file codebear-1.0.3-py3-none-any.whl.

File metadata

  • Download URL: codebear-1.0.3-py3-none-any.whl
  • Upload date:
  • Size: 7.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.7.8

File hashes

Hashes for codebear-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 38976161d8d8fc0386374d96983fee363eaa715984ace88c7d7f45f65f93287e
MD5 7a356b2772aedbb29e83abed6468cd80
BLAKE2b-256 48b7dc89eb613b80c23feb2f307cfbadaee7681272ad9f7b48224df5a6c94328

See more details on using hashes here.

Supported by

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