(p5.js)射击项目符号以在GIF /图像中打开链接

时间:2018-07-21 04:21:11

标签: javascript html css p5.js

我正在制作一个以太空侵略者为主题的网站,以宣传您的SoundCloud音乐,并且在拍摄Gif /图像时打开新页面时遇到了一些麻烦。 picture of what I'm talking about

我想发生的是,当您拍摄放下物体(子弹)时,它将击中所需的gif,这将打开一个新页面,例如,如果我拍摄视频GIF,它将打开一个包含艺术家所有音乐的新页面视频。

这只是我正在从事的一个有趣的小项目,我对编程界还是一个陌生的人,因此请给予任何建议和帮助。

p5.js-

var p;
var p2;
var p3;
var p4;
var drops = [];

function setup() {
    var cnv = createCanvas(windowWidth, windowHeight, );
    var x = (windowWidth - width) / 2;
    var y = (windowWidth - width) / 2;


    p = new Player();
    p2 = new Player2();
    p3 = new Player3();
    p4 = new Player4();
    drop = new Drop(width / 1, height / 1);
}

function draw() {
    background(0);
    p.drawPlayer();
    p.movePlayer();
    p2.drawPlayer2();
    p2.movePlayer2();
    p3.drawPlayer3();
    p3.movePlayer3();
    p4.drawPlayer4();
    p4.movePlayer4();
    for (var i = 0; i < drops.length; i++) {
        drops[i].show();
        drops[i].move();
    }

}

function Player() {
    this.x = width / 2;
    this.y = 700;
    this.w = 90;
    this.h = 20;


    this.drawPlayer = function () {
        fill(255)
        noStroke();
        rect(this.x, this.y, this.w, this.h);


    }

    this.movePlayer = function () {
        this.x = mouseX - this.w / 2;

    }

}

function Player2() {
    this.x = width / 2;
    this.y = 695;
    this.w = 80;
    this.h = 20;

    this.drawPlayer2 = function () {
        fill(255)
        noStroke();
        rect(this.x, this.y, this.w, this.h);


    }

    this.movePlayer2 = function () {
        this.x = mouseX - this.w / 2;

    }

}

function Player3() {
    this.x = width / 2;
    this.y = 690;
    this.w = 35;
    this.h = 20;

    this.drawPlayer3 = function () {
        fill(255)
        noStroke();
        rect(this.x, this.y, this.w, this.h);


    }

    this.movePlayer3 = function () {
        this.x = mouseX - this.w / 2;

    }

}

function Player4() {
    this.x = width / 2;
    this.y = 685;
    this.w = 10;
    this.h = 20;

    this.drawPlayer4 = function () {
        fill(255)
        noStroke();
        rect(this.x, this.y, this.w, this.h);


    }

    this.movePlayer4 = function () {
        this.x = mouseX - this.w / 2;

    }

}



function keyPressed() {
    if (key === ' ') {
        var drop = new Drop(p.x, height / 1.1);
        drops.push(drop);
    }
}


/*Shooting Bullet*/

function Drop(x, y) {
    this.x = x;
    this.y = y;

    this.show = function () {
        fill(250, 90, 50);
        rect(this.x, this.y, 5, 16);
    }
    this.move = function () {
        this.y = this.y - 7;
    }
}

0 个答案:

没有答案