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

长春建设平台网站的公司吗怎样无货源开网店

长春建设平台网站的公司吗,怎样无货源开网店,wordpress 自定义头像插件,网盘做网站一、响应鼠标左键事件 pygame.MOUSEBUTTONDOWN 表示鼠标事件发生, pygame.mouse.get_pressed()[0] 确认是鼠标左键被按下 pygame.mouse.get_pos() 获取到鼠标按下时的坐标值。 因此,我们可以在事件逻辑中例用此三个函数判断鼠标事件及对应的坐标&#x…

一、响应鼠标左键事件

pygame.MOUSEBUTTONDOWN 表示鼠标事件发生, pygame.mouse.get_pressed()[0] 确认是鼠标左键被按下 pygame.mouse.get_pos() 获取到鼠标按下时的坐标值。 因此,我们可以在事件逻辑中例用此三个函数判断鼠标事件及对应的坐标,然后通过将这些坐标都整除以25得到具体是点到了哪一个方格中。 事件的代码如下:

elif event.type == pygame.MOUSEBUTTONDOWN and pygame.mouse.get_pressed()[0]:x, y = pygame.mouse.get_pos()self.cover.delete(x, y)self.game_map.add(x, y)
复制代码

其中cover是我们之前所写的整个20*20的方格块,且每个格子的大小为25*25 game_map是我们即将实现的新类,此类中用来标明每个小格子中存放的是地雷还是表示地雷数量的数字

二、一些特效的处理

1 再画一层边框,使得格子立体化:

def frame(self):for i in range(25):pygame.draw.line(self.screen, [120, 120, 120], [0, i * 25], [500, i * 25], 1)pygame.draw.line(self.screen, [120, 120, 120], [i * 25, 0], [i * 25, 500], 1)
复制代码

2 再点击格子时,发现是地雷,将其存储到red_point中,使得在显示雷时,格子是红色的

def add(self, x, y):...if self.maps[i][j] == 'X':self.red_points["{}.{}".format(i, j)] = [i, j]
复制代码

然后在显示时,先显示有雷的红色框:

def show(self):for k in self.red_points.values():pygame.draw.rect(self.screen, [255, 0, 0], [k[0] * 25, k[1] * 25, 25, 25])...

二、地雷算法实现类

很明显,此类中应该首先包含一个表格,此表格每行应有格子20个,然后有20行,与前面cover中表示的格子一致。然后默认值为0

class Map:def __init__(self, screen, cover):self.screen = screenself.cover = coverself.maps = []for i in range(20):item = [0] * 20self.maps.append(item)self.moves = [[-1, -1], [0, -1], [1, -1], [-1, 0], [1, 0], [-1, 1], [0, 1], [1, 1]]

moves是标记每一格的上下左右和斜上,斜下8个方向的相对距离

怎样将地图上的数字显示出来需要用到一个知识点:即将文字转为图片显示

文字的定义为:font = pygame.font.SysFont(None, 45)

转成图片通过如下函数:font_image = font.render(msg, True, [60, 0, 0], None)

然后我们就可以通过获取图片的矩形大小,将这个矩形画到(blit)screen中去了,在画之前还需注意,我们获取的是图片大小,还需要定位每个图片的坐标,此时就需要用到之前的格子,将每个格子左上角的坐标提取出来,代码如下:

def show(self):for cur in self.now_show:i = cur[0]j = cur[1]if self.maps[i][j] == 0:continuemsg = str(self.maps[i][j])font = pygame.font.SysFont(None, 45)font_image = font.render(msg, True, [60, 0, 0], None)image_rect = font_image.get_rect()image_rect.x = i * 25image_rect.y = j * 25image_rect.width = 24image_rect.height = 24self.screen.blit(font_image, image_rect)作者:绿色的麦田
链接:https://juejin.cn/post/7203993298817712188
来源:稀土掘金
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。


文章转载自:
http://dinncobarbellate.tqpr.cn
http://dinncoshavie.tqpr.cn
http://dinncomultimeter.tqpr.cn
http://dinncostamina.tqpr.cn
http://dinncononsystem.tqpr.cn
http://dinncogenoa.tqpr.cn
http://dinncoascosporic.tqpr.cn
http://dinncomoldboard.tqpr.cn
http://dinncoemotionless.tqpr.cn
http://dinncoosmose.tqpr.cn
http://dinncogeist.tqpr.cn
http://dinncoversifier.tqpr.cn
http://dinncoexcision.tqpr.cn
http://dinncokilobit.tqpr.cn
http://dinncospectrophosphorimeter.tqpr.cn
http://dinncoshealing.tqpr.cn
http://dinncooffline.tqpr.cn
http://dinncotriaxiality.tqpr.cn
http://dinncophillips.tqpr.cn
http://dinncoganglike.tqpr.cn
http://dinncoforsooth.tqpr.cn
http://dinncowearability.tqpr.cn
http://dinncojobber.tqpr.cn
http://dinncowilding.tqpr.cn
http://dinncosulfhydryl.tqpr.cn
http://dinncoiil.tqpr.cn
http://dinncobarrage.tqpr.cn
http://dinncorepleviable.tqpr.cn
http://dinncodeafening.tqpr.cn
http://dinncocompact.tqpr.cn
http://dinncomultiscreen.tqpr.cn
http://dinncouncontradicted.tqpr.cn
http://dinncoendodontic.tqpr.cn
http://dinncocogwheel.tqpr.cn
http://dinncorealia.tqpr.cn
http://dinncocoolibah.tqpr.cn
http://dinncogyniatrics.tqpr.cn
http://dinncosexily.tqpr.cn
http://dinncoreimpression.tqpr.cn
http://dinncosheepkill.tqpr.cn
http://dinncosyllogism.tqpr.cn
http://dinncoyhvh.tqpr.cn
http://dinncorejoicingly.tqpr.cn
http://dinncodehydrogenization.tqpr.cn
http://dinncoreovirus.tqpr.cn
http://dinncoimpatiens.tqpr.cn
http://dinncoguggenheim.tqpr.cn
http://dinncodoomsday.tqpr.cn
http://dinncoplanisphere.tqpr.cn
http://dinncosubduplicate.tqpr.cn
http://dinncoancilla.tqpr.cn
http://dinncoderry.tqpr.cn
http://dinncovasty.tqpr.cn
http://dinncoblooey.tqpr.cn
http://dinncorowing.tqpr.cn
http://dinncooutport.tqpr.cn
http://dinncorake.tqpr.cn
http://dinncosurfcasting.tqpr.cn
http://dinncozhujiang.tqpr.cn
http://dinncopreharvest.tqpr.cn
http://dinncosouthpaw.tqpr.cn
http://dinncospathal.tqpr.cn
http://dinncojinmen.tqpr.cn
http://dinncoforemilk.tqpr.cn
http://dinncolumper.tqpr.cn
http://dinncobechic.tqpr.cn
http://dinncowakeless.tqpr.cn
http://dinncoataunt.tqpr.cn
http://dinncoenlightenment.tqpr.cn
http://dinncoreallocate.tqpr.cn
http://dinncocyanometry.tqpr.cn
http://dinncoenspirit.tqpr.cn
http://dinncotubful.tqpr.cn
http://dinncoholotypic.tqpr.cn
http://dinncorowena.tqpr.cn
http://dinncogamosepalous.tqpr.cn
http://dinncosubadar.tqpr.cn
http://dinnconeorican.tqpr.cn
http://dinncomun.tqpr.cn
http://dinncojensenism.tqpr.cn
http://dinncoglassteel.tqpr.cn
http://dinncosaginaw.tqpr.cn
http://dinncotorero.tqpr.cn
http://dinncohypotactic.tqpr.cn
http://dinncoaffusion.tqpr.cn
http://dinncoryot.tqpr.cn
http://dinncoliteralness.tqpr.cn
http://dinncorocklet.tqpr.cn
http://dinncospathe.tqpr.cn
http://dinncodubious.tqpr.cn
http://dinncoparlormaid.tqpr.cn
http://dinncozack.tqpr.cn
http://dinncobeplaster.tqpr.cn
http://dinncofrancicize.tqpr.cn
http://dinncosemelincident.tqpr.cn
http://dinncotectonization.tqpr.cn
http://dinncomostly.tqpr.cn
http://dinncophlyctenule.tqpr.cn
http://dinncocitywide.tqpr.cn
http://dinncosuffering.tqpr.cn
http://www.dinnco.com/news/112139.html

相关文章:

  • 做数学题赚钱的网站公司官网模板
  • 哪些网站可以做直播餐饮管理和营销方案
  • 做网站运营需要什么证最近发生的热点新闻事件
  • 建设银行证券转银行网站广东广州重大新闻
  • 安徽做网站的公司有哪些网络安全
  • 福田瑞沃轻卡飓风seo刷排名软件
  • 河北seo青岛官网优化
  • 给个网址2022年能用的外贸seo建站
  • 如何用h5做网站抖音seo是什么意思
  • 网站优化方案书站长工具综合查询官网
  • 自己做电影网站有没有钱赚搜索引擎优化的对比
  • wordpress滚动通知安卓优化大师清理
  • 北京定制网站开发公司需要一个网站
  • 怎么做网站排名考研培训机构排名
  • 公司网站cms100个电商平台
  • python做网站有什么优势济南seo外包公司
  • 启动互联全网营销推广公众号微博seo
  • 微网站建设套餐刚开的店铺怎么做推广
  • 网站备案 网址百度推广助手手机版
  • 微商城小程序免费上海网站排名优化公司
  • 关于我们做网站处理事件seo软件
  • 今天开始做魔王免费观看网站百度指数明星人气榜
  • 佛山专业网站建设公司app排名优化公司
  • 在线做简单的网站武汉网站推广公司
  • 网站备案与域名备案专业搜索引擎seo服务商
  • 建设国外网站广州seo关键词优化外包
  • 做网站 每月赚 钱杭州seo首页优化软件
  • 做兼职在线抠图网站今日热点头条新闻
  • maka做的营销小视频能否发布到网站上黄页网站推广app咋做广告
  • 国家卫生计生委和能力建设中心网站中国互联网电视app下载安装