<html>
<head>
<title>0.0</title>
<script>
window.onload=function Test(){
alert("游戏提示,本游戏没有关卡限制,每次得分超过整百时,进入下一关,点击确定开始游戏吧!");
var game=new Game();
game.start();
}
var times;
var words;
var down=2;
var fen=100;
var createCharDiv=new Array();
function Game(){
//alert("coming game()");
words=new Array("A","B","C","D","E","F","G","H","I","J","K","L","N","M","O","P","Q","R","S","T","U","V","W","Z","X","Y");
var createBackground=new CreateBackground();
var createScore=new CreateScore();
//var createCharDiv=new CreateCharDiv();
this.start=function(){
for(var i=0;i<5;i++){
createCharDiv[i]=new CreateCharDiv();
}
times=setInterval(function(){
for(var i=0;i<5;i++){
createCharDiv[i].move();
}
},50);
document.onkeydown=keydown;
function keydown(e){
var real=String.fromCharCode(e.which);
//alert(real);
for(var i=0;i<5;i++){
if(createCharDiv[i].divHTML()==real){
//alert("zhong");
createScore.addScore();
createCharDiv[i].againTop();
}
}
}
}
}
function CreateBackground(){
//alert("coming CreateBackground()");
var newBackground;
function initBackground(){
//alert("coming initBackground()");
newBackground=document.createElement("div");
//alert(newBackground);
newBackground.style.width="500px";
newBackground.style.height="600px";
newBackground.style.border="3px solid black";
newBackground.style.position="absolute";
//newBackground.style.background="pink";
document.body.appendChild(newBackground);
}
initBackground();
}
function CreateScore(){
//alert("1");
var scoreboard;
var score=0;
function initScore(){
//alert("2");
scoreboard=document.createElement("div");
scoreboard.style.width="100px";
scoreboard.style.height="20";
scoreboard.style.top="10px";
scoreboard.style.left="405px";
scoreboard.style.position="absolute";
scoreboard.style.border="3px solid black";
scoreboard.style.background="green";
scoreboard.innerHTML="得分:"+score;
document.body.appendChild(scoreboard);
//alert(scoreboard);
}
initScore();
this.addScore=function(){
score+=10;
scoreboard.innerHTML="";
scoreboard.innerHTML="得分:"+score;
if(score==fen){
alert("亲,即将进入下一关,请做好准备!");
down++;
fen+=100;
//alert("fen"+fen);
for(var i=0;i<5;i++){
createCharDiv[i].againTop();
}
}
}
}
function CreateCharDiv(){
//alert("CreateCharDiv()");
var newDiv;
var numbs=0;
function initCharDiv(){
//alert("initCharDiv()");
num=parseInt(Math.random()*words.length);
//alert(words.length);
newDiv=document.createElement("div");
newDiv.style.width="30px";
newDiv.style.height="30px";
newDiv.style.border="1px solid black";
newDiv.style.position="absolute";
newDiv.style.top="20px";
//规定范围内取随机数 *(上限-下限+1)+下限
//newDiv.style.left=parseInt(Math.random()*480)+"px";
newDiv.style.left=parseInt(Math.random()*(470-20+1)+20)+"px";
newDiv.style.background="red";
newDiv.innerHTML=words[num];
document.body.appendChild(newDiv);
}
initCharDiv();
this.move=function(){
//alert("move()");
newDiv.style.top=parseInt(newDiv.style.top)+down;
if(parseInt(newDiv.style.top)>580){
clearInterval(times);
alert("oh oh oh , game over !");
}
}
this.divHTML=function(){
return newDiv.innerHTML;
}
this.againTop=function(){
newDiv.style.display="none";
initCharDiv();
}
}
</script>
</head>
<body>
</body>
</html>
分享到:
相关推荐
适合想从结构化转为OO的人学习,键盘游戏例子简单有利于理解
VC++中利用OO4O接口从Oracle数据库中读写图像C++源代码程序小实例visual studio.net
实战OO_用例建模 实战OO_用例建模 实战OO_用例建模
字母组合oo的发音规律[学习].doc
使用方法:打开游戏界面,同时按下键盘shift和ctrl键,切换至您想要 的输入法,界面底部会显示当前输入法和模式。 2、新增 增加抽奖功能。 3、修复 修复商品价格和利润的关系问题,解决金币越来越少的问题。 ======...
oo学习
ABAP OOALV报表开发,定义变量,选择屏幕定义,创建类,调用函数,是学习OOALV很不错的学习资料
C_OO思想编程
OOALV常用功能完整简例,OO ALV常用功能完整简例 - OO ALV 常用功能完整简例(热键单击,双击,帮助,编辑,自定义工具条等)
基于OO4O和VC 6.0 实现Oracle数据库操作C++源代码程序小实例visual studio.net
PPT,需求分析,OO分析前言,PPT,需求分析,OO分析前言,
利用OO实现ALV , OO是SAP比较新的东西了,应用可能会越来越广
oracle oo4o 817安装包oracle oo4o 817安装包oracle oo4o 817安装包
1、Windows 95/98/Me系统,将oo2core_6_win64.dll复制到C:\Windows\System目录下。 2、Windows NT/2000系统,将oo2core_6_win64.dll复制到C:\WINNT\System32目录下。 3、Windows XP/WIN7/win10系统(64位系统对应...
SAP ABAP开发学习——第10课:OOALV(视频教程) 1.SAP ABAP开发入门学习 2.含视频教程学习、PPT、作业 3.视频非常清晰
GO.OO声音模块
OO4O方式获取Oracle数据库中SDO_Geometry字段坐标方法
Oracle Objects for OLE (OO4O) is a product designed to allow easy access to data stored in Oracle databases using any programming or scripting language that supports the Microsoft ...
sap abap oo实现alv框可编辑
用OO4O操作Oracle数据库的大数据字段.pdf