几年前无聊小游戏之作_WEB版本打泡泡
几年前写的小东西 主要是H5画布的操作,还有个C语言基于WIN SDK开发的版本 找不到代码了 找到了再分享 <!DOCTYPE html>
<script src="game/jquery190.js"></script>
<body id="box" style="background: #000000;TEXT-ALIGN: center;margin-top: 0px;"> <div style="margin:0 auto;">
<canvas id="map" width="360" height="580"></canvas>
</div>
<audio src="game/back.wav" loop="loop" autoplay="autoplay">
</audio>
<audio id ="kill" src="game/kill.wav">
</audio>
<script>
// JQ CODE start
$(function() { // JQ按键处理
$("#box").keyup(function(e) {
game.OnKeyUp(e.keyCode);
}); });
// JQ CODE end // 实体类==============================
var Ball = function(src, x, y, w, h) {
this.imger = new Image();
this.number = 0;
this.x = 0;
this.y = 0;
this.w = 0;
this.h = 0;
// Y轴移动增量
this.moveYSet = 1;
// 键值
this.keyVal = 0;
// 层格编号
this.layerNumber = 0;
this.MoveY = function() {
if (this.y >= 580) {
this.y = 0;
}
this.y += this.moveYSet;
}
}; var Map = function() {
this.img = null;
this.w = 900;
this.h = 580;
};
// 层格
var Layer = function() {
// 设置球球状态
this.isSetBall = 0;
this.x = 0;
this.y = 0;
// 球球实体
this.ball = null;
this.number = 0; }; var Game = function() {
// 球球实数组
this.ballHandle = new Array();
// 球球总数
this.ballCount = 27;
// 地图实体
this.maper = new Map(); this.ctx = null;
// 层格
this.layer = new Array();
this.layerCount = 7;
this.killPlayer = null; // A-Z键码表
this.keyVals = [0,65, 66,67,68,69,70,71,72,73,74,
75,76,77,78,79,80,81,82,83,84,85,86,
87,88,89,90]; this.OnKeyUp = function(keyVal) { for (i = 1; i < this.layerCount; i++)
{
if (this.layer[i].ball.keyVal==keyVal){ this.layer[i].isSetBall = 0;
/*
* 播放击中声音,命中率高的时候声音会不同步,考虑做到woker里
*/
this.killPlayer.play();
return false; }
}
}
// test
this.GetIndexSechm = function(){
var k = UtilManage.FrandomBy(1,26);
for (i = 1; i < this.layerCount; i++){
if (this.layer[i].ball.number == k){
this.GetIndexSechm();
}
}
return k; } this.Start = function()
{
this.ctx.drawImage(this.maper.img, 0, 0, 900, 580); for (i = 1; i < this.layerCount; i++)
{
if (this.layer[i].isSetBall==0)
{ this.layer[i].ball = this.ballHandle[UtilManage.FrandomBy(1,26)];
this.layer[i].ball.y = 0;
this.layer[i].isSetBall = 1;
this.layer[i].ball.layerNumber = this.layer[i].number;
}
} for (i = 1; i < this.layerCount; i++)
{
this.layer[i].ball.x = this.layer[i].x; this.ctx.drawImage( this.layer[i].ball.imger,
this.layer[i].ball.x,
this.layer[i].ball.y,
60,
60);
this.layer[i].ball.MoveY(); } } }; // 工具管理器
UtilManage = { FrandomBy:function(under, over) {
switch (arguments.length) {
case 1:
return parseInt(Math.random() * under + 1);
case 2:
return parseInt(Math.random() * (over - under + 1) + under);
default:
return 0;
}
} }; // 游戏管理器
var GameManage = { Run: function() {
GameManage.InitResource();
},
// 初始化游戏数据
InitResource: function() { game = new Game();
// 坐标校正
var ballXofs = 0; for (i = 1; i < game.layerCount; i++)
{ game.layer[i] = new Layer();
game.layer[i].number++ ; // 设置层格X坐标
game.layer[i].x = ballXofs + 2;
ballXofs += (60); } for (i = 1; i < game.ballCount; i++) { game.ballHandle[i] = new Ball();
game.ballHandle[i].number = i;
game.ballHandle[i].keyVal = game.keyVals[i];
game.ballHandle[i].imger = new Image();
game.ballHandle[i].imger.src = "game/" + i + ".png"; } game.maper.img = new Image();
game.maper.img.src = "game/bg.jpg";
game.killPlayer = document.getElementById("kill");
game.ctx = (document.getElementById("map")).getContext("2d"); setInterval("game.Start()", 50); }
}; GameManage.Run(); </script> </body>
</html>
几年前无聊小游戏之作_WEB版本打泡泡的更多相关文章
- 带你使用h5开发移动端小游戏
带你使用h5开发移动端小游戏 在JY1.x版本中,你要做一个pc端的小游戏,会非常的简单,包括说,你要在低版本的浏览器IE8中,也不会出现明显的卡顿现象,你只需要关心游戏的逻辑就行了,比较适合逻辑较为 ...
- 一、微信小游戏开发 --- 初次在微信开发者工具里跑Egret小游戏项目
尝试下Egret的小游戏开发,学习,学习,干IT,不学习,就得落后啊... 相关教程: Egret微信小游戏教程 微信公众平台-微信小游戏教程 微信公众平台-微信小游戏接入指南 开发版本: Egret ...
- 无聊的周末用Java写个扫雷小游戏
周末无聊,用Java写了一个扫雷程序,说起来,这个应该是在学校的时候,写会比较好玩,毕竟自己实现一个小游戏,还是比较好玩的.说实话,扫雷程序里面核心的东西,只有点击的时候,去触发更新数据这一步. Sw ...
- C/C++,彩色图像小游戏。
这里声明,这个游戏是由本人,在大一暑假自作的第二个小游戏,转载请注明原帖地址,谢谢! 所有图片都是我一个人用ps搞出来的,比较简单.........毕竟不是学图像制作的,请体谅!另外,图片 不放出来了 ...
- Egret白鹭H5小游戏开发入门(一)
前言: 好久没更新博客了,以前很多都不会,所以常常写博客总结,倒是现在有点点经验了就懒了.在过去的几个月里,在canvas游戏框架方面,撸过了CreateJS,玩得了Egret,又学过PIXI.js. ...
- Swift实战之2048小游戏
上周在图书馆借了一本Swift语言实战入门,入个门玩一玩^_^正好这本书的后面有一个2048小游戏的实例,笔者跟着实战了一把. 差不多一周的时间,到今天,游戏的基本功能已基本实现,细节我已不打算继续完 ...
- 恶趣味小游戏 I'm hungry
之前学算法的时候无聊做了个游戏放松放松,现在传到了github以免电脑坏了就永远丢失了... github地址:https://github.com/BenDanChen/IamHungry I am ...
- 通通的最后一篇博客(附自制html5平面射击小游戏一枚)
这是我最后一篇博客了,由于本人的人生规划吧,以后应该也写不出什么好的技术文章了,到现在在博客园写了2年, 今天一看,我也有了120个粉丝,好几万的浏览量,感谢大家的支持啊~~ 半年没有写博客了,由于半 ...
- 12岁的少年教你用Python做小游戏
首页 资讯 文章 频道 资源 小组 相亲 登录 注册 首页 最新文章 经典回顾 开发 设计 IT技术 职场 业界 极客 创业 访谈 在国外 - 导航条 - 首页 最新文章 经典回顾 开发 ...
随机推荐
- C# Log4Net使用指南(转)
1 简介 1.1 Log4net的优点: 几乎所有的大型应用都会有自己的用于跟踪调试的API.因为一旦程序被部署以后,就不太可能再利用专门的调试工具了.然而一个管 ...
- attribute和property兼容性分析
上一篇文章中,详细的分析了他们的区别,请看Javascript中的attribute和property分析 这次,来详细的看下他们的兼容性,这些内容主要来自于对于jQuery(1.9.x)源代码的分析 ...
- windbg命令学习1
一.windbg 常用知识: 1. Windbg中的调试命令,分为三种:基本命令,元命令和扩展命令.基本命令和元命令是调试器自带的,元命令总是以“.”开头,而扩展命令是外部加入的,总是以感叹号“!”开 ...
- CentOS rc.local 不执行的问题
centos7 开机/etc/rc.local 不执行的问题 时间:2015-02-09 00:54来源:blog.51cto.com 作者:“闲潭小筑” 博客, 举报 点击:次 最近发现centos ...
- ENVISAT卫星及ASAR数据介绍
摘要: ENVISAT卫星是欧空局的对地观测卫星系列之一,于2002年3月1日发射升空.该卫星是欧洲迄今建造的最大的环境卫星.星上载有10种探测设备,其中4种是ER S-1/2所载设备的改进型,所载最 ...
- Tempo 2.0
Tempo 2.0 Tempo is an easy, intuitive JavaScript rendering engine that enables you to craft data tem ...
- WEKA,一个开源java的数据挖掘工具
开始研究WEKA,一个开源java的数据挖掘工具. HS沉寂这么多天,谁知道偏偏在我申请离职的时候给我安排了个任务,哎,无语. 于是,今天看了一天的Weka. 主要是看了HS提供的三个文章(E文,在g ...
- 一个Windows C++的线程类实现
Thread.h [cpp] view plaincopy #ifndef __THREAD_H__ #define __THREAD_H__ #include <string> #inc ...
- 分析Ext2文件系统结构。
1. 目的 分析Ext2文件系统结构. 使用 debugfs 应该跟容易分析 Ext2文件系统结构 了解ext2的hole的 2. 准备工作 预习文件系统基本知识: http://www.doc88. ...
- 备机大地院系项目dataguard archived_log及standby_log
主库archivelog及standbylog 仅仅是测试4天的数据,项目并未正式上线/data/dddb/DBSoftware/app/oracle/product/11.2.0/dbhome_1/ ...