Web前端--HTML+CSS+JS新型冠状病毒射击小游戏

临近期末, 你还在为HTML网页设计结课作业,老师的作业要求感到头大?网页要求的总数量太多?HTML网页作业无从下手?没有合适的模板?等等一系列问题。你想要解决的问题,在这里常见网页设计作业题材有 个人、 美食、 公司、体育、 化妆品、 物流、 环保、 书籍、 婚纱、 军事、 游戏、 节日、 戒烟、 电影、 摄影 学校、 旅游、 电商、 宠物、 电器、 茶叶、 家居、 酒店、 舞蹈、 动漫、 明星、 服装、  文化、 家乡、 鲜花、 礼品、 汽车、 其他等网页设计题目, A+水平作业, 可满足大学生网页大作业网页设计需求都能满足你的需求。原始HTML+CSS+JS页面设计, web大学生网页设计作业源码,这是一个不错的电竞博客网页制作,画面精明,非常适合初学者学习使用。

     效果演示:文末获取源码

   代码目录:

主要代码实现:

部分JS代码 :

var stage = {
    w: 1280,
    h: 720
}

var _pexcanvas = document.getElementById("canvas");
_pexcanvas.width = stage.w;
_pexcanvas.height = stage.h;
var ctx = _pexcanvas.getContext("2d");




var pointer = {
    x: stage.w / 2,
    y: stage.h / 4
}

var scale = 1;
var portrait = true;
var loffset = 0;
var toffset = 0;
var mxpos = 0;
var mypos = 0;


// ------------------------------------------------------------------------------- Gamy

var againprog = 0;

var healthprog = 0;


function newGame() {
    score = 0;
    health = 100;
    enemies = [];
    enemies.push(new Enemy());
    enemies.push(new Enemy());
    enemies.push(new Enemy());
    againprog = 0;
}



function drawHeart(x, y, w) {
    ctx.beginPath();
    ctx.arc(x - w / 4, y, w / 4, 0.75 * Math.PI, 0);
    ctx.arc(x + w / 4, y, w / 4, 1 * Math.PI, 2.25 * Math.PI);
    ctx.lineTo(x, y + w / 1.5);
    ctx.closePath();
    ctx.fill();
}


var Cannon = function(x, y, tx, ty) {
    this.x = x;
    this.y = y;
    this.tx = tx;
    this.ty = ty;
    this.r = 10;
}

var cannons = [];

var gameover = false;

cannons.push(new Cannon(stage.w, stage.h, stage.w / 2, stage.h / 2));

var firetm = 0;
var fireact = true;

var health = 100;
var score = 0;


var arm = {
    x: stage.w,
    y: stage.h
};
var arm2 = {
    x: 0,
    y: stage.h
};
var danger = false;
var dangera = 0;



var Enemy = function() {
    this.x = stage.w / 2;
    this.y = stage.h / 2;
    this.r = 10;
    this.tx = Math.floor(Math.random() * stage.w);
    this.ty = Math.floor(Math.random() * stage.h);
    this.des = false;
    this.eyeX = 0.4;
    this.eyeY = 0.25;
    this.eyeR = 0.25;
    this.sp = 50;
    this.spl = 1.4;
    this.op = 1;
    this.danger = false;
    this.nuked = false;
}

源码获取  

打卡 文章 更新  36  /  100天

大家可以点赞、收藏、关注、评论我啦 、

猜你喜欢

转载自blog.csdn.net/chengyang_java/article/details/121286699