所以我一直在为一个项目开发一个python游戏,现在我遇到了一个问题,如果我在游戏中设置了一个障碍,我就不能让它对我的图片做出响应,就像我的图片与它发生碰撞一样,游戏就结束了。我已经做了很长一段时间了,但是我不知道代码。任何我们将非常感谢您的帮助。我非常需要帮助这个。拜托并不是说我是初学者,而且我刚开始学习python一个月以前。所以请试着去理解。我附上了下面的代码。在import pygame, random, sys

from pygame.locals import *

BACKGROUNDCOLOR = (181, 230, 29)

FPS = 30

pixels = 5

pygame.init()

mainClock = pygame.time.Clock()

windowSurface = pygame.display.set_mode((990, 557))

pygame.display.set_caption('Clumsy Claire :D')

background = pygame.image.load('grass.jpg')

backgroundRect = background.get_rect()

size = (990, 557)

background.get_size()

image = pygame.image.load('snail 2.png')

imageRect = image.get_rect()

stone1 = pygame.image.load('rock.PNG')

stone1Rect = stone1.get_rect()

stone2 = pygame.image.load('rock.PNG')

stone2Rect = stone2.get_rect()

BROWN = (128,64,0)

pygame.draw.line(background, BROWN, (98, 555), (98,69), 12)

pygame.draw.line(background, BROWN, (98, 16), (98,1), 12)

pygame.draw.line(background, BROWN, (94, 3), (283, 3),12)

pygame.draw.line(background, BROWN, (278, 457), (278, 3),12)

pygame.draw.line(background, BROWN, (278, 554), (278, 512),12)

pygame.draw.line(background, BROWN, (274, 554), (470, 554),12)

pygame.draw.line(background, BROWN, (465, 554), (465, 90),12)

pygame.draw.line(background, BROWN, (465, 35), (465, 0),12)

pygame.draw.line(background, BROWN, (465, 3), (657, 3),12)

pygame.draw.line(background, BROWN, (652,555 ), (652, 502),12)

pygame.draw.line(background, BROWN, (652, 449), (652, 0),12)

pygame.draw.line(background, BROWN, (648, 553), (844, 553),12)

pygame.draw.line(background, BROWN, (838, 553 ), (838, 138),12)

pygame.draw.line(background, BROWN, (838, 84 ), (838, 0),12)

while True:

imageRect.topleft = (10,488)

moveLeft = False

moveRight = False

moveUp = False

moveDown = False

while True:

for event in pygame.event.get():

if event.type == QUIT:

pygame.quit()

sys.exit()

if event.type == KEYDOWN:

if event.key == K_LEFT:

moveLeft = True

if event.key == K_RIGHT:

moveRight = True

if event.key == K_UP:

moveUp = True

if event.key == K_DOWN:

moveDown = True

if event.type == KEYUP:

if event.key == K_LEFT:

moveLeft = False

if event.key == K_RIGHT:

moveRight = False

if event.key == K_UP:

moveUp = False

if event.key == K_DOWN:

moveDown = False

if moveLeft and imageRect.left > 0:

imageRect.move_ip(-1 * pixels, 0)

if moveRight and imageRect.right < 990:

imageRect.move_ip(pixels, 0)

if moveUp and imageRect.top > 0:

imageRect.move_ip(0, -1 * pixels)

if moveDown and imageRect.bottom < 557:

imageRect.move_ip(0, pixels)

windowSurface.blit(background, backgroundRect)

windowSurface.blit(image, imageRect)

rock1 = background.blit(stone1,(658,337))

rock2 = background.blit(stone2,(225,150))

pygame.display.update()

mainClock.tick(FPS)

vpython 贞测碰撞_python碰撞检测?相关推荐

  1. vpython 贞测碰撞_7、Pygame碰撞检测

    本文目标 1,本章我们继续学习使用sprite木块,来实现我们游戏当中的碰撞检测 2,完成游戏实例:吃苹果小游戏 Pygame模块的Sprite碰撞检测 下面是几种常见的碰撞检测以及实现代码. 1.两 ...

  2. vpython 贞测碰撞_球碰撞vPython问题

    所以我在编写一个斯诺克游戏,我决定找出如何使球相互碰撞的最好方法是在一个单独的程序中这样做,然后复制进去.我是一个很有能力的数学家,所以我坐下来,画了一个事件,然后用数学的方法研究了实际发生的事情.在 ...

  3. vpython 贞测碰撞_VPython - example - 模拟球在两板之间的碰撞

    作者:liuyuan_jq 2011-04-10 ######################################### # Import the library(s) ######### ...

  4. Unity碰撞和碰撞检测

    所谓带碰撞效果是指有物理效果,比如碰了要发生位移之类的.而检测是用在只是检测是否发生了碰撞. 比如一个足球游戏中,用碰撞的思路来判定足球是否出边线,我们会在边线附近摆一个碰撞体,当球碰到边线时,我们并 ...

  5. 基于python的压测工具_Python Locust性能测试简介及框架实践

    Locust(俗称 蝗虫), 一个轻量级的开源压测工具,用Python编写.使用 Python 代码定义用户行为,也可以仿真百万个用户: Locust 非常简单易用,是分布式,用户负载测试工具.Loc ...

  6. python回测工具_Python爬虫回测股票的实例讲解

    股票和基金一直是热门的话题,很多周围的人都选择不同种类的理财方式.就股票而言,肯定是短时间内收益最大化,这里我们需要用python爬虫的方法,来帮助我们获取一些股票的数据,这样才能更好的买到相应的股票 ...

  7. python locust 能压测数据库_python locust 性能测试:HOOKS钩子方法

    为locust中不同类型的事件,提供的钩子方法: from locust import TaskSet, task, events, Locust from locust.clients import ...

  8. python回测代码_python实现马丁策略回测3000只股票的实例代码

    免费资源网 - https://freexyz.cn/ 上一篇文章讲解了如何实现马丁策略,但没有探索其泛化能力,所以这次来尝试回测3000只股票来查看盈利比例. 批量爬取股票数据 这里爬取数据继续使用 ...

  9. python压测接口_python的一个接口压测脚本

    1 importrequests2 import queue #Queue模块中提供了同步的.线程安全的队列类,包括 3 #FIFO(先入先出)队列Queue,LIFO(后入先出)队列 4 #Lifo ...

最新文章

  1. AI一分钟 | Windows负责人离职;华为2017年收入6036亿元,净利475亿元
  2. 洛谷P1919 【模板】A*B Problem升级版(FFT)
  3. How to call DLL and LIB files (SDK)
  4. 符号主义对深度学习的意义浅谈
  5. Windows进程与线程学习笔记(七)—— 时间片管理
  6. reactjs虚拟DOM与真实DOM
  7. 拥有一亿会员的爱奇艺如何搭建大数据实时分析平台
  8. 深度学习基础2(反向传播算法)
  9. 【GIS风暴】GIS拓扑关系原理详解
  10. Google C++编程风格指南(一):背景
  11. 光荣的梦想(信息学奥赛一本通-T1328)
  12. WP黑格导航主题BlackCan 焕然一新的UI设计
  13. python求列表的平均值的用法_python如何求列表平均值?_后端开发
  14. RocketMQ在Windows环境下部署(亲测有效)
  15. 安卓9 webview打开指定url报错或者空白
  16. html 文字 转 语音,把文字变成语音的软件
  17. vba中filedialog用法
  18. C#操作-LX3600非接触式IC卡读写器
  19. 用python学概率与统计(第十二章)拟合度检验和独立性检验
  20. 记一次github 翻车事件

热门文章

  1. My task - how is inline creation implemented
  2. how is SAP ui5 formatter resolved
  3. SAP Fiori:why my filter by titleID does not work
  4. One order time zone
  5. webdynpro view navigation - the same as Webclient UI
  6. 手动生成function 对应的ABAP class
  7. HTTPS和TCP的关系
  8. C4C和CRM里获取当前登录用户分配的Organization Unit信息
  9. Linux系统下区别对比(~、/home与/root)
  10. java并发排序_Java并发(三):重排序