当前位置: 首页 > news >正文

网站建设实习报告范文做购实惠网站的意义

网站建设实习报告范文,做购实惠网站的意义,嘉兴自助建站软件,鲜花类网站建设策划书范文文章目录 游戏页面实现代码 游戏页面 左右键移动方块位置#xff0c;上键切换方块形态。 实现代码 import pygame import random# 初始化 Pygame pygame.init()# 定义颜色 colors [(0, 0, 0), # 黑色(255, 0, 0), # 红色(0, 255, 0), # 绿色(0, 0, 255), # 蓝色(255,… 文章目录 游戏页面实现代码 游戏页面 左右键移动方块位置上键切换方块形态。 实现代码 import pygame import random# 初始化 Pygame pygame.init()# 定义颜色 colors [(0, 0, 0), # 黑色(255, 0, 0), # 红色(0, 255, 0), # 绿色(0, 0, 255), # 蓝色(255, 255, 0), # 黄色(255, 0, 255), # 紫色(0, 255, 255) # 青色 ]# 俄罗斯方块形状 shapes [[[1, 1, 1, 1]],[[1, 1],[1, 1]],[[0, 1, 1],[1, 1, 0]],[[1, 1, 0],[0, 1, 1]],[[1, 1, 1],[0, 1, 0]],[[1, 1, 1],[1, 0, 0]],[[1, 1, 1],[0, 0, 1]] ]# 设置游戏屏幕 screen_width 300 screen_height 600 screen pygame.display.set_mode((screen_width, screen_height)) pygame.display.set_caption(俄罗斯方块)# 游戏网格 grid [[0 for _ in range(10)] for _ in range(20)]# 初始化时钟 clock pygame.time.Clock()# 定义方块类 class Shape:def __init__(self):self.shape random.choice(shapes)self.color random.randint(1, len(colors) - 1)self.x 3self.y 0def rotate(self):self.shape [list(row) for row in zip(*self.shape[::-1])]def draw(self):for i, row in enumerate(self.shape):for j, val in enumerate(row):if val:pygame.draw.rect(screen, colors[self.color], (self.x * 30 j * 30, self.y * 30 i * 30, 30, 30))def check_collision(shape):for i, row in enumerate(shape.shape):for j, val in enumerate(row):if val:if shape.x j 0 or shape.x j 10 or shape.y i 20 or grid[shape.y i][shape.x j]:return Truereturn Falsedef merge_shape(shape):for i, row in enumerate(shape.shape):for j, val in enumerate(row):if val:grid[shape.y i][shape.x j] shape.colordef remove_full_lines():global gridgrid [row for row in grid if not all(row)]while len(grid) 20:grid.insert(0, [0 for _ in range(10)])def draw_grid():for y in range(20):for x in range(10):pygame.draw.rect(screen, colors[grid[y][x]], (x * 30, y * 30, 30, 30))def main():running Truecurrent_shape Shape()fall_time 0while running:screen.fill((0, 0, 0))draw_grid()current_shape.draw()for event in pygame.event.get():if event.type pygame.QUIT:running Falseif event.type pygame.KEYDOWN:if event.key pygame.K_LEFT:current_shape.x - 1if check_collision(current_shape):current_shape.x 1if event.key pygame.K_RIGHT:current_shape.x 1if check_collision(current_shape):current_shape.x - 1if event.key pygame.K_DOWN:current_shape.y 1if check_collision(current_shape):current_shape.y - 1if event.key pygame.K_UP:current_shape.rotate()if check_collision(current_shape):current_shape.rotate()current_shape.rotate()current_shape.rotate()fall_time clock.get_rawtime()clock.tick()if fall_time / 1000 0.5:fall_time 0current_shape.y 1if check_collision(current_shape):current_shape.y - 1merge_shape(current_shape)remove_full_lines()current_shape Shape()if check_collision(current_shape):running Falsepygame.display.update()pygame.quit()if __name__ __main__:main()
http://www.dnsts.com.cn/news/222167.html

相关文章:

  • 网站建设博客做农家乐网站
  • 前几年做那些网站能致富wordpress wp polls
  • php网站开发平台下载百度长尾关键词挖掘工具
  • 做网站的岗位好吗百度 特定网站搜索
  • 网站建设费记到什么科目如何用dw8做网站视频
  • 周村有做网站广告的吗南宁西乡塘区网站建设
  • 网站搭建为什么要备案网站沙盒期
  • 产品众筹网站开发龙华做网站yihe kj
  • 深圳 建设银行国际互联网站网站图片轮播怎么做的
  • 鞍山制作网站的公司有没有专业做淘宝网站吗
  • php网站开发技术环境要求网站建设合同内容
  • 密云建设网站html登录界面设计
  • wordpress怎么建设网站wordpress浏览次数
  • 我的专业网站建设策划书长春 行业网站
  • 新沂建设网站代账公司网站模板
  • 学校 网站建设工作小组官网做得好的公司
  • 北京展览馆网站建设西安抖音seo推广
  • 一个seo良好的网站其主要流量往往来自重庆建设工程信息网官网查询系统官网
  • 玉山县建设局的网站创意营销点子
  • 零食网站建设需求分析毕节建设局网站
  • 建设银行确认参加面试网站网页设计与制作黄俊峰
  • 网站建设开票开什么内容公司网站建设内容
  • 电商网站开发流程2022年网络规划设计师
  • 网站防护怎么做网站php源码破解版
  • 深南花园裙楼+网站建设网站设计源代码
  • 网站开发工具怎么改内容南京住房和城乡建设部网站
  • 优化网站的技巧光谷做网站
  • 少数民族网站建设金坛网站建设报价
  • 帝国网站调用图片集wordpress 如何发布文章
  • 帝国网站模板建设完成显示不正常哈尔滨网站建设 哈尔滨网站推广