几年前写的小东西 主要是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版本打泡泡的更多相关文章

  1. 带你使用h5开发移动端小游戏

    带你使用h5开发移动端小游戏 在JY1.x版本中,你要做一个pc端的小游戏,会非常的简单,包括说,你要在低版本的浏览器IE8中,也不会出现明显的卡顿现象,你只需要关心游戏的逻辑就行了,比较适合逻辑较为 ...

  2. 一、微信小游戏开发 --- 初次在微信开发者工具里跑Egret小游戏项目

    尝试下Egret的小游戏开发,学习,学习,干IT,不学习,就得落后啊... 相关教程: Egret微信小游戏教程 微信公众平台-微信小游戏教程 微信公众平台-微信小游戏接入指南 开发版本: Egret ...

  3. 无聊的周末用Java写个扫雷小游戏

    周末无聊,用Java写了一个扫雷程序,说起来,这个应该是在学校的时候,写会比较好玩,毕竟自己实现一个小游戏,还是比较好玩的.说实话,扫雷程序里面核心的东西,只有点击的时候,去触发更新数据这一步. Sw ...

  4. C/C++,彩色图像小游戏。

    这里声明,这个游戏是由本人,在大一暑假自作的第二个小游戏,转载请注明原帖地址,谢谢! 所有图片都是我一个人用ps搞出来的,比较简单.........毕竟不是学图像制作的,请体谅!另外,图片 不放出来了 ...

  5. Egret白鹭H5小游戏开发入门(一)

    前言: 好久没更新博客了,以前很多都不会,所以常常写博客总结,倒是现在有点点经验了就懒了.在过去的几个月里,在canvas游戏框架方面,撸过了CreateJS,玩得了Egret,又学过PIXI.js. ...

  6. Swift实战之2048小游戏

    上周在图书馆借了一本Swift语言实战入门,入个门玩一玩^_^正好这本书的后面有一个2048小游戏的实例,笔者跟着实战了一把. 差不多一周的时间,到今天,游戏的基本功能已基本实现,细节我已不打算继续完 ...

  7. 恶趣味小游戏 I'm hungry

    之前学算法的时候无聊做了个游戏放松放松,现在传到了github以免电脑坏了就永远丢失了... github地址:https://github.com/BenDanChen/IamHungry I am ...

  8. 通通的最后一篇博客(附自制html5平面射击小游戏一枚)

    这是我最后一篇博客了,由于本人的人生规划吧,以后应该也写不出什么好的技术文章了,到现在在博客园写了2年, 今天一看,我也有了120个粉丝,好几万的浏览量,感谢大家的支持啊~~ 半年没有写博客了,由于半 ...

  9. 12岁的少年教你用Python做小游戏

    首页 资讯 文章 频道 资源 小组 相亲 登录 注册       首页 最新文章 经典回顾 开发 设计 IT技术 职场 业界 极客 创业 访谈 在国外 - 导航条 - 首页 最新文章 经典回顾 开发 ...

随机推荐

  1. 在spring中进行基于Executor的任务调度

    Executor java.util.concurrent.Executor接口的主要目的是要将“任务提交”和“任务执行”两者分离解耦.该接口定义了任务提交的方法,实现者可以提供不同的任务运行机制,解 ...

  2. oracle tablespace

    oracle tablespace 1. 查看所有表空间大小 SQL> select tablespace_name,sum(bytes)/1024/1024 from dba_data_fil ...

  3. SVN导出增量包的方法

    此方法是在svn1.7版本基础上进行的操作,其他版本没有验证 第一步.点击右键,选择“TortoiseSVN–> Show log”. 进入日志页面,如下图所示: 第二步.选择版本区间,右键选择 ...

  4. Windows中的对象

    来源  http://www.0xaa55.com/forum.php?mod=viewthread&tid=1401&extra=page%3D1  windows里常用句柄操作资源 ...

  5. [STL源码剖析]RB-tree的插入操作

    RB-tree的性质 对于RB-tree,首先做一个了解,先看一张维基百科的RB-tree: 再看RB-tree的性质: 性质1. 节点是红色或黑色. 性质2. 根是黑色,所有叶子都是黑色(叶子节点指 ...

  6. 浅谈C中的指针和数组(五)

    前面写了一些C指针和数组的一些知识,但是还有一些很重要的知识没有交代,这里做一个补充. 首先看一下,普通变量(指针也是变量)和数组名查看地址的方式是不同的. 查看数组变量的地址,不需要使用 & ...

  7. Centos for php+mysql+apache

    一.安装 MySQL 首先来进行 MySQL 的安装.打开超级终端,输入: [root@localhost ~]# yum install mysql mysql-server 安装完毕,让 MySQ ...

  8. 随意记的一点 js 笔记

    1. 给未经声明的变量赋值在严格模式下会导致抛出 ReferenceError 错误(意思是,所有变量都必须用 var 去定义,不能在函数内部定义全局变量): 2. 在严格模式下,不能定义名为 eva ...

  9. OpenCV学习 4:摄像头视频读写与边缘检测

    原创文章,欢迎转载,转载请注明出处 想实现人脸识别,车辆识别,车牌识别.一般我们可不是读硬盘里面的视频文件的,都是直接从摄像头读取视频流然后直接识别的.所以读取摄像头的视频流这是基础...OpenCV ...

  10. android 读写sd卡的权限设置

    原文:android 读写sd卡的权限设置 在Android中,要模拟SD卡,要首先使用adb的mksdcard命令来建立SD卡的镜像,如何建立,大家上网查一下吧,应该很容易找到,这里不说这个问题. ...