I'm making a game in which some enemies shoot bullets at the player. I have an ArrayList of enemy objects and they should all be shooting bullets. However, when I run my program, only one of them actually does. The others still move around, but nothing else.
EDIT: what is supposed to happen is.. there are 3 enemies on screen. Every second, a bullet is generated at their coordinates at that moment in time, and it is displayed and updated (it moves towards the player).
Relevant code (there is much more code than this, but this is everything involving enemies):
ArrayList <Enemy> eList2 = new ArrayList();
Enemy newEn;
Enemy en2;
void setup() {
size(800, 800);
for (int i = 0; i < num2; i++) {
Enemy newEn2 = new Enemy(random(TWO_PI), (int) random(-1, 2), random(PI/300, PI/200));
I'm making a game that has an enemy move in a circle around the center of the screen (kind of like an orbit). The player is within this circle, it can move around.
The enemy shoots balls out every 3 seconds. I want these balls to always be aimed at the player's current position. It doesn't need to follow
the player around when it moves, but it needs to be
aimed towards the player.
Here are some images to show what I want to do. The red arrow is how the ball should move.
I'm making a game involving hit detection. Simply put, when a rectangle controlled by the player hits a circle, the score is supposed to increase by one. However what is happening right now is that instead of the score going from, let's say, 1 to 2 when there's a hit, it goes 1 to 2 to 3 to... 25, etc depending on how long the rectangle is overlapping with the circle.
How can I get it to increase by ONLY 1 each time there's a hit?
Here is my code:
// this function is in my player (rectangle) class
void collision(Object o) {
if (abs(x - o.x) < w/2 + o.w/2 && abs(y - o.y) < h/2 + o.h/2) {
hit = true;
// sb.score is an integer from the scoreboard class, it represents the score
sb.score += 1;