player

【python游戏编程之旅】第九篇---嗷大喵快跑小游戏开发实例

橙三吉。 提交于 2019-12-21 01:13:33
本系列博客介绍以python+pygame库进行小游戏的开发。有写的不对之处还望各位海涵。 前几期博客我们一起学习了,pygame中的 冲突检测技术 以及一些 常用的数据结构 。 这次我们来一起做一个简单的酷跑类游戏综合运用以前学到的知识。 程序下载地址: https://pan.baidu.com/s/1Ji2Ubsds6z2brBx8Gz1OOw 提取码:dff4 源代码网盘地址: https://pan.baidu.com/s/1T7tlYbTNUPRhtJ45B6PAPw 提取码:mhip github地址: https://github.com/XINCGer/catRunFast 效果图: 现在我们来分析一下制作流程: 游戏中一共有嗷大喵,恶龙,火焰,爆炸动画和果实(就是上方蓝色的矩形块)这几种精灵。这里我们使用到了前几期博客中的MyLibrary.py。上述这几个精灵都是 MySprite类实例化的对象。 为了方便管理。我们建立了几个精灵组,并且将一些精灵塞到了里面: #创建精灵组 group = pygame.sprite.Group() group_exp = pygame.sprite.Group() group_fruit = pygame.sprite.Group() #创建怪物精灵 dragon = MySprite() dragon.load(

SQLite语句

微笑、不失礼 提交于 2019-12-21 01:02:30
搜索某属性: select exp from player where level = 2; 创建表: create table player (level integer primary key, name text); 删除表: drop table player; 更新数据: update player set exp = 300 where level = 2; 插入数据: insert into player (level, exp) values ('2', '200'); insert into player values ('2', '200'); 复制表: create table newtable as select * from oldtable where rowid = 1 获得所有table名: select name from sqlite_master where type='table' order by name; 来源: https://www.cnblogs.com/zhenlong/p/5387574.html

react & youtube

旧巷老猫 提交于 2019-12-18 01:26:12
react & youtube https://www.npmjs.com/package/react-youtube https://developers.google.com/youtube/iframe_api_reference 通过 IFrame Player API,您可以在自己的网站上嵌入 YouTube 视频播放器并使用 JavaScript 控制播放器。 与 Flash 和 JavaScript Player API 不同的是,这两者都要求在您的网页上嵌入一个 Flash 对象,而 IFrame API 会将内容发布到网页上的 <iframe> 标记中。 这种方法比之前提供的 API 更加灵活,因为它允许 YouTube 针对不支持 Flash 的移动设备提供 HTML5 播放器(而非 Flash 播放器)。 demo <!DOCTYPE html> <html> <body> <!-- 1. The <iframe> (and video player) will replace this <div> tag. --> <div id="player"></div> <script> // 2. This code loads the IFrame Player API code asynchronously. var tag = document

go语言,struct and interface(golang)(二)

為{幸葍}努か 提交于 2019-12-17 05:21:37
go语言包含但不限于int32,float32,chan,map,slice等内建类型,同时为了能让用户定义自己的类型,go语言为我们提供了struct和interface这两种好用的工具 结构体(Struct) 和C语言的struct相似,在go语言中,我们依然用struct来声明一个结构体比如: type gameObject struct{ name string } 以上代码声明了一个名为gameObject的结构体,该结构体包含类型为string的字段name。 在go语言中,所有的类型名都是放在变量后面的,这也是go语言跟C/C++,JAVA,C#等语言区别比较大的地方。 既然有了struct,那有没有class呢? 没有class,go语言中的“面向对象”概念和上面提到的几种语言是有很大区别的,后面会讲到 嵌入(Embedding) go语言中的“继承”和其他语言中的继承有很大区别,比如: type player struct{ gameObject } 这是一种“继承”的写法,在go语言中这种方式叫做“嵌入”(embed),此时player类型就拥有了gameObject类型的name变量 方法(Method) 在go语言中,我们可以为自定义类型定义类型相关的方法,比如: func (p *player) Name() string{ return p.name }

WPF 播放声音的三种方法

我的未来我决定 提交于 2019-12-16 23:49:26
  单位近日要办一个歌唱比赛,小丸被委托开发一个随机选人的小工具,想到之前在园子里收藏过一篇 《年终了,大家年会有抽奖不?共享个WPF的抽奖程序吧[源码]》 ,马上找出来看。   阅读代码之后发现:这位大神的3D圆环效果使用Canvas直接瞄坐标绘制,图形学渣渣表示相当钦佩。实际使用中流畅程度也可以接受,只是少了音乐和音效总感觉不太舒服。所以决定添加音乐和音效。   搜索了一番后找到三个方法, 方法一:古老的SoundPlayer类   它是.NET Framework 2.0的一部分,是对Win32 PlaySound API的封装。   它具有以下特征 1) 仅支持.wav音频文件 2) 不支持同时播放多个音频(任何新播放的操作将终止当前正在播放的) 3) 无法控制声音的音量 4) 支持同步、异步播放 5) 支持循环播放 6) 支持文件和流播放   下面的代码展示了如何使用SoundPlayer播放声音: 简单范例 SoundPlayer player = new SoundPlayer("next.wav"); player.Play(); 同步播放: System.Media.SoundPlayer player = new System.Media.SoundPlayer(); player.SoundLocation = @"d:\music\happy.mp3";

AE方法——查询(一)

泪湿孤枕 提交于 2019-12-16 19:03:57
查询是GIS不可或缺的功能,今天我写一下我近期对查询的理解。先说说属性查询; A 查询主要涉及接口: 1.IQueryFilter 通过设置这个接口的WhereClause属性来作为查询条件,本属性的语句为SQL的where后的条件语句。 2.IFeatureLayer 矢量图层,一般由ILayer进行转化。该接口的Search方法进行查询,Search方法的参数有两个,前面的是IQueryFilter对象 ,后面的是bool值,一般设为false. 3.IFeature 要素接口,用来接收查询出来的要素。 4.IFeatureCursor 游标接口,通过Search进行查询,可以讲结果保存在这里,从而利用NextFeature方法,遍历所有要素。 B 基本的思想 获取图层,设置条件,进行查询,显示要素类。 C 如何获取IFeatureLayer 地图的图层的索引从0开始,一般通过get_Layer方法或者Layer属性获取ILayer,然后将ILayer强制转换为IFeatureLayer。 D 举例 下面是一个整体的过程。 首先定义一个方法: /// <summary> /// 查询并高亮显示 /// </summary> /// <param name="sql">为WhereClause赋值</param> /// <param name="pLayer">图层

CS102A Fall 2019 Project:

怎甘沉沦 提交于 2019-12-11 12:34:06
CS102A Fall 2019 Project: Xiangqi (象棋, Chinese Chess) Figure 1: Board of Xiangqi Introduction Xiangqi is a strategy board game for two players. It is one of the most popular board games in China. The game represents a battle between two armies, with the object of capturing the enemy’s general (將/帥). The introduction of this game below is heavily adopted from the wiki page. 1 Board Xiangqi is played on a board nine lines wide and ten lines long. Centred at the first to third and eighth to tenth rows of the board are two zones, each three points by three points, demarcated by two diagonal lines

【c++设计模式】代理模式

落花浮王杯 提交于 2019-12-10 22:49:17
结构型模式 10)代理模式 本文参考 https://www.cnblogs.com/wrbxdj/p/5267370.html 代理模式贯彻了面对对象程序的开闭原则(对修改关闭,对扩展开放),在不改变原本类的情况下,修改用户的使用接口。 也就是为其他类提供一种代理,以控制对这个类的访问。真正调用时只让代理出现,不让真正的用户出现。 一般来说包括两个角色: 第一种,对象类。 第二种,代理类。 需要注意的是上面两个角色需要继承自同一基类。 例如在游戏中,通过代理来控制不同用户的访问权限。 //基本游戏接口 class play{ public: virtual void play1() = 0; virtual void play2() = 0; }; //玩家接口 class player : public play{ public: void play1(){ cout<<"装备1"<<endl; } void play2(){ cout<<"装备2"<<endl; } void play3(){ cout<<"装备3"<<endl; } }; //代理玩家1 class proxyPlayer1 : public play{ public: proxyPlayer1(){ m_player = new player(); } void play1(){ m_player-

LightOJ - 1318 - Strange Game(组合数)

冷暖自知 提交于 2019-12-10 22:03:17
链接: https://vjudge.net/problem/LightOJ-1318 题意: In a country named "Ajob Desh", people play a game called "Ajob Game" (or strange game). This game is actually a game of words. The rules for the game are as follows: It's an N player game and players are numbered from 1 to N. And the players alternate turns in a circular way. Player 1 starts first. The next turn is for player 2, then player 3 and so on. After the turn for the Nth player, player 1 gets his turn again and the same procedure is continued. In each turn a player has to propose a pair of words. Each of the words should have length L,

Android多媒体操作

若如初见. 提交于 2019-12-10 13:11:29
MediaPlayer 实现思路 本地音频资源播放 播放本地音频资源实例化MediaPlayer对象,依次调用:setDataSource、prepare()、start()方法,获取资源文件路径及准备资源文件,最后播放音频文件。 网络音频资源播放 播放网络资源首先需要得到网络访问权限。(代码见下方),使用prepareAsync()方法准备音频资源,使用setOnPreparedListener()方法监听资源准备情况,最后于onPrepared()方法中执行start()方法播放音频资源。 <uses-permission android:name="android.permission.INTERNET"/> 代码实现 Layout <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical">