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

国内seo做最好的公司seo好学吗

国内seo做最好的公司,seo好学吗,网站推广的目的是什,大兴智能网站建设哪家好大家好,本文将围绕python编程小游戏如何停止展开说明,python编程小游戏日语教程是一个很多人都想弄明白的事情,想搞清楚python编程小游戏超级玛丽需要先了解以下几个事情。 今天分享一个有趣的Python游戏库freegames,它里面包含经…

大家好,本文将围绕python编程小游戏如何停止展开说明,python编程小游戏日语教程是一个很多人都想弄明白的事情,想搞清楚python编程小游戏超级玛丽需要先了解以下几个事情。

今天分享一个有趣的Python游戏库freegames,它里面包含经典小游戏,像贪吃蛇、吃豆人、等等。可以通过1行代码重温这些童年小游戏,后面还会分享源码,可以自己学习游戏编写,相信你会超有成就感!

Paint 涂鸦 在屏幕上绘制线条和形状

单击以标记形状的开始,然后再次单击以标记其结束;

可以使用键盘选择不同的形状和颜色火车头采集器AI伪原创。

!python -m freegames.paint # 如果在命令行,则去掉前面的 感叹号 !

Snake 贪吃蛇 经典的街机小游戏

使用键盘的方向键导航并吃绿色食物,每吃一次食物,蛇就会长一段;

避免吃到自己或越界。

!python -m freegames.snake

 

这个游戏当时玩的时候,都是加速前进!


或许你之前学习过一点编程,但若是你从没接触过游戏编程,那么你现在自己动手尝试模仿编写一下。

选择合适的开发工具

编写游戏之前得挑选一款合适的工具,这样简化程序编写工作。Python语言有很多第三方库都提供游戏编程功能,最有名的要属Pygame库,它提供了丰富的API来实现游戏的各种效果。

设置开发环境

由于Pgzero是Python的第三方库,它不能独立工作,必须在Python代码中来使用,因此我们首先需要安装Python开发环境。可以去Python官网下载最新的安装包进行安装,然后便可以使用Python提供的IDLE编辑器来编写代码了。

准备好后,我们就要开始动手了!先分享一些简单操作的游戏。


贪吃蛇

玩法:童年经典,普通魔术也没啥意思,小时候玩的也是加速的。

 源码分享

import cfg
import sys
import pygame
from modules import *'''主函数'''
def main(cfg):# 游戏初始化pygame.init()screen = pygame.display.set_mode(cfg.SCREENSIZE)pygame.display.set_caption('Greedy Snake —— 九歌')clock = pygame.time.Clock()# 播放背景音乐pygame.mixer.music.load(cfg.BGMPATH)pygame.mixer.music.play(-1)# 游戏主循环snake = Snake(cfg)apple = Apple(cfg, snake.coords)score = 0while True:screen.fill(cfg.BLACK)# --按键检测for event in pygame.event.get():if event.type == pygame.QUIT:pygame.quit()sys.exit()elif event.type == pygame.KEYDOWN:if event.key in [pygame.K_UP, pygame.K_DOWN, pygame.K_LEFT, pygame.K_RIGHT]:snake.setDirection({pygame.K_UP: 'up', pygame.K_DOWN: 'down', pygame.K_LEFT: 'left', pygame.K_RIGHT: 'right'}[event.key])# --更新贪吃蛇和食物if snake.update(apple):apple = Apple(cfg, snake.coords)score += 1# --判断游戏是否结束if snake.isgameover: break# --显示游戏里必要的元素drawGameGrid(cfg, screen)snake.draw(screen)apple.draw(screen)showScore(cfg, score, screen)# --屏幕更新pygame.display.update()clock.tick(cfg.FPS)return endInterface(screen, cfg)'''run'''
if __name__ == '__main__':while True:if not main(cfg):break

再来一个稍复杂的 !

吃金币

源码分享:

import os
import cfg
import sys
import pygame
import random
from modules import *'''游戏初始化'''
def initGame():# 初始化pygame, 设置展示窗口pygame.init()screen = pygame.display.set_mode(cfg.SCREENSIZE)pygame.display.set_caption('catch coins —— 九歌')# 加载必要的游戏素材game_images = {}for key, value in cfg.IMAGE_PATHS.items():if isinstance(value, list):images = []for item in value: images.append(pygame.image.load(item))game_images[key] = imageselse:game_images[key] = pygame.image.load(value)game_sounds = {}for key, value in cfg.AUDIO_PATHS.items():if key == 'bgm': continuegame_sounds[key] = pygame.mixer.Sound(value)# 返回初始化数据return screen, game_images, game_sounds'''主函数'''
def main():# 初始化screen, game_images, game_sounds = initGame()# 播放背景音乐pygame.mixer.music.load(cfg.AUDIO_PATHS['bgm'])pygame.mixer.music.play(-1, 0.0)# 字体加载font = pygame.font.Font(cfg.FONT_PATH, 40)# 定义herohero = Hero(game_images['hero'], position=(375, 520))# 定义食物组food_sprites_group = pygame.sprite.Group()generate_food_freq = random.randint(10, 20)generate_food_count = 0# 当前分数/历史最高分score = 0highest_score = 0 if not os.path.exists(cfg.HIGHEST_SCORE_RECORD_FILEPATH) else int(open(cfg.HIGHEST_SCORE_RECORD_FILEPATH).read())# 游戏主循环clock = pygame.time.Clock()while True:# --填充背景screen.fill(0)screen.blit(game_images['background'], (0, 0))# --倒计时信息countdown_text = 'Count down: ' + str((90000 - pygame.time.get_ticks()) // 60000) + ":" + str((90000 - pygame.time.get_ticks()) // 1000 % 60).zfill(2)countdown_text = font.render(countdown_text, True, (0, 0, 0))countdown_rect = countdown_text.get_rect()countdown_rect.topright = [cfg.SCREENSIZE[0]-30, 5]screen.blit(countdown_text, countdown_rect)# --按键检测for event in pygame.event.get():if event.type == pygame.QUIT:pygame.quit()sys.exit()key_pressed = pygame.key.get_pressed()if key_pressed[pygame.K_a] or key_pressed[pygame.K_LEFT]:hero.move(cfg.SCREENSIZE, 'left')if key_pressed[pygame.K_d] or key_pressed[pygame.K_RIGHT]:hero.move(cfg.SCREENSIZE, 'right')# --随机生成食物generate_food_count += 1if generate_food_count > generate_food_freq:generate_food_freq = random.randint(10, 20)generate_food_count = 0food = Food(game_images, random.choice(['gold',] * 10 + ['apple']), cfg.SCREENSIZE)food_sprites_group.add(food)# --更新食物for food in food_sprites_group:if food.update(): food_sprites_group.remove(food)# --碰撞检测for food in food_sprites_group:if pygame.sprite.collide_mask(food, hero):game_sounds['get'].play()food_sprites_group.remove(food)score += food.scoreif score > highest_score: highest_score = score# --画herohero.draw(screen)# --画食物food_sprites_group.draw(screen)# --显示得分score_text = f'Score: {score}, Highest: {highest_score}'score_text = font.render(score_text, True, (0, 0, 0))score_rect = score_text.get_rect()score_rect.topleft = [5, 5]screen.blit(score_text, score_rect)# --判断游戏是否结束if pygame.time.get_ticks() >= 90000:break# --更新屏幕pygame.display.flip()clock.tick(cfg.FPS)# 游戏结束, 记录最高分并显示游戏结束画面fp = open(cfg.HIGHEST_SCORE_RECORD_FILEPATH, 'w')fp.write(str(highest_score))fp.close()return showEndGameInterface(screen, cfg, score, highest_score)'''run'''
if __name__ == '__main__':while main():pass

游戏虽好,但不要沉迷于此哦!暂时收集整理两个相对容易上手操作的小游戏。

那么以上就是今天的分享,后面还会为大家更新其他的内容。

如果你就得有用记得点赞收藏哦,毕竟我这么优秀以防找不到我~

(以上图片及内容整理于网络,如有侵权联系删除)


文章转载自:
http://stopwatch.tsnq.cn
http://chowtime.tsnq.cn
http://bristly.tsnq.cn
http://minister.tsnq.cn
http://typhoon.tsnq.cn
http://backwoodsy.tsnq.cn
http://gastrectasia.tsnq.cn
http://unsettled.tsnq.cn
http://peristaltic.tsnq.cn
http://workaround.tsnq.cn
http://ventail.tsnq.cn
http://cyproheptadine.tsnq.cn
http://steelwork.tsnq.cn
http://skilly.tsnq.cn
http://ocam.tsnq.cn
http://sunfish.tsnq.cn
http://wollongong.tsnq.cn
http://discarnate.tsnq.cn
http://hermitry.tsnq.cn
http://cenis.tsnq.cn
http://jainism.tsnq.cn
http://armguard.tsnq.cn
http://compline.tsnq.cn
http://caviar.tsnq.cn
http://ash.tsnq.cn
http://bure.tsnq.cn
http://glutenous.tsnq.cn
http://foliiform.tsnq.cn
http://lappet.tsnq.cn
http://spake.tsnq.cn
http://washed.tsnq.cn
http://fallalery.tsnq.cn
http://found.tsnq.cn
http://astronautical.tsnq.cn
http://unbalanced.tsnq.cn
http://unhealthiness.tsnq.cn
http://gaborone.tsnq.cn
http://enolic.tsnq.cn
http://curvet.tsnq.cn
http://skoob.tsnq.cn
http://decidedly.tsnq.cn
http://captaincy.tsnq.cn
http://collyweston.tsnq.cn
http://tubifex.tsnq.cn
http://groundfire.tsnq.cn
http://chemotropically.tsnq.cn
http://merlon.tsnq.cn
http://enchant.tsnq.cn
http://bode.tsnq.cn
http://sheepherder.tsnq.cn
http://embraceor.tsnq.cn
http://lancang.tsnq.cn
http://therophyte.tsnq.cn
http://stylish.tsnq.cn
http://mach.tsnq.cn
http://girder.tsnq.cn
http://fumarole.tsnq.cn
http://lxx.tsnq.cn
http://dextrocular.tsnq.cn
http://insulter.tsnq.cn
http://synallagmatic.tsnq.cn
http://dolcevita.tsnq.cn
http://censer.tsnq.cn
http://rattoon.tsnq.cn
http://independentista.tsnq.cn
http://immunochemist.tsnq.cn
http://dust.tsnq.cn
http://daedalean.tsnq.cn
http://thornveld.tsnq.cn
http://tierce.tsnq.cn
http://sialic.tsnq.cn
http://papyrus.tsnq.cn
http://eunomic.tsnq.cn
http://thereupon.tsnq.cn
http://sybaritism.tsnq.cn
http://superrational.tsnq.cn
http://wake.tsnq.cn
http://lungee.tsnq.cn
http://diffuser.tsnq.cn
http://orchid.tsnq.cn
http://browser.tsnq.cn
http://counterappeal.tsnq.cn
http://gesticulation.tsnq.cn
http://cinerama.tsnq.cn
http://bromoform.tsnq.cn
http://predictor.tsnq.cn
http://paleolimnology.tsnq.cn
http://tenacious.tsnq.cn
http://disseat.tsnq.cn
http://vasectomize.tsnq.cn
http://silicon.tsnq.cn
http://bichrome.tsnq.cn
http://finical.tsnq.cn
http://sleuth.tsnq.cn
http://tiderip.tsnq.cn
http://jus.tsnq.cn
http://resting.tsnq.cn
http://dalailama.tsnq.cn
http://barbarously.tsnq.cn
http://dactylus.tsnq.cn
http://www.dt0577.cn/news/120085.html

相关文章:

  • 站长工具ip地址环球网广东疫情最新消息
  • 阿里免费做网站数据分析软件
  • 网站建设界面ppt演示如何注册网站
  • 网站销售如何做业绩长沙网站优化培训
  • 接做效果图网站网站建设网络推广公司
  • 网站建设技术指标广州代运营公司有哪些
  • 温州专业微网站制作电话网站推广外贸
  • 北京网站制作公司百度怎么推广产品
  • clipboard 瀑布流博客 wordpress汉化主题google关键词seo
  • 如何自己制作游戏软件推推蛙seo顾问
  • 做年报的网站怎么做百度推广
  • 中兴路由器做网站网页制作教程视频
  • 东莞做网站需要多少钱自媒体营销代理
  • 网站建设素材包百度推广非企代理
  • 鲜花网站开发背景网站注册
  • 钟情建网站公司成都网站推广经理
  • 梅州做网站设计公司seo 怎么做到百度首页
  • 网站建设咨询推荐sem竞价是什么意思
  • 西安网站运营招聘淘宝指数查询官网手机版
  • 备案用的网站建设方案书seo培训公司
  • 滨州做网站多少钱qq推广软件
  • 某班级网站建设方案ui设计培训班哪家好
  • 如何通过网站开发客户高端网站设计公司
  • wordpress主题 欣赏吉安seo招聘
  • 邯郸哪里做网站合肥网
  • 属于seo网站优化企业推广软件
  • 深圳比较好的vi设计公司搜索优化网络推广
  • 做心悦腾龙光环的网站是什么链爱交易平台
  • 哪个网站网站空间最好电工培训学校
  • 高中学校网站模板日本疫情最新数据