So I setup the code so that when the zombie is hit by the bullet it dies and it should spawn another zombie. However when the zombie dies a new one appears for half a second and then is gone. I don't know what i did wrong can anyone help?
import java.awt.Rectangle;
PVector pos_player;
Bullet aBullet;
Zombie zombie;
Zombie zombie2;
String[] tileMap;
int TILE_SIZE = 100;
PImage[] tiles = new PImage[10];
float e = 0;
int Z;
boolean death;
class Zombie {
PVector p,v;
Zombie(){
p = new PVector( 1000,random(800),0);
v = new PVector(-1,0,0);
}
void simulate(){
p.x+=v.x;
p.y+=v.y;
}
void draw(){
pushStyle();
fill(0,0,255);
rectMode(CENTER);
rect( p.x, p.y, 50, 50);
popStyle();
}
}
Basically I want to be able to tell if the zombie touches any bullets the player fires. I also cant figure out how to make it so that when the bullet touches a zombie it kills it. Any help?
Player(){
rect(p,i,50,50);
}
}
void Bullet(){
rect(p+50,i+13,25,25);
o = o + 5;
}
So I'm making a game and I'm having trouble with projectiles. I can't seem to figure out a way to make the bullet start at the location of the player but move independently of the player. The bullet also disappears when the player moves and resumes at the last location when f is pressed again. Can anyone tell me how to fix these?
So I am trying to make a abstract clock and basically what I'm doing is in the code below. At each specific time i want the number of circles to corespond to the time and to update each time draw runs but it doesn't update and I cant seem to figure it out. The Second function goes on for a while up to case 59 as does the minute function and the hour function goes to 23. I had assumed that everytime draw() would run it would call the Second, Minute and Hour functions and update the dots but it doesnt seem to work. Any help on how to get it to update in real time would be greatly appreciated.
int s = second();
int m = minute();
int h = hour();
void setup() {
size(460,100);
}
void draw() {
background(0);
//Each white circle is 1 second
Second();
//Each green circle is 1 minute
Minute();
//Each red circle is 1 hour
Hour();
}
void Second() {
fill(255);
switch(s) {
case 0:
break;
case 1:
ellipse(10,20,10,10);
break;
case 2:
ellipse(10,20,10,10);
ellipse(25,20,10,10);
break;
case 3:
ellipse(10,20,10,10);
ellipse(25,20,10,10);
ellipse(40,20,10,10);
break;
case 4:
ellipse(10,20,10,10);
ellipse(25,20,10,10);
ellipse(40,20,10,10);
ellipse(55,20,10,10);
break;
case 5:
ellipse(10,20,10,10);
ellipse(25,20,10,10);
ellipse(40,20,10,10);
ellipse(55,20,10,10);
ellipse(70,20,10,10);
break;
}
}