几年前写的小东西 主要是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. IIS Express中如何配置支持json

    今天在使用i18next的时候,由于要加载一个json的文件,但是在vs2013中一直加载不成功呢,经过上网查资料得知原来要配置iis express才能支持json文件的加载. 文件的默认位置在:C ...

  2. OCI_INVALID_HANDLE 什么原因

    查看oci.dll应用版本和服务器版本是否一致

  3. Oracle错误ORA-03113: end-of-file on communication channel处理办法

    oracle不能启动了,报错ORA-03113: end-of-file on communication channel (通信通道的文件结尾) 解决办法: SQL> startup ORAC ...

  4. hibernate总结四

    HIbernate-查询语句 Hibernate Query Language (HQL) 是一个面向对象的查询语言,与Sql相似, 相对于sql对表和列的操作, HQL是对持久对象和他们的属性进行操 ...

  5. 如何在Eclipse中开发并调试自己的插件(或者说如何将自己的代码插件化)

    Setting up Eclipse to create and debug plugins for ImageJ 最近在做一个关于卫星遥感全链路仿真的项目,由于项目是基于ImageJ开发,而Imag ...

  6. Java 工厂模式学习

    工厂模式分三种:简单工厂.工厂方法.抽象工厂.其中抽象工厂是用于多个产品族的情况.所谓产品族就是不同产品组成的有机整体,各不同产品之间相互依赖.打个比方,一台电脑有CPU.主板.内存和硬盘等,这些不同 ...

  7. PHP中date函数参数详解

    date函数输出当前的时间echo date('Y-m-d H:i:s', time()); // 格式:xxxx-xx-xx xx:xx:xx 第一个参数的格式分别表示: a - "am& ...

  8. linux shell 札记

    shell 数组 数组索引: 单个元素索引: ${array[n]} 全部元素:   ${array[*]}  或者  ${array[@]} 部分索引: ${array[2:]} 数组所有元素统一加 ...

  9. Linux中的cron计划任务配置方法(详细)

    cron来源于希腊单词chronos(意为“时间”),指Linux系统下一个自动执行指定任务的程序(计划任务) 1. crontab命令选项 #crontab -u <-l, -r, -e> ...

  10. 在VC6.0下如何调用Delphi5.0开发的进程内COM

    因为本人的语言水平很差,考大学时150的总分,我考了个60分.外语也是,初中及格过一次,会考及格过一次.其它的时间好像从没有及格过.所以我不写文章,因我一百字的文章给我写,至少要出八九个错别字.哈哈… ...