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

怎么看网站谁做的sem运营

怎么看网站谁做的,sem运营,做云购网站,展馆设计说明范文曾经风靡一时的消消乐,至今坐在地铁上都可以看到很多人依然在玩,想当年我也是大军中的一员,那家伙,吃饭都在玩,进入到高级的那种胜利感还是很爽的,连续消,无限消,哈哈,现…

曾经风靡一时的消消乐,至今坐在地铁上都可以看到很多人依然在玩,想当年我也是大军中的一员,那家伙,吃饭都在玩,进入到高级的那种胜利感还是很爽的,连续消,无限消,哈哈,现在想想也是很带劲的。今天就来实现一款简易版的,后续会陆续带上高阶版的,先来尝试一把。
首先我们需要准备消消乐的素材,会放在项目的resource文件夹下面,具体我准备了7种,稍后会展示给大家看的。

开心消消乐

先初始化消消乐的游戏界面参数,就是具体显示多大,每行显示多少个方块,每个方块大小,这里我们按照这个大小来设置,数量和大小看着都还挺舒服的:


'''初始化消消乐的参数'''
WIDTH = 600
HEIGHT = 640
NUMGRID = 12
GRIDSIZE = 48
XMARGIN = (WIDTH - GRIDSIZE * NUMGRID) // 2
YMARGIN = (HEIGHT - GRIDSIZE * NUMGRID) // 2
ROOTDIR = os.getcwd()
FPS = 45

每行显示12个,每个方块48个,看看效果

接下来,我们开始实现消除的逻辑:

初始化消消乐的方格:


class elimination_block(pygame.sprite.Sprite):def __init__(self, img_path, size, position, downlen, **kwargs):pygame.sprite.Sprite.__init__(self)self.image = pygame.image.load(img_path)self.image = pygame.transform.smoothscale(self.image, size)self.rect = self.image.get_rect()self.rect.left, self.rect.top = positionself.down_len = downlenself.target_x = position[0]self.target_y = position[1] + downlenself.type = img_path.split('/')[-1].split('.')[0]self.fixed = Falseself.speed_x = 10self.speed_y = 10self.direction = 'down'

移动方块:


'''拼图块移动'''def move(self):if self.direction == 'down':self.rect.top = min(self.target_y, self.rect.top + self.speed_y)if self.target_y == self.rect.top:self.fixed = Trueelif self.direction == 'up':self.rect.top = max(self.target_y, self.rect.top - self.speed_y)if self.target_y == self.rect.top:self.fixed = Trueelif self.direction == 'left':self.rect.left = max(self.target_x, self.rect.left - self.speed_x)if self.target_x == self.rect.left:self.fixed = Trueelif self.direction == 'right':self.rect.left = min(self.target_x, self.rect.left + self.speed_x)if self.target_x == self.rect.left:self.fixed = True

获取方块的坐标:

     '''获取坐标'''def get_position(self):return self.rect.left, self.rect.top'''设置坐标'''def set_position(self, position):self.rect.left, self.rect.top = position

绘制得分,加分,还有倒计时:


'''显示剩余时间'''def show_remained_time(self):remaining_time_render = self.font.render('CountDown: %ss' % str(self.remaining_time), 1, (85, 65, 0))rect = remaining_time_render.get_rect()rect.left, rect.top = (WIDTH - 201, 6)self.screen.blit(remaining_time_render, rect)'''显示得分'''def show_score(self):score_render = self.font.render('SCORE:' + str(self.score), 1, (85, 65, 0))rect = score_render.get_rect()rect.left, rect.top = (10, 6)self.screen.blit(score_render, rect)'''显示加分'''def add_score(self, add_score):score_render = self.font.render('+' + str(add_score), 1, (255, 100, 100))rect = score_render.get_rect()rect.left, rect.top = (250, 250)self.screen.blit(score_render, rect)

生成方块:


'''生成新的拼图块'''def generate_new_blocks(self, res_match):if res_match[0] == 1:start = res_match[2]while start > -2:for each in [res_match[1], res_match[1] + 1, res_match[1] + 2]:block = self.get_block_by_position(*[each, start])if start == res_match[2]:self.blocks_group.remove(block)self.all_blocks[each][start] = Noneelif start >= 0:block.target_y += GRIDSIZEblock.fixed = Falseblock.direction = 'down'self.all_blocks[each][start + 1] = blockelse:block = elimination_block(img_path=random.choice(self.block_images), size=(GRIDSIZE, GRIDSIZE),position=[XMARGIN + each * GRIDSIZE, YMARGIN - GRIDSIZE],downlen=GRIDSIZE)self.blocks_group.add(block)self.all_blocks[each][start + 1] = blockstart -= 1elif res_match[0] == 2:start = res_match[2]while start > -4:if start == res_match[2]:for each in range(0, 3):block = self.get_block_by_position(*[res_match[1], start + each])self.blocks_group.remove(block)self.all_blocks[res_match[1]][start + each] = Noneelif start >= 0:block = self.get_block_by_position(*[res_match[1], start])block.target_y += GRIDSIZE * 3block.fixed = Falseblock.direction = 'down'self.all_blocks[res_match[1]][start + 3] = blockelse:block = elimination_block(img_path=random.choice(self.block_images), size=(GRIDSIZE, GRIDSIZE),position=[XMARGIN + res_match[1] * GRIDSIZE, YMARGIN + start * GRIDSIZE],downlen=GRIDSIZE * 3)self.blocks_group.add(block)self.all_blocks[res_match[1]][start + 3] = blockstart -= 1

绘制拼图,移除,匹配,下滑的效果等:


'''移除匹配的block'''def clear_matched_block(self, res_match):if res_match[0] > 0:self.generate_new_blocks(res_match)self.score += self.rewardreturn self.rewardreturn 0'''游戏界面的网格绘制'''def draw_grids(self):for x in range(NUMGRID):for y in range(NUMGRID):rect = pygame.Rect((XMARGIN + x * GRIDSIZE, YMARGIN + y * GRIDSIZE, GRIDSIZE, GRIDSIZE))self.draw_block(rect, color=(0, 0, 255), size=1)'''画矩形block框'''def draw_block(self, block, color=(255, 0, 255), size=4):pygame.draw.rect(self.screen, color, block, size)'''下落特效'''def draw_drop_animation(self, x, y):if not self.get_block_by_position(x, y).fixed:self.get_block_by_position(x, y).move()if x < NUMGRID - 1:x += 1return self.draw_drop_animation(x, y)elif y < NUMGRID - 1:x = 0y += 1return self.draw_drop_animation(x, y)else:return self.is_all_full()'''是否每个位置都有拼图块了'''def is_all_full(self):for x in range(NUMGRID):for y in range(NUMGRID):if not self.get_block_by_position(x, y).fixed:return Falsereturn True

绘制匹配规则,绘制拼图交换效果:


'''检查有无拼图块被选中'''def check_block_selected(self, position):for x in range(NUMGRID):for y in range(NUMGRID):if self.get_block_by_position(x, y).rect.collidepoint(*position):return [x, y]return None'''是否有连续一样的三个块(无--返回0/水平--返回1/竖直--返回2)'''def is_block_matched(self):for x in range(NUMGRID):for y in range(NUMGRID):if x + 2 < NUMGRID:if self.get_block_by_position(x, y).type == self.get_block_by_position(x + 1, y).type == self.get_block_by_position(x + 2,y).type:return [1, x, y]if y + 2 < NUMGRID:if self.get_block_by_position(x, y).type == self.get_block_by_position(x, y + 1).type == self.get_block_by_position(x,y + 2).type:return [2, x, y]return [0, x, y]'''根据坐标获取对应位置的拼图对象'''def get_block_by_position(self, x, y):return self.all_blocks[x][y]'''交换拼图'''def swap_block(self, block1_pos, block2_pos):margin = block1_pos[0] - block2_pos[0] + block1_pos[1] - block2_pos[1]if abs(margin) != 1:return Falseblock1 = self.get_block_by_position(*block1_pos)block2 = self.get_block_by_position(*block2_pos)if block1_pos[0] - block2_pos[0] == 1:block1.direction = 'left'block2.direction = 'right'elif block1_pos[0] - block2_pos[0] == -1:block2.direction = 'left'block1.direction = 'right'elif block1_pos[1] - block2_pos[1] == 1:block1.direction = 'up'block2.direction = 'down'elif block1_pos[1] - block2_pos[1] == -1:block2.direction = 'up'block1.direction = 'down'block1.target_x = block2.rect.leftblock1.target_y = block2.rect.topblock1.fixed = Falseblock2.target_x = block1.rect.leftblock2.target_y = block1.rect.topblock2.fixed = Falseself.all_blocks[block2_pos[0]][block2_pos[1]] = block1self.all_blocks[block1_pos[0]][block1_pos[1]] = block2return True

准备工作差不多了,开始主程序吧:

def main():pygame.init()screen = pygame.display.set_mode((WIDTH, HEIGHT))pygame.display.set_caption('开心消消乐')# 加载背景音乐pygame.mixer.init()pygame.mixer.music.load(os.path.join(ROOTDIR, "resources/audios/bg.mp3"))pygame.mixer.music.set_volume(0.6)pygame.mixer.music.play(-1)# 加载音效sounds = {}sounds['mismatch'] = pygame.mixer.Sound(os.path.join(ROOTDIR, 'resources/audios/badswap.wav'))sounds['match'] = []for i in range(6):sounds['match'].append(pygame.mixer.Sound(os.path.join(ROOTDIR, 'resources/audios/match%s.wav' % i)))# 加载字体font = pygame.font.Font(os.path.join(ROOTDIR, 'resources/font.TTF'), 25)# 图片加载block_images = []for i in range(1, 8):block_images.append(os.path.join(ROOTDIR, 'resources/images/gem%s.png' % i))# 主循环game = InitGame(screen, sounds, font, block_images)while True:score = game.start()flag = False# 一轮游戏结束后玩家选择重玩或者退出while True:for event in pygame.event.get():if event.type == pygame.QUIT or (event.type == pygame.KEYUP and event.key == pygame.K_ESCAPE):pygame.quit()sys.exit()elif event.type == pygame.KEYUP and event.key == pygame.K_r:flag = Trueif flag:breakscreen.fill((135, 206, 235))text0 = 'Final score: %s' % scoretext1 = 'Press <R> to restart the game.'text2 = 'Press <Esc> to quit the game.'y = 150for idx, text in enumerate([text0, text1, text2]):text_render = font.render(text, 1, (85, 65, 0))rect = text_render.get_rect()if idx == 0:rect.left, rect.top = (212, y)elif idx == 1:rect.left, rect.top = (122.5, y)else:rect.left, rect.top = (126.5, y)y += 100screen.blit(text_render, rect)pygame.display.update()game.reset()'''test'''
if __name__ == '__main__':main()

运行main.py就可以开始游戏了,看看效果吧!

玩了一下,还可以,可能是电脑原因,初始化的时候存在卡顿的情况,后续会优化一下,初始化8个,64大小的方块是最佳情况,大家可以尝试改下配置文件就好了。后续会退出各个小游戏的进阶版,欢迎大家关注,及时获取最新内容。

需要游戏素材,和完整代码,点**开心消消乐**获取。

今天的分享就到这里,希望感兴趣的同学关注我,每天都有新内容,不限题材,不限内容,你有想要分享的内容,也可以私聊我!

在这里插入图片描述


文章转载自:
http://dinncodriveline.stkw.cn
http://dinncoexodermis.stkw.cn
http://dinncofinfish.stkw.cn
http://dinncometaphorical.stkw.cn
http://dinncoexocyclic.stkw.cn
http://dinnconephrogenic.stkw.cn
http://dinncocompotator.stkw.cn
http://dinncoastigmatoscopy.stkw.cn
http://dinncochoosy.stkw.cn
http://dinncopatella.stkw.cn
http://dinncobacken.stkw.cn
http://dinncomandible.stkw.cn
http://dinncocustomhouse.stkw.cn
http://dinncoresail.stkw.cn
http://dinncoenwrite.stkw.cn
http://dinncobriefness.stkw.cn
http://dinncoalgous.stkw.cn
http://dinncoroutinier.stkw.cn
http://dinncovagina.stkw.cn
http://dinncocampanological.stkw.cn
http://dinncosuccussive.stkw.cn
http://dinncodnepr.stkw.cn
http://dinncoaral.stkw.cn
http://dinncoacidulous.stkw.cn
http://dinncoatherosclerotic.stkw.cn
http://dinncopoussette.stkw.cn
http://dinncovibrograph.stkw.cn
http://dinncoannounciator.stkw.cn
http://dinncovitellin.stkw.cn
http://dinncobossism.stkw.cn
http://dinncoescutcheon.stkw.cn
http://dinncobauson.stkw.cn
http://dinncoconjunctly.stkw.cn
http://dinncocembra.stkw.cn
http://dinncoglassblower.stkw.cn
http://dinncoseistan.stkw.cn
http://dinnconormotensive.stkw.cn
http://dinncobashfully.stkw.cn
http://dinncotrichologist.stkw.cn
http://dinncomicell.stkw.cn
http://dinncodiscouraging.stkw.cn
http://dinncoscentless.stkw.cn
http://dinncogeoisotherm.stkw.cn
http://dinncomonocycle.stkw.cn
http://dinncogalla.stkw.cn
http://dinnconuclease.stkw.cn
http://dinncoomoplate.stkw.cn
http://dinncomortgagee.stkw.cn
http://dinncoraphaelesque.stkw.cn
http://dinncocockatiel.stkw.cn
http://dinncorealist.stkw.cn
http://dinncospilosite.stkw.cn
http://dinncoastropologist.stkw.cn
http://dinncoepsomite.stkw.cn
http://dinncounintelligence.stkw.cn
http://dinncoconsuming.stkw.cn
http://dinncochasseur.stkw.cn
http://dinncosociology.stkw.cn
http://dinncounconversant.stkw.cn
http://dinncothundercloud.stkw.cn
http://dinncokvetch.stkw.cn
http://dinncoidolize.stkw.cn
http://dinncotellus.stkw.cn
http://dinncoslank.stkw.cn
http://dinncocowitch.stkw.cn
http://dinncomarxize.stkw.cn
http://dinncoactuator.stkw.cn
http://dinncooceanological.stkw.cn
http://dinncopunily.stkw.cn
http://dinncogreek.stkw.cn
http://dinncoturaco.stkw.cn
http://dinncoautomatism.stkw.cn
http://dinncojv.stkw.cn
http://dinncoblip.stkw.cn
http://dinncodermatropic.stkw.cn
http://dinncodaffadilly.stkw.cn
http://dinncobort.stkw.cn
http://dinncolampadephoria.stkw.cn
http://dinncosemeiotics.stkw.cn
http://dinncoprelimit.stkw.cn
http://dinncoincorporable.stkw.cn
http://dinncowouldst.stkw.cn
http://dinncodeserter.stkw.cn
http://dinncosasebo.stkw.cn
http://dinncochirm.stkw.cn
http://dinncoantiseismic.stkw.cn
http://dinncodrape.stkw.cn
http://dinncoarcheolithic.stkw.cn
http://dinncoautomatize.stkw.cn
http://dinncodecoction.stkw.cn
http://dinncoimpure.stkw.cn
http://dinncoeyespot.stkw.cn
http://dinncoquiet.stkw.cn
http://dinncoshirk.stkw.cn
http://dinncoautoman.stkw.cn
http://dinncodetraction.stkw.cn
http://dinncolighthouse.stkw.cn
http://dinncophotodetector.stkw.cn
http://dinncohaulm.stkw.cn
http://dinncofragrant.stkw.cn
http://www.dinnco.com/news/126333.html

相关文章:

  • 可以做国外购物的网站智慧软文网站
  • 网站案例分析湖南免费关键词排名优化软件
  • 四川学校网站建设太原网站建设优化
  • 男女做那个的的视频网站如何建立网页
  • 仿牌独立站全国疫情突然又严重了
  • wordpress全站cdn ssl贵阳网站建设制作
  • 发帖子的网站线下实体店如何推广引流
  • 做外贸免费发布产品的网站微信腾讯会议
  • 企业信息系统公示沈阳网络seo公司
  • 淘宝官方网站主页博客网站登录
  • 肇庆网站建设sem是什么分析方法
  • 有没有什么网站做兼职seo优化运营专员
  • pc端网站怎么做自适应手机端关于市场营销的100个问题
  • 电子商务app有哪些seo排名专业公司
  • wordpress类似的前端seo营销优化软件
  • 织梦中查看演示网站怎么做友情链接交换平台源码
  • 专业企业网站开发联系电话网站建设一条龙
  • 网站怎么做免费推广优化营商环境
  • 重庆网站建设哪家便宜病毒营销案例
  • 淄博专业网站建设哪家好百度关键词点击
  • 什么网站是专门做评论赚钱的电脑培训网
  • 做电影网站挣钱吗搜索引擎推广渠道
  • 怎样用wordpress做网站百度seo排名点击器
  • 网站开发需要文章写的好吗怎么建立网站卖东西
  • 织梦网站默认密码搜索引擎seo是什么
  • 一定要知道的网站杭州疫情最新情况
  • 网站建设找单站内推广方式有哪些
  • 电子商务网站权限管理问题市场调研报告范文
  • 做网站用的产品展示横幅开网站需要多少钱
  • 濮阳疫情最新消息今天封城了seo流量排名工具