跳跳狗小游戏

编程入门 行业动态 更新时间:2024-10-28 20:23:17

跳跳狗<a href=https://www.elefans.com/category/jswz/34/1769974.html style=小游戏"/>

跳跳狗小游戏

欢迎来到程序小院

跳跳狗

玩法:一直弹跳的狗狗,鼠标点击屏幕左右方向键进行弹跳,弹到不同物品会有不同的分数减扣,规定的时间3分钟内完成狗狗弹跳,快去跳跳狗吧^^。

开始游戏

 

 

html

<canvas id="ef" width="100%" height="100%" style="position:absolute;left:0;top:180px;z-index:19;display:none;"></canvas>
<canvas id="game" width="100%" height="100%" style="position:absolute;left:0;top:180px;z-index:18;"></canvas>
<canvas id="bg" width="100%" height="100%" style="position:absolute;left:0;top:180px;z-index:17;"></canvas>

css

h2.title{display: block;margin: 50px auto;text-align: center;
}

js

function dot_TalkBubble() {this.reset = function(a, b, c, d, e, f, g, h, k) {this.image = a;this.text = "";this.x = f;this.y = g;this.offsetX = b;this.offsetY = c;this.w = h;this.font = k;a = d.split(" ");for (d = c = b = 0; d < a.length; d++) c = k.getTextSize(a[d]).w, b + c > this.w ? (this.text += "\n" + a[d] + " ", b = c + k.charWidths[" "]) : (this.text += a[d] + " ", b += c + k.charWidths[" "]);this.timer = this.currentIndex = 0;this.maxTimer = 1 / e;this.justFinished = this.finished = !1};this.update = function(a) {this.justFinished = !1;this.finished || (this.timer += a, this.timer >this.maxTimer && (this.timer = 0, this.currentIndex++, this.currentIndex == this.text.length && (this.justFinished = this.finished = !0)))};this.render = function(a, b, c, d) {a.drawImage(this.image, Math.floor(this.x + b - this.offsetX), Math.floor(this.y + c - this.offsetY));this.font.write(a, Math.floor(this.x + b), Math.floor(this.y + c), this.text, d, 0, this.currentIndex)}
}function dot_Math() {this.load = function() {this.m_sin = Array(1440);this.m_cos = Array(1440);for (var a = 0, b = 0; 1440 > b; b++) this.m_sin[b] = Math.sin(a * PI / 180), this.m_cos[b] = Math.cos(a * PI / 180), a += 0.25;this.msquare = Array(600);for (b = 0; b < this.msquare.length; b++) this.msquare[b] = b * b};this.sqrt = function(a) {a = Math.floor(a);a = 0 < a ? a : -a;for (var b = 0, c = this.msquare.length - 1, d = b + c >> 1; b < c - 1;) {if (this.msquare[d] > a) c = d;else if (this.msquare[d] < a) b = d;else break;d = b + c >> 1}return d};this.sin = function(a) {0 > a ? a += 360 : 360 <= a && (a -= 360);return this.m_sin[Math.floor(4 * a)]};this.cos = function(a) {0 > a ? a += 360 : 360 <= a && (a -= 360);return this.m_cos[Math.floor(4 * a)]};this.seed_w = 1234;this.seed_z = 5678;this.randomize = function() {var a = (new Date).getTime();this.seed_w = a % 32E3;this.seed_z = a % 65535};this.rand = function() {this.seed_z = 36969 * (this.seed_z & 65535) + (this.seed_z >> 16);this.seed_w = 18E3 * (this.seed_w & 65535) + (this.seed_w >> 16);return Math.abs((this.seed_z << 16) + this.seed_w)};this.random = function() {return 1 / (this.rand() % 10)};this.randomIn = function(a,b) {return 1 < b ? a + this.rand() % b : a + this.random() * b}
}
var EASE_NONE = 0,EASE_QUAD_IN = 1,EASE_QUAD_OUT = 2,EASE_QUAD_INOUT = 3,EASE_CUBE_IN = 4,EASE_CUBE_OUT = 5,EASE_CUBE_INOUT = 6,EASE_QUART_IN = 7,EASE_QUART_OUT = 8,EASE_QUART_INOUT = 9,EASE_QUINT_IN = 10,EASE_QUINT_OUT = 11,EASE_QUINT_INOUT = 12,EASE_SIN_IN = 13,EASE_SIN_OUT = 14,EASE_SIN_INOUT = 15,EASE_BOUNCE_IN = 16,EASE_BOUNCE_OUT = 17,EASE_BOUNCE_INOUT = 18,EASE_CIRC_IN = 19,EASE_CIRC_OUT = 20,EASE_CIRC_INOUT = 21,EASE_EXPO_IN = 22,EASE_EXPO_OUT = 23,EASE_EXPO_INOUT = 24,EASE_BACK_IN = 25,EASE_BACK_OUT = 26,EASE_BACK_INOUT = 27,PI = 3.1415926,PI2 =1.5707963,B1 = 0.363636363636364,B2 = 0.727272727272727,B3 = 0.545454545454545,B4 = 0.909090909090909,B5 = 0.818181818181818,B6 = 0.954545;function dot_Tween() {this.duration = this.duration_inverse = this.t = 0;this.functionId = EASE_NONE;this.targetRangeNumber = this.targetLowest = this.timer = 0;this.finished = !0;this.delta = 0;this.reset = function(a, b, c, d) {this.duration_inverse = 1 / d;this.functionId = c;this.timer = 0;this.targetLowest = a;this.targetRangeNumber = b - a;this.duration = d;this.finished = !1;this.t = 0;this.delta = this.targetLowest;this.update(0)};this.replay = function() {this.finished = !1;this.t = this.timer = 0;this.delta = this.targetLowest;this.update(0)};this.update = function(a) {if (!this.finished)if (this.timer += a, this.timer > this.duration) this.finished = !0, this.t = 1, this.delta = this.targetLowest + this.targetRangeNumber;else {a = this.t = this.timer * this.duration_inverse;switch (this.functionId) {case EASE_QUAD_IN:a *= a;break;case EASE_QUAD_OUT:a = -a * (a - 2);break;case EASE_QUAD_INOUT:a = 0.5 >= a ? 2 * a * a : 1 - 2 * --a * a;break;case EASE_CUBE_IN:a *= a * a;break;case EASE_CUBE_OUT:a = 1 + --a * a * a;break;case EASE_CUBE_INOUT:a = 0.5 >= a ? 4 * a * a * a : 1 + 4 * --a * a * a;break;case EASE_QUART_IN:a *= a * a * a;break;case EASE_QUART_OUT:a = 1 - (a -= 1) * a * a * a;break;case EASE_QUART_INOUT:a = 0.5 >= a ? 8 * a * a * a * a : (1 - (a = 2 * a - 2) * a * a * a) / 2 + 0.5;break;case EASE_QUINT_IN:a *= a * a * a * a;break;case EASE_QUINT_OUT:a = (a -= 1) * a * a * a * a + 1;break;case EASE_QUINT_INOUT:a = 1 > (a *= 2) ? a * a * a * a * a / 2 : ((a -= 2) * a * a * a * a + 2) / 2;break;case EASE_SIN_IN:a = -Math.cos(PI2 * a) + 1;break;case EASE_SIN_OUT:a = Math.sin(PI2 * a);break;case EASE_SIN_INOUT:a = -Math.cos(PI * a) / 2 + 0.5;break;case EASE_BOUNCE_IN:a = 1 - a;if (a < B1) {a = 1 - 7.5625 * a * a;break}if (a < B2) {a = 1 - (7.5625 * (a - B3) * (a - B3) +0.75);break}if (a < B4) {a = 1 - (7.5625 * (a - B5) * (a - B5) + 0.9375);break}a = 1 - (7.5625 * (a - B6) * (a - B6) + 0.984375);break;case EASE_BOUNCE_OUT:if (a < B1) {a *= 7.5625 * a;break}if (a < B2) {a = 7.5625 * (a - B3) * (a - B3) + 0.75;break}if (a < B4) {a = 7.5625 * (a - B5) * (a - B5) + 0.9375;break}a = 7.5625 * (a - B6) * (a - B6) + 0.984375;break;case EASE_BOUNCE_INOUT:if (0.5 > a) {a = 1 - 2 * a;if (a < B1) {a = (1 - 7.5625 * a * a) / 2;break}if (a < B2) {a = (1 - (7.5625 * (a - B3) * (a - B3) + 0.75)) / 2;break}if (a < B4) {a = (1 - (7.5625 * (a - B5) * (a - B5) + 0.9375)) / 2;break}a = (1 - (7.5625 * (a - B6) * (a - B6) + 0.984375)) / 2;break}a =2 * a - 1;if (a < B1) {a = 7.5625 * a * a / 2 + 0.5;break}if (a < B2) {a = (7.5625 * (a - B3) * (a - B3) + 0.75) / 2 + 0.5;break}if (a < B4) {a = (7.5625 * (a - B5) * (a - B5) + 0.9375) / 2 + 0.5;break}a = (7.5625 * (a - B6) * (a - B6) + 0.984375) / 2 + 0.5;break;case EASE_CIRC_IN:a = -(Math.sqrt(1 - a * a) - 1);break;case EASE_CIRC_OUT:a = Math.sqrt(1 - (a - 1) * (a - 1));break;case EASE_CIRC_INOUT:a = 0.5 >= a ? (Math.sqrt(1 - 4 * a * a) - 1) / -2 : (Math.sqrt(1 - (2 * a - 2) * (2 * a - 2)) + 1) / 2;break;case EASE_EXPO_IN:a = Math.pow(2, 10 * (a - 1));break;case EASE_EXPO_OUT:a = -Math.pow(2, -10 * a) + 1;break;case EASE_EXPO_INOUT:a =0.5 > a ? Math.pow(2, 10 * (2 * a - 1)) / 2 : (-Math.pow(2, -10 * (2 * a - 1)) + 2) / 2;break;case EASE_BACK_IN:a = a * a * (2.70158 * a - 1.70158);break;case EASE_BACK_OUT:a = 1 - --a * a * (-2.70158 * a - 1.70158);break;case EASE_BACK_INOUT:a *= 2;if (1 > a) {a = a * a * (2.70158 * a - 1.70158) / 2;break}a--;a = (1 - --a * a * (-2.70158 * a - 1.70158)) / 2 + 0.5}this.t = a;this.delta = this.targetLowest + this.targetRangeNumber * this.t}}
}

源码/

需要源码请关注添加好友哦^ ^

转载:欢迎来到本站,转载请注明文章出处/

 

 

更多推荐

跳跳狗小游戏

本文发布于:2023-11-16 22:45:54,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1635433.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:小游戏

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!