player

2D游戏开发-第三周作业

家住魔仙堡 提交于 2020-03-17 20:40:25
某厂面试归来,发现自己落伍了!>>> 1.坦克大战 import os,sys,pygame from pygame.locals import * def control_tank(event): speed=[x,y]=[0,0] speed_offset=1 if event.type==pygame.KEYDOWN: if event.key==pygame.K_LEFT: speed[0]-=speed_offset if event.key==pygame.K_RIGHT: speed[0]=speed_offset if event.key==pygame.K_UP: speed[1]-=speed_offset if event.key==pygame.K_DOWN: speed[1]=speed_offset if event.type==pygame.KEYUP: if event.type in [pygame.K_UP,pygame.K_DOWN,pygame.K_RIGHT,pygame.K_LEFT]: speed=[0,0] return speed def play_tank(): pygame.init() window_size=Rect(0,0,640,480) speed=[1,1] color_white=[255,255,255]

基于pygame的游戏

谁说我不能喝 提交于 2020-03-17 20:40:04
某厂面试归来,发现自己落伍了!>>> 基于pygame的游戏 pygame 简介 首先,让我们简要回顾一下Pygame的历史吧~ Pygame最初是由Pete Shinner编写的,该项目于2000年10月启动,六个月后,pygame版本1.0发布。pygame是一个利用SDL(Simple DirectMedia Layer)写就的游戏库。SDL 是一个用于控制多媒体的跨平台C库,与DirectX相当,它已被用于数百种商业和开源游戏。Pete Shinner对Python和SDL两个项目的简洁与优雅印象深刻,他决定将Python和SDL结合起来,组建一个真正利用Python的项目,目标是让做简单的事情变得容易,让困难的事情变简单。 如何安装pygame 非常的easy! 直接打开运行cmd 输入pip install pygame 就可啦 好了 下面我们做一些pygame的基础操作 pygame基础 一、pygame窗口 1.导入pygame模块 2.设置窗口大小和窗口名称 3.参考代码 import pygame from pygame.locals import * import sys def hello_world(): pygame.init() pygame.display.set_mode((640,480)) pygame.display.set_caption(

第三周:2d游戏制作作业

别说谁变了你拦得住时间么 提交于 2020-03-17 19:34:59
某厂面试归来,发现自己落伍了!>>> 1. import pygame,sys,time,random from pygame.locals import * pygame.init() fpsClock = pygame.time.Clock() playSurface = pygame.display.set_mode(( 640 , 480 )) pygame.display.set_caption( ' 贪吃蛇游戏 ' ) # 定义一些颜色 redColour = pygame.Color( 255 , 0 , 0 ) blackColour = pygame.Color( 0 , 0 , 0 ) whiteColour = pygame.Color( 255 , 255 , 255 ) greyColour = pygame.Color( 150 , 150 , 150 ) # 初始化了一些程序中用到的变量 snakePosition = [ 100 , 100 ] snakeSegments = [[ 100 , 100 ], [ 80 , 100 ], [ 60 , 100 ]] raspberryPosition = [ 300 , 300 ] # 位置 raspberrySpawned = 1 # 是否吃到树莓 direction = 'right'

Python--pygame游戏开发

倾然丶 夕夏残阳落幕 提交于 2020-03-16 20:49:38
某厂面试归来,发现自己落伍了!>>> 利用python中的pygame模块来进行2D游戏开发。 Pygame 是跨平台 Python 模块,专为电子游戏设计。包含图像、声音。创建在 SDL 基础上,允许实时电子游戏研发而无需被低级语言,如 C 语言或是更低级的汇编语言束缚。基于这样一个设想,所有需要的游戏功能和理念都完全简化位游戏逻辑本身,所有的资源结构都可以由高级语言提供,如 Python 本次实验为 验证性作业 ,代码为 老师 所给. 开发坏境:Python3.8.0 + Pygame1.9.6 开发工具:PyCharm 2019.3.3 x64 基础 安装pygame,在安装好python的基础上在cmd指令中输入 pip install pygame 安装完毕,打开pycharm from pygame.locals import * import sys def hellow_world(): pygame.init() pygame.display.set_mode((640, 480)) pygame.display.set_caption("hellow world!") while True: for event in pygame.event.get(): if event.type==QUIT: pygame.quit() sys.exit() pygame

2d游戏开发学习笔记(3)——基于pygame的小游戏开发

耗尽温柔 提交于 2020-03-15 20:28:26
- 一.pygame基础知识 pygame有大量可以被独立使用的模块。 pygam.display-显示模块 pygame.keyboard-键盘模块 pygame.mouse-鼠标模块 二.pygame基础测试 1.首先安装pygame,打开cmd使用pip安装pygame: pip install pygame 2.在pycharm中导入pygame模块 3.设置窗口大小和窗口名称 参考代码如下: import pygame from pygame.locals import * import sys def hello_world(): pygame.init() pygame.display.set_mode((640,480)) pygame.display.set_caption("hello world") while True: for event in pygame.event.get(): if event.type==QUIT: pygame.quit() sys.exit() pygame.display.update() if __name__=="__main__": hello_world() 运行效果如图: 精灵的使用 介绍: Pygame 提供了两个类 pygame.sprite.Sprite —— 存储 图像数据 image 和 位置 rect

pygame之打飞机

一笑奈何 提交于 2020-03-15 14:46:06
游戏介绍 敌人落地前消灭 消灭加分 否则结束 代码 ''' @Author: your name @Date: 2020-03-15 12:40:53 @LastEditTime: 2020-03-15 12:59:20 @LastEditors: Please set LastEditors @Description: In User Settings Edit @FilePath: \3.14\feiji.py ''' import pygame from sys import exit from pygame.locals import * import random SCREEN_WIDTH=480 SCREEN_HEIGHT = 800 TYPE_SMALL=1 TYPE_MIDDLE=2 TYPE_BIG=3 class Bullet(pygame.sprite.Sprite): def __init__(self, bullet_img, init_pos): pygame.sprite.Sprite.__init__(self) self.image = bullet_img self.rect = self.image.get_rect() self.rect.midbottom = init_pos self.speed = 10 def move(self):

ubuntu下安装flash player

一曲冷凌霜 提交于 2020-03-13 09:24:10
  首先下载linux版的flash player,解压后进入文件之后,可以发现有个叫“libflashplayer.so”的文件。把这个libflashplayer.so文件复制到文件系统的/usr/lib/mozilla/plugins目录下。   在终端直接使用命令:sudo cp libflashplayer.so /usr/lib/mozilla/plugins   接下来,执行下面的命令:nspluginwrapper -i /usr/lib/mozilla/plugins/libflashplayer.so   此后,只要重启一下浏览器,就可以发现flash player插件已经安装好了   注意:在执行命令 nspluginwrapper -i /usr/lib/mozilla/plugins/libflashplayer.so 的时候,可能会提示安装nspluginwrapper ,这个时候,只要用命令sudo apt-get install nspluginwrapper 之后就可以使用上述的命令来安装flash player了。 来源: https://www.cnblogs.com/xingfuzzhd/archive/2012/09/05/2672014.html

pygame----打飞机

我的梦境 提交于 2020-03-12 11:51:36
开发工具:pycharm 游戏介绍:游戏开始时,一群外星人出现,他们在屏幕中向下移动,玩家的任务就是发射子弹消灭敌人,每消灭一个敌人,玩家积累一分。当敌人落地前未被玩家消灭,则游戏结束。 程序设计步骤: 1.游戏初始化 2.定义子弹类 3.定义玩家类 4.定义敌人类 5.设置游戏机制 6.游戏结束 一,游戏初始化 SCREEN_WIDTH= 480 SCREEN_HEIGHT = 800 TYPE_SMALL= 1 TYPE_MIDDLE= 2 TYPE_BIG= 3 二,定义子弹类 def __init__ ( self , bullet_img , init_pos): pygame.sprite.Sprite. __init__ ( self ) self .image = bullet_img self .rect = self .image.get_rect() self .rect.midbottom = init_pos self .speed = 10 三,定义玩家类 1.设置玩家基本参数 def __init__ ( self , plane_img , player_rect , init_pos): pygame.sprite.Sprite. __init__ ( self ) self .image = [] # 用来存储玩家飞机图片的列表 for i in

Flash Player 32.0.0.344 大全

倾然丶 夕夏残阳落幕 提交于 2020-03-12 09:33:50
2020年11月3日–更新了Flash Player的调试器和独立版本,这些版本包含关键修复程序。最新版本是32.0.0.344(Windows) 通用版 : https://www.flash.cn/cdm/latest/flashplayerpp_install_cn.exe 独立播放器 : https://www.flash.cn/cdm/latest/flashplayer_sa.exe 独立播放器内容调试器 : https://www.flash.cn/cdm/latest/flashplayer_sa_debug.exe Opera.Chromium内容调试器 : https://www.flash.cn/cdm/latest/flashplayerpp_install_cn_debug.exe PPAPI Internet Explorer内容调试器 : https://www.flash.cn/cdm/latest/flashplayerax_install_cn_debug.exe ActiveX Firefox内容调试器 : https://www.flash.cn/cdm/latest/flashplayer_install_cn_debug.exe NPAPI 注:Internet Explorer内容调试器仅适用于Windows 7及以下版。

Linux 更新后异常(kernel 版本 3.17) VMware player

家住魔仙堡 提交于 2020-03-10 22:21:27
前几天手欠把linux的内和从3.16 升级到 3.17,结果就悲剧了,VMware不能正常启动了,一直报一个错误。 我这里的linux版本为:fedora20,其他发行版本也一样; VMware player版本: VMware-Player-6.0.4-2249910.x86_64.bundle 错误信息大概为: before you can run vmware several modules must be compiled and loaded into the running kernel; 大概的意思就是说,运行vmware虚拟机前需要编译linux的内核; 我天朝大百度搜不出来什么结果..希望提醒后来者低碳生活,远离百度; 好了,不说废话,放上解决方案: 第一步、cd到这个目录下找到文件:vmnet.tar cd /usr/lib/vmware/modules/source/ 第二步、修改这个文件前最好先备份一下,重新建立个文件夹: mkdir vmnet_bak 第三步、将vmnet.tar 拷贝到 vmnet_bak下 cp vmnet.tar vmnet_bak/ 第四步、用tar命令解压 vmnet.tar 并修改文件 netif.c 找到行号130: 文件内容: /**********************************************