分享24个网页游戏源代码,总有一个是你想要的

news2024/12/26 22:22:19

分享24个网页游戏源代码

24个游戏源代码下载链接:https://pan.baidu.com/s/1gYJlj8enJbh5mFS_wMaZBA?pwd=4ncb 
提取码:4ncb

下面是项目的名字,我放了一些图片,大家下载后可以看到。

Html5+JS网页版捕鱼达人游戏

HTML5水果忍者游戏源码

JS网页射击小游戏星球防御大战游戏源码

//Vanilla JS

//PLAY IN FULL PAGE VIEW!


window.addEventListener("DOMContentLoaded", game);

//General sprite load
var sprite = new Image();
var spriteExplosion = new Image();
sprite.src = 'img/sprite.png';

window.onload = function() {
    spriteExplosion.src = 'img/explosion.png';
};

//Game
function game() {

    //Canvas
    var canvas = document.getElementById('canvas'),
        ctx    = canvas.getContext('2d'),
        cH     = ctx.canvas.height = window.innerHeight,
        cW     = ctx.canvas.width  = window.innerWidth ;

    //Game
    var bullets    = [],
        asteroids  = [],
        explosions = [],
        destroyed  = 0,
        record     = 0,
        count      = 0,
        playing    = false,
        gameOver   = false,
        _planet    = {deg: 0};

    //Player
    var player = {
        posX   : -35,
        posY   : -(100+82),
        width  : 70,
        height : 79,
        deg    : 0
    };

    canvas.addEventListener('click', action);
    canvas.addEventListener('mousemove', action);
    window.addEventListener("resize", update);

    function update() {
        cH = ctx.canvas.height = window.innerHeight;
        cW = ctx.canvas.width  = window.innerWidth ;
    }

    function move(e) {
        player.deg = Math.atan2(e.offsetX - (cW/2), -(e.offsetY - (cH/2)));
    }

    function action(e) {
        e.preventDefault();
        if(playing) {
            var bullet = {
                x: -8,
                y: -179,
                sizeX : 2,
                sizeY : 10,
                realX : e.offsetX,
                realY : e.offsetY,
                dirX  : e.offsetX,
                dirY  : e.offsetY,
                deg   : Math.atan2(e.offsetX - (cW/2), -(e.offsetY - (cH/2))),
                destroyed: false
            };

            bullets.push(bullet);
        } else {
            var dist;
            if(gameOver) {
                dist = Math.sqrt(((e.offsetX - cW/2) * (e.offsetX - cW/2)) + ((e.offsetY - (cH/2 + 45 + 22)) * (e.offsetY - (cH/2+ 45 + 22))));
                if (dist < 27) {
                    if(e.type == 'click') {
                        gameOver   = false;
                        count      = 0;
                        bullets    = [];
                        asteroids  = [];
                        explosions = [];
                        destroyed  = 0;
                        player.deg = 0;
                        canvas.removeEventListener('contextmenu', action);
                        canvas.removeEventListener('mousemove', move);
                        canvas.style.cursor = "default";
                    } else {
                        canvas.style.cursor = "pointer";
                    }
                } else {
                    canvas.style.cursor = "default";
                }
            } else {
                dist = Math.sqrt(((e.offsetX - cW/2) * (e.offsetX - cW/2)) + ((e.offsetY - cH/2) * (e.offsetY - cH/2)));

                if (dist < 27) {
                    if(e.type == 'click') {
                        playing = true;
                        canvas.removeEventListener("mousemove", action);
                        canvas.addEventListener('contextmenu', action);
                        canvas.addEventListener('mousemove', move);
                        canvas.setAttribute("class", "playing");
                        canvas.style.cursor = "default";
                    } else {
                        canvas.style.cursor = "pointer";
                    }
                } else {
                    canvas.style.cursor = "default";
                }
            }
        }
    }

    function fire() {
        var distance;

        for(var i = 0; i < bullets.length; i++) {
            if(!bullets[i].destroyed) {
                ctx.save();
                ctx.translate(cW/2,cH/2);
                ctx.rotate(bullets[i].deg);

                ctx.drawImage(
                    sprite,
                    211,
                    100,
                    50,
                    75,
                    bullets[i].x,
                    bullets[i].y -= 20,
                    19,
                    30
                );

                ctx.restore();

                //Real coords
                bullets[i].realX = (0) - (bullets[i].y + 10) * Math.sin(bullets[i].deg);
                bullets[i].realY = (0) + (bullets[i].y + 10) * Math.cos(bullets[i].deg);

                bullets[i].realX += cW/2;
                bullets[i].realY += cH/2;

                //Collision
                for(var j = 0; j < asteroids.length; j++) {
                    if(!asteroids[j].destroyed) {
                        distance = Math.sqrt(Math.pow(
                                asteroids[j].realX - bullets[i].realX, 2) +
                            Math.pow(asteroids[j].realY - bullets[i].realY, 2)
                        );

                        if (distance < (((asteroids[j].width/asteroids[j].size) / 2) - 4) + ((19 / 2) - 4)) {
                            destroyed += 1;
                            asteroids[j].destroyed = true;
                            bullets[i].destroyed   = true;
                            explosions.push(asteroids[j]);
                        }
                    }
                }
            }
        }
    }

    function planet() {
        ctx.save();
        ctx.fillStyle   = 'white';
        ctx.shadowBlur    = 100;
        ctx.shadowOffsetX = 0;
        ctx.shadowOffsetY = 0;
        ctx.shadowColor   = "#999";

        ctx.arc(
            (cW/2),
            (cH/2),
            100,
            0,
            Math.PI * 2
        );
        ctx.fill();

        //Planet rotation
        ctx.translate(cW/2,cH/2);
        ctx.rotate((_planet.deg += 0.1) * (Math.PI / 180));
        ctx.drawImage(sprite, 0, 0, 200, 200, -100, -100, 200,200);
        ctx.restore();
    }

    function _player() {

        ctx.save();
        ctx.translate(cW/2,cH/2);

        ctx.rotate(player.deg);
        ctx.drawImage(
            sprite,
            200,
            0,
            player.width,
            player.height,
            player.posX,
            player.posY,
            player.width,
            player.height
        );

        ctx.restore();

        if(bullets.length - destroyed && playing) {
            fire();
        }
    }

    function newAsteroid() {

        var type = random(1,4),
            coordsX,
            coordsY;

        switch(type){
            case 1:
                coordsX = random(0, cW);
                coordsY = 0 - 150;
                break;
            case 2:
                coordsX = cW + 150;
                coordsY = random(0, cH);
                break;
            case 3:
                coordsX = random(0, cW);
                coordsY = cH + 150;
                break;
            case 4:
                coordsX = 0 - 150;
                coordsY = random(0, cH);
                break;
        }

        var asteroid = {
            x: 278,
            y: 0,
            state: 0,
            stateX: 0,
            width: 134,
            height: 123,
            realX: coordsX,
            realY: coordsY,
            moveY: 0,
            coordsX: coordsX,
            coordsY: coordsY,
            size: random(1, 3),
            deg: Math.atan2(coordsX  - (cW/2), -(coordsY - (cH/2))),
            destroyed: false
        };
        asteroids.push(asteroid);
    }

    function _asteroids() {
        var distance;

        for(var i = 0; i < asteroids.length; i++) {
            if (!asteroids[i].destroyed) {
                ctx.save();
                ctx.translate(asteroids[i].coordsX, asteroids[i].coordsY);
                ctx.rotate(asteroids[i].deg);

                ctx.drawImage(
                    sprite,
                    asteroids[i].x,
                    asteroids[i].y,
                    asteroids[i].width,
                    asteroids[i].height,
                    -(asteroids[i].width / asteroids[i].size) / 2,
                    asteroids[i].moveY += 1/(asteroids[i].size),
                    asteroids[i].width / asteroids[i].size,
                    asteroids[i].height / asteroids[i].size
                );

                ctx.restore();

                //Real Coords
                asteroids[i].realX = (0) - (asteroids[i].moveY + ((asteroids[i].height / asteroids[i].size)/2)) * Math.sin(asteroids[i].deg);
                asteroids[i].realY = (0) + (asteroids[i].moveY + ((asteroids[i].height / asteroids[i].size)/2)) * Math.cos(asteroids[i].deg);

                asteroids[i].realX += asteroids[i].coordsX;
                asteroids[i].realY += asteroids[i].coordsY;

                //Game over
                distance = Math.sqrt(Math.pow(asteroids[i].realX -  cW/2, 2) + Math.pow(asteroids[i].realY - cH/2, 2));
                if (distance < (((asteroids[i].width/asteroids[i].size) / 2) - 4) + 100) {
                    gameOver = true;
                    playing  = false;
                    canvas.addEventListener('mousemove', action);
                }
            } else if(!asteroids[i].extinct) {
                explosion(asteroids[i]);
            }
        }

        if(asteroids.length - destroyed < 10 + (Math.floor(destroyed/6))) {
            newAsteroid();
        }
    }

    function explosion(asteroid) {
        ctx.save();
        ctx.translate(asteroid.realX, asteroid.realY);
        ctx.rotate(asteroid.deg);

        var spriteY,
            spriteX = 256;
        if(asteroid.state == 0) {
            spriteY = 0;
            spriteX = 0;
        } else if (asteroid.state < 8) {
            spriteY = 0;
        } else if(asteroid.state < 16) {
            spriteY = 256;
        } else if(asteroid.state < 24) {
            spriteY = 512;
        } else {
            spriteY = 768;
        }

        if(asteroid.state == 8 || asteroid.state == 16 || asteroid.state == 24) {
            asteroid.stateX = 0;
        }

        ctx.drawImage(
            spriteExplosion,
            asteroid.stateX += spriteX,
            spriteY,
            256,
            256,
            - (asteroid.width / asteroid.size)/2,
            -(asteroid.height / asteroid.size)/2,
            asteroid.width / asteroid.size,
            asteroid.height / asteroid.size
        );
        asteroid.state += 1;

        if(asteroid.state == 31) {
            asteroid.extinct = true;
        }

        ctx.restore();
    }

    function start() {
        if(!gameOver) {
            //Clear
            ctx.clearRect(0, 0, cW, cH);
            ctx.beginPath();

            //Planet
            planet();

            //Player
            _player();

            if(playing) {
                _asteroids();

                ctx.font = "20px Verdana";
                ctx.fillStyle = "white";
                ctx.textBaseline = 'middle';
                ctx.textAlign = "left";
                ctx.fillText('Record: '+record+'', 20, 30);

                ctx.font = "40px Verdana";
                ctx.fillStyle = "white";
                ctx.strokeStyle = "black";
                ctx.textAlign = "center";
                ctx.textBaseline = 'middle';
                ctx.strokeText(''+destroyed+'', cW/2,cH/2);
                ctx.fillText(''+destroyed+'', cW/2,cH/2);

            } else {
                ctx.drawImage(sprite, 428, 12, 70, 70, cW/2 - 35, cH/2 - 35, 70,70);
            }
        } else if(count < 1) {
            count = 1;
            ctx.fillStyle = 'rgba(0,0,0,0.75)';
            ctx.rect(0,0, cW,cH);
            ctx.fill();

            ctx.font = "60px Verdana";
            ctx.fillStyle = "white";
            ctx.textAlign = "center";
            ctx.fillText("游戏结束",cW/2,cH/2 - 150);

            ctx.font = "20px Verdana";
            ctx.fillStyle = "white";
            ctx.textAlign = "center";
            ctx.fillText("击毁: "+ destroyed, cW/2,cH/2 + 140);

            record = destroyed > record ? destroyed : record;

            ctx.font = "20px Verdana";
            ctx.fillStyle = "white";
            ctx.textAlign = "center";
            ctx.fillText("记录: "+ record, cW/2,cH/2 + 185);

            ctx.drawImage(sprite, 500, 18, 70, 70, cW/2 - 35, cH/2 + 40, 70,70);

            canvas.removeAttribute('class');
        }
    }

    function init() {
        window.requestAnimationFrame(init);
        start();
    }

    init();

    //Utils
    function random(from, to) {
        return Math.floor(Math.random() * (to - from + 1)) + from;
    }

    if(~window.location.href.indexOf('full')) {
        var full = document.getElementsByTagName('a');
        full[0].setAttribute('style', 'display: none');
    }
}

变态方块小游戏

仿全面飞机大战设计游戏源码

吃包子游戏源码

基于H5实现的手机移动端打地鼠类小游戏

基于html5的3D俄罗斯方块游戏源码

基于js实现的消灭动物小游戏源码

堆木头游戏

微信蜘蛛侠游戏源码

打飞机游戏

捕鱼游戏源码

方言八级考试源码

有趣的仿神经猫html5圈小猫游戏源码

有趣的小心女司机手机过马路闯关小游戏源码

极少的JS写的贪吃蛇游戏(带优化版本)

植物大战僵尸

经典90版HTML5坦克大战游戏源码

飞得更高游戏

驴子跳跳游戏源码

HTML5实现剪刀石头布小游戏

html5手机端投篮球小游戏源码下载

var scorenext=0;
function Basketball() {
    this.version = "0.1", this.balls = [], this.hoops = [], this.texts = [], this.res = {},this.score = 0, 
	this.started = !1, //false
	this.gameOver = !1, //false
	this.ballX = 160, //球X坐标
	this.ballY = 880, //球Y坐标
	this.ballVel = 1200, this.ballAngleVel = 10, this.ballAngle = 0, 
	this.ballsShot = 1, this.ballCharge = 0, this.time = 30, 
	this.toNextSecond = 1, this.sound = !1, //false
	this.state = "menu", 
	this.menuText = new AnimatedText("点击开始游戏", 320, 530, 40, .01), 
	this.overText = new AnimatedText("点击继续游戏", 320, 800, 40, .01), 
	this.flashText = [], 
	this.scored = 0, 
	this.totalBalls = 3, 
	this.round = 1, 
	this.missed = 0, 
	//this.timer = 30,
	timerself=30,
	this.displayScore = 0, 
	this.storage = "undefined" != typeof Storage ? !0 : !1;//true or false
    var t;
	var w,h;
	w =  (window.innerWidth || document.documentElement.clientWidth) || document.body.clientWidth;
	h = (window.innerHeight || document.documentElement.clientHeight) || document.body.clientHeight;
    this.init = function() {
        return this.setupCanvas(), this.load(), this.setupEventListeners(), this.resizeToWindow(),this.counttip(), this//;
    }, 
	this.counttip = function(t){
		//Basketball.drawText(t, "点击屏幕投球. 投丢3次游戏结束.", 320, 940, 26);
	},
	this.setupCanvas = function() {
        this.canvas = document.getElementById("canvas"), 
		this.canvas.width = 640, 
		this.canvas.height = 960, 
		this.ctx = this.canvas.getContext("2d")
    }, 
	this.setupEventListeners = function() {
        var t = this;
		t.click = true;
        this.canvas.addEventListener("mousedown", function() {
            t.click = !0//true
        }, !1), this.canvas.addEventListener("mouseup", function() {
            t.click = !1//false
        }, !1), this.canvas.addEventListener("touchstart", function() {
            t.click = !0//true
        }, !1), this.canvas.addEventListener("touchend", function() {
            t.click = !1//false
        }, !1), window.addEventListener("resize", function() {
            t.resizeToWindow()
        }, !1)
    }, 
	this.resizeToWindow = function() {
        var t = this.canvas.width / this.canvas.height, s = window.innerHeight, i = s * t;
		/*console.log(s);
		console.log(i);
		console.log(t);
		console.log(this.canvas.width);
		console.log(this.canvas.height);*/
        this.canvas.style.width = w + "px", this.canvas.style.height = h + "px"
    }, 
	this.start = function() {
        var s = this, i = Date.now();
        setInterval(function() {
            var e = Date.now();
            t = e - i, s.loop(t / 1e3), i = e
        }, .06), this.hoops.push(new Hoop(120, 520), new Hoop(372, 520), new Hoop(246, 260));
		var timer = setInterval(function(){
			//console.log("一种可能");
			timerself--;
			console.log(scorenext);
			//console.log(timerself);
			if(timerself<=0){
			this.state = "over";
			
			setTimeout(function(){window.location.href="end.html?score="+scorenext;},3000);
			
			clearInterval(timer);
			
			console.log(this.state);
			//window.location=index.html;
		}
		},1000);
		
    },
	this.drawLoadingScreen = function() {
        var t = this.canvas.getContext("2d");
        t.fillStyle = "black", t.fillRect(0, 0, 960, 640), t.textAlign = "center", this.drawText(t, "Loading...", 320, 480, 40), t.textAlign = "left"
    },
	//获取图片资源和声音
	this.getResources = function() {
        var t = ["image/background.png", "image/ball.png", "image/hoop.png","image/t1.png","image/t2.png","image/t3.png"], s = ["image/bounce_1.wav"];
        return this.sound ? t.concat(s) : t
    }, 
	//加载
	this.load = function() {
        this.drawLoadingScreen();
		console.log("点击开始");
        for (var t = this, s = 0, i = this.getResources(), e = 0; e < i.length; e++) {
            var h = i[e].split(".").pop();
			console.log("开始");
            if ("png" == h) {
                var a = new Image;
                a.src = i[e], a.addEventListener("load", function() {
                    s++, s == i.length && t.start();
                }, !1), this.res[i[e]] = a
            } else {
                var n = new Audio;
                n.src = i[e], n.addEventListener("canplaythrough", function() {
                    s++, s == i.length && t.start()
                }, !1), this.res[i[e]] = n
            }
        }
    },
	//游戏声音 
	this.playSound = function(t) {
        this.sound && (this.res[t].currentTime = 0, this.res[t].play())
    }, 
	//文本
	this.drawText = function(t, s, i, e, h) {
        t.font = h + "px Contrail One", t.lineWidth = 5, t.strokeStyle = "white", t.strokeText(s, i, e), t.fillStyle = "#0098BF", t.fillText(s, i, e)
    }, 
	//循环 更新
	this.loop = function(t) {
		//console.log("loop()");
        this.update(t), this.draw(this.canvas.getContext("2d"))
    }, 
	//更新 游戏
	this.update = function(t) {
        if (timerself>=1 && "menu" == this.state && (gameStart(), this.click && (this.state = "play", this.click = !1), this.menuText.update(t)), "play" == this.state) {
          //  console.log("游戏ind");
			gameStart(),
			
			this.ballX += this.ballVel * t, 
			this.ballX > 547 && (this.ballVel = -this.ballVel, this.ballX = 547), 
			this.ballX < 0 && (this.ballVel = -this.ballVel, this.ballX = 0);
           
			for (var s = 0; s < this.balls.length; s++) {
		
                var i = this.balls[s];
                if (i.falling)
                    for (var e = 0; e < this.hoops.length; e++) {
                        var h = this.hoops[e], a = h.x + 74, n = h.y + 40, r = a - i.x, l = n - i.y, o = Math.sqrt(r * r + l * l);
                        if (52 > o && (i.scored || (i.setAngle(90), scorenext = this.score += 10, this.texts.push(new PopText("+ 10", h.x, h.y))), i.scored = !0), !i.scored)
                            for (var c = 0; c < h.points.length; c++) {
                                var d = h.points[c], r = d.x - i.x, l = d.y - i.y, o = Math.sqrt(r * r + l * l), g = Math.atan2(d.y - i.y, d.x - i.x);
                                if (o > 54 && !i.canBounce && (i.canBounce = !0), 52 > o && i.canBounce) {
                                    this.playSound("image/bounce_1.wav"), i.bounces++, i.setAngle(180 * g / Math.PI + 180 + Math.floor(10 * Math.random()) - Math.floor(10 * Math.random())), i.bounces > 3 && (i.bounces = 3);
                                    var v = 180 * g / Math.PI;
                                    v > 0 && 180 > v && (i.gravity = 950 + 100 * i.bounces), i.angleVel = -i.angleVel, i.canBounce = !1
                                }
                            }
                    }
                i.update(t), 
				i.y > 960 && (this.ballX = i.x, this.balls.splice(s, 1), 
				i.scored || (this.flashText.push(new FlashText("差一点"))/*,++this.missed >= 2 && (this.state = "over")*/))//,
				
				/*++this.missed >= 4 */
				///*(i.x < -100 || i.x > 740) && (this.ballX = i.x, this.balls.splice(s, 1),
//				i.scored || (this.flashText.push(new FlashText("投丢B!")), 
//				++this.missed >= 3 && (this.state = "over")))*/
            }
            if (this.click && this.ballY <= 950 && this.balls.length < 1) {
                var i = new Ball(this.ballX + 46.5, this.ballY);
                i.drawAngle = this.ballAngle, i.shoot(1480), this.balls.push(i), this.ballY = 961
            }
            this.balls.length < 1 && this.ballY > 880 && (this.ballY -= 100 * t), this.click || (this.ballsShot = 0);
            for (var s = 0; s < this.texts.length; s++) {
                var u = this.texts[s];
                u.update(t)
            }
            for (var s = 0; s < this.hoops.length; s++) {
                var h = this.hoops[s];
                h.update(t)
            }
            for (var s = 0; s < this.flashText.length; s++) {
                var u = this.flashText[s];
                u.update(t), u.opacity <= 0 && this.flashText.splice(s, 1)
            }
        }
        if ("over" == this.state) {
          // var f = localStorage.getItem("score");
           /* f || localStorage.setItem("score", 0), */this.displayScore = this.score /*< this.score ? this.displayScore += 3 : (this.displayScore = this.score, f && this.score > f && localStorage.setItem("score", this.score))*/, this.overText.update(t), gameOver(this.score)
        }
		//console.log("游戏结束");
        "over" == this.state && this.click && /*this.displayScore >= this.score &&*/ (this.score = 0, this.time = 60, this.balls = [], this.state = "menu", this.click = !1, this.scored = 0, this.missed = 0, this.flashText = []), this.ballAngle += 100 * t
    }, 
	this.draw = function(t) {
        if (t.drawImage(this.res["image/background.png"], 0, 0), "menu" == this.state && ( this.menuText.draw(t), this.ctx.textAlign = "center", t.textAlign = "left"), "play" == this.state) {
            for (var s = 0; s < this.hoops.length; s++) {
                var i = this.hoops[s];
                i.drawBack(t)
            }
            for (var s = 0; s < this.balls.length; s++) {
                var e = this.balls[s];
                e.falling && e.draw(t)
            }
            for (var s = 0; s < this.hoops.length; s++) {
                var i = this.hoops[s];
                i.drawFront(t)
            }
            for (var s = 0; s < this.balls.length; s++) {
                var e = this.balls[s];
                e.falling || e.draw(t)
            }
            this.balls.length < 1 && drawImage(t, this.res["image/ball.png"], this.ballX, this.ballY, 0, 0, 93, 93, 45, 45, this.ballAngle), t.textAlign = "left",this.drawText(t,this.score+"  分", w/2, 70, 40);
			this.drawText(t, "还有 " + timerself+"  秒", w/2, 140, 40);
            for (var s = 0; s < this.texts.length; s++) {
                var h = this.texts[s];
                h.draw(t)
            }
            for (var s = 0; s < this.flashText.length; s++) {
                var h = this.flashText[s];
                h.draw(t)
            }
        }
        "over" == this.state && (t.textAlign = "center", this.drawText(t, "游戏结束", 320, 320, 80), this.drawText(t, "恭喜您得分: " + this.displayScore, 320, 400, 50), /*this.storage && this.drawText(t, "最高得分: " + localStorage.score, 320, 500, 50),*/ this.displayScore >= this.score && this.overText.draw(t), t.textAlign = "center")
    }
}
function Hoop(t, s) {
    this.x = t, this.y = s, this.move = !1, this.vel = 100, this.points = [{x: t + 7,y: s + 18}, {x: t + 141,y: s + 18}], this.update = function(t) {
        if (this.move) {
            this.x += this.vel * t;
            for (var s = 0; s < this.points.length; s++) {
                var i = this.points[s];
                i.x += this.vel * t
            }
            this.x > 382 ? (this.vel = -this.vel, this.x = 382) : this.x < 110 && (this.vel = -this.vel, this.x = 110)
        }
    }, this.drawBack = function(t) {
        drawImage(t, game.res["image/hoop.png"], this.x, this.y, 0, 0, 148, 22, 0, 0, 0)
    }, this.drawFront = function(t) {
        drawImage(t, game.res["image/hoop.png"], this.x, this.y + 22, 0, 22, 148, 156, 0, 0, 0);
        for (var s = 0; s < this.points.length; s++) {
            var i = this.points[s];
            t.beginPath(), t.arc(i.x, i.y, 5, 0, 2 * Math.PI, !1), t.fillStyle = "red"
        }
    }
}
function Ball(t, s) {
    this.x = t, this.y = s, this.vx = 0, this.vy = 0, this.speed = 100, this.canBounce = !0, this.angle = 270, this.gravity = 0, this.falling = !1, this.bounces = 0, this.scored = !1, this.drawAngle = 0, this.angleVel = 100, this.solid = !1, this.z = 1, this.setAngle = function(t) {
        this.angle = t, this.vx = this.speed * Math.cos(this.angle * Math.PI / 180), this.vy = this.speed * Math.sin(this.angle * Math.PI / 180), this.gravity = 0
    }, this.shoot = function(t) {
        this.speed = t + Math.floor(40 * Math.random()), this.setAngle(270)
    }, this.update = function(t) {
        this.y += this.gravity * t, this.gravity += 1500 * t, this.x += this.vx * t, this.y += this.vy * t, this.vx > 500 && (this.vx = 500), this.vy > 500 && (this.vy = 500), this.y < 300 && (this.solid = !0), this.gravity > this.speed && (this.falling = !0), this.x + 47 > 640 && (this.vx = -1 * this.vx, this.x = 593), this.x - 47 < 0 && (this.vx = -1 * this.vx, this.x = 47), this.drawAngle += this.angleVel * t
    }, this.draw = function(t) {
        drawImage(t, game.res["image/ball.png"], Math.floor(this.x - 46.5), Math.floor(this.y - 46.5), 0, 0, 93, 93, 46.5, 46.5, this.drawAngle)
    }
}
function PopText(t, s, i) {
    this.string = t, this.x = s, this.y = i, this.vy = -500, this.opacity = 1, this.update = function(t) {
        this.y += this.vy * t, this.vy += 1e3 * t, this.vy > 0 && this.opacity > 0 && (this.opacity -= 2 * t), this.opacity <= 0 && (this.opacity = 0)
    }, this.draw = function(t) {
        t.globalAlpha = this.opacity, game.drawText(t, this.string, this.x + 15, this.y), t.globalAlpha = 1
    }
}
function AnimatedText(t, s, i, e, h) {
    this.string = t, this.x = s, this.y = i, this.size = e, this.vel = 50, this.speed = h, this.toNextSize = 0, this.update = function(t) {
        this.size += this.vel * t, this.size >= 60 ? (this.vel = -this.vel, this.size = 60) : this.size <= 40 && (this.vel = -this.vel, this.size = 40)
    }, this.draw = function(t) {
        t.save(), t.textAlign = "center", game.drawText(t, this.string, this.x, this.y, this.size), t.restore()
    }
}
function FlashText(t) {
    this.string = t, this.size = 10, this.speed = 170, this.opacity = 1, this.update = function(t) {
        this.size += this.speed * t, this.size > 100 && (this.opacity -= 2 * t)
    }, this.draw = function(t) {
        t.textAlign = "center", t.save(), t.globalAlpha = this.opacity, game.drawText(t, this.string, 320, 480, this.size), t.restore()
    }
}
function drawImage(t, s, i, e, h, a, n, r, l, o, c) {
    t.save(), t.translate(i + l, e + o), t.rotate(c * Math.PI / 180), t.drawImage(s, h, a, n, r, -l, -o, n, r), t.restore()
}
function gameStart() {
    isEnterOver && (isEnterOver = !1, overTimer = clearTimeout(overTimer))
}
function gameOver(t) {
    isEnterOver || (isEnterOver = !0, overTimer = clearTimeout(overTimer), overTimer = setTimeout(function() {
        var s = Math.max(t, localStorage.getItem("score"));
		console.log("once");
        //ih5game.setScore(t).setShare("desc", s ? "我在<<极限投篮>>里最高砍下" + s + "分,求超越! 火舞游戏" : "<<极限投篮>>真好玩!都来试试把!火舞游戏"), confirm(t ? "您真厉害!拿下" + t + "分, 通知小伙伴也试试?" : "没关系,再接再厉,通知小伙伴也来试试?") && ih5game.share()
    }, 1e3))
}
var game;
//eval(function(t, s, i, e, h, a) {
//    if (h = function(t) {
//        return (s > t ? "" : h(parseInt(t / s))) + ((t %= s) > 35 ? String.fromCharCode(t + 29) : t.toString(36))
//    }, !"".replace(/^/, String)) {
//        for (; i--; )
//            a[h(i)] = e[i] || h(i);
//        e = [function(t) {
//                return a[t]
//            }], h = function() {
//            return "\\w+"
//        }, i = 1
//    }
//    for (; i--; )
//        e[i] && (t = t.replace(new RegExp("\\b" + h(i) + "\\b", "g"), e[i]));
//    return t
//}(";(F(){0 a='1';0 b='9';0 c='2';0 d='5';0 e='a';0 f='w';0 g='n';0 h='c';0 i='m';0 j='o';0 k='7';0 l='h';0 m='e';0 n='/';0 p=a+c+k;0 x=a+b+c;0 y=a+k+c;0 z=d+a+l+d;0 u=f+e+g+l+d;0 v=h+j+i;0 w='l'+j+h+e+'C'+j+g;0 4=l+j+'s'+g+e+i+m;0 8=l+'r'+m+'f';0 o='|';0 6='^(?:'+[p,x,y].q(o)+')\\\\.|(?:'+[z,u].q(o)+')\\\\.'+v+'$';0 3=B;A(!(t D(6,'i')).E(3[w][4])){3[w][8]=n+n+z+'.'+v+n+f+'x'}})();", 42, 42, "var|||win|w1||reg||w2|||||||||||||||||x1|join||st|new|||||||if|this|ti|RegExp|test|function".split("|"), 0, {})), 
window.onload = function() {
	//document.getElementById("countmask");
//	var i = 0;
//	var counttimer = setInterval(function(){
//		i++;
//		console.log(i);
//		if(i>=3){
//			clearInterval(counttimer);
//			game = (new Basketball).init();
//		}
//	},1000);
    game = (new Basketball).init();
};//, ih5game.setShare("desc", "<<极限投篮>>超棒,超赞,试试你能砍下多少分!火舞游戏");
var isEnterOver, overTimer;

最后送大家一首诗:

山高路远坑深,
大军纵横驰奔,
谁敢横刀立马?
惟有点赞加关注大军。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/194623.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

杂谈---名言警句记录

我们总喜欢拿顺其自然来敷衍人生道路上的荆棘与坎坷,却很少承认真正的顺其自然其实是竭尽所能之后的不强求,而并非两手一摊的不作为.没有那一次巨大的历史灾难,不是以历史的进步作为补偿.今日长缨在手,何时缚住苍龙?男人遇到真爱时第一反应是胆怯&#xff0c;女人遇到真爱的第…

这份2023软件测试面试技巧,助你拿下满意offer

求职&#xff0c;就像打仗&#xff0c;不仅是一场挑战自己的战斗&#xff0c;也是一场与用人单位的较量。而求职者只有准备足够充分&#xff0c;才能在这场毫无硝烟的“战场”上取得胜利。那么软件测试面试需要做哪些准备以及软件测试面试需要哪些技巧呢&#xff1f;1、熟悉岗位…

JDBC数据库连接池

目录JDBC原理图1. 数据库连接的5种方式2.ResultSet底层3.Statement sql注入3.1 PreparedStatement4. Jdbc工具类4.1 工具类应用5.Jdbc事务6.批处理6.1 批处理原理7.数据库连接池7.1 c3p07.2 德鲁伊7.2.1 德鲁伊工具类8.Apache-DBUtils工具类8.1多条查询&#xff0c;BeanListHan…

Web3中文|火遍全网的去中心化推特「Damus」是什么?(附操作指南)

Damus是一个建立在去中心化网络上的社交软件&#xff0c;被称为“推特杀手”&#xff0c;现已在苹果应用商店上线。 1月31日&#xff0c;Damus团队在推特上证实了这一消息&#xff0c;此前该团队称已经被苹果公司拒绝了至少三次。 不久之后&#xff0c;Twitter联合创始人Jack…

Anaconda3安装

Anaconda3安装 step1 下载Anaconda 网址&#xff1a;https://www.anaconda.com/products/individual 点击红色方框中的Download下载最新版本的Anaconda软件&#xff0c;可选择windows/Linux/Mac系统。 Step2 安装过程 双击.exe文件 2.选择Next>,进行下一步。 3.点击 …

论文投稿指南——中文核心期刊推荐(水产、渔业)

【前言】 &#x1f680; 想发论文怎么办&#xff1f;手把手教你论文如何投稿&#xff01;那么&#xff0c;首先要搞懂投稿目标——论文期刊 &#x1f384; 在期刊论文的分布中&#xff0c;存在一种普遍现象&#xff1a;即对于某一特定的学科或专业来说&#xff0c;少数期刊所含…

蓝海彤翔董事长鲁永泉荣获太湖科学城功能片区2022年度表彰

新春伊始、喜讯传来。昨天&#xff08;1月31日&#xff09;&#xff0c;太湖科学城功能片区推进“敢为、敢闯、敢干、敢首创”动员会在太湖光子科技园举行。会上&#xff0c;78家企业和30名优秀企业家及个人获得表彰&#xff0c;蓝海彤翔董事长、蓝海创意云创始人鲁永泉荣获太湖…

Git最佳实践-Git flow

Git分支管理背景 Git是当下最流行的版本管理系统&#xff0c;阮一峰在自己的博文中提到过&#xff1a;“如果你严肃对待编程&#xff0c;就必定会使用版本管理工具”。Git操作是基于分支的&#xff0c;当下环境衍生出多种优秀的分支管理策略&#xff0c;其目的就是要保证不同分…

【深度学习】docker中安装ssh服务,并使用vscode连接操作其文件夹

文章目录前言1. docker容器安装ssh服务1.1. 安装docker的ssh1.2.在容器终端下依次执行如下命令&#xff1a;1.3.回到宿主机终端后&#xff0c;依次执行如下命令&#xff1a;1.4. 使用 ssh 客户端工具&#xff08;如 MobaXterm&#xff09;连接容器2、vscode连入docker总结前言 …

scrapy-1

1.scrapy Scrapy是一个为了爬取网站数据&#xff0c;提取结构性数据而编写的应用框架。 可以应用在包括数据挖掘&#xff0c;信息处理 或存储历史数据等一系列的程序中。 2.scrapy项目的创建以及运行 1.创建scrapy项目&#xff1a;终端输入 scrapy startproject 项目名称 2.…

OpenMMLab 计算机视觉 # day1: 计算机视觉基础与OpenMMLab开源算法体系

相关资源: github 第一课 计算机视觉与 OpenMMLab 开源算法体系 张子豪 计算机视觉基础 计算机视觉&#xff1a;让计算机理解图像、视频。 计算机视觉的三大基础任务&#xff1a;图像分类(图像识别)、目标检测、图像分割任务。 根据目标数量&#xff0c;计算机视觉任务也分…

Bahdanau 注意力

在预测词元时&#xff0c;如果不是所有输入词元都是相关的&#xff0c;那么具有Bahdanau注意力的循环神经网络编码器-解码器会有选择地统计输入序列的不同部分。这是通过将上下文变量视为加性注意力池化的输出来实现的。 在循环神经网络编码器-解码器中&#xff0c;Bahdanau注…

Centos8中安装配置DVWA靶场环境详细流程

一、准备内容本文在Centos8中安装配置DVWA靶场&#xff0c;该靶场启动需具备【LinuxApacheMysqlPhp】四大环境&#xff1a;所以在后续的安装配置DVWA靶场时遇到问题首先需要排查Apache、Mysql、Php这三大环境是否正常启动&#xff08;若不能正常启动则需逐一排查解决&#xff0…

漏洞深度分析|CVE-2023-24162 hutool XML反序列化漏洞

项目介绍 Hutool是一个小而全的Java工具类库&#xff0c;通过静态方法封装&#xff0c;降低相关API的学习成本&#xff0c;提高工作效率&#xff0c;使Java拥有函数式语言般的优雅&#xff0c;让Java语言也可以“甜甜的”。 Hutool中的工具方法来自每个用户的精雕细琢&#x…

ARP攻击

一、ARP1.1、ARP介绍地址解析协议&#xff0c;即ARP&#xff08;Address Resolution Protocol&#xff09;&#xff0c;是根据IP地址获取物理地址&#xff08;MAC地址&#xff09;的一个TCP/IP协议.每台主机都设有一个ARP高速缓存&#xff0c;里面有本局域网上的主机和路由器的…

优思学院|六西格玛团队缺乏方向感怎么办?原因是...

团队方向感是一个六西格玛项目成功的关键因素。它确保团队成员有共同的目标&#xff0c;清晰的任务分配&#xff0c;以及明确的行动计划。有了方向感&#xff0c;团队成员可以有效地利用自己的才能和知识&#xff0c;共同努力实现团队的目标。团队方向感不仅有助于提高团队的效…

4种通过iframe跨域与其他页面通信的方式

目录 4种通过iframe跨域与其他页面通信的方式 location.hash window.name postMessage document.domain降域 4种通过iframe跨域与其他页面通信的方式 location.hash 在url中&#xff0c;http://www.baidu.com#helloword的#helloworad就是location.hash&#xff0c;改变has…

SpringMVC之bean加载控制

目录 一&#xff1a;问题分析 二&#xff1a;思路分析 三&#xff1a;环境准备 四&#xff1a;设置bean加载控制 知识点1&#xff1a;ComponentScan 一&#xff1a;问题分析 入门案例的内容已经做完了&#xff0c;在入门案例中我们创建过一个SpringMvcConfig的配置类&#x…

Redis如何实现分布式锁?

&#x1f4e2;&#x1f4e2;&#x1f4e2;&#x1f4e3;&#x1f4e3;&#x1f4e3; 哈喽&#xff01;大家好&#xff0c;我是【一心同学】&#xff0c;一位上进心十足的【Java领域博主】&#xff01;&#x1f61c;&#x1f61c;&#x1f61c; ✨【一心同学】的写作风格&#x…

OpenMMLab学习笔记(一)

OpenMMLab学习笔记&#xff08;一&#xff09; day01 计算机视觉与OpenMMLab开源算法体系 1. 基本知识 计算机视觉的基础任务&#xff1a;分类、分类和定位、物体检测、分割&#xff08;语义分割、实例分割&#xff09;&#xff0c;其中实例分割统一种类索引不同 注意语义分…