Bullets stop after I fire bullet


#1

I am trying to make a space invaders like game, but the bullet will stop after I fire another, which seems rather unusable, although it would provide an interesting aspect to the game. CodeName_Flier1-Dec18-2018-6.28PM.wick (3.0 KB)

var active = false;
var bullet_speed = 15;
this.opacity = 0;
var spaced = false;


function update() {
    if (active === false){
    this.opacity = 0;
    }
    if (active){
        this.opacity = 1
        this.y -= bullet_speed;
        this.clone.y -= bullet_speed;
    }

}
    

function keyPressed(key) {
    if (keyIsDown('Space')){
    var spaced = true;
    var clone = this.clone();
    this.y = Flier1.y;
    this.x = Flier1.x;
    active = true;
    }
}  

P.S. the similar topic thing on the left when you make a topic is rather handy. . .


#2

hi @ForgeFlarion, if i try to set clone.x and clone.y instead of this.x and this.y in keyPressed, it looks better.


#3

Okay thank you for your help; there still are bugs in mine however, like it stating that clone is undefined even though I called it.
I tried to get around that by re-declaring it every time I use it; that just results in a glitch-y stream of bullets.
But I digress. Thank you @berti for helping, good luck in your endeavors.


#4

Never mind; now it is working better, weird glitch I guess; thank you again.