We are about to switch to a new forum software. Until then we have removed the registration on this forum.
So I am making somekind of game that you have airplanes shooting meteorites. But I need some help with Array in objects to add and remove that meteorite object in my array. And i'm using the "class" function.
Answers
Plane plane;
PImage plane_0; PImage plane_1; PImage plane_2; PImage plane_3; PImage plane_4; PImage plane_5; PImage plane_shoot_0; PImage plane_shoot_1; PImage plane_shoot_2;
void setup() { imageMode(CENTER);
plane_0 = loadImage("plane_0.png"); plane_1 = loadImage("plane_1.png"); plane_2 = loadImage("plane_2.png"); plane_3 = loadImage("plane_3.png"); plane_4 = loadImage("plane_4.png"); plane_5 = loadImage("plane_5.png"); plane_shoot_0 = loadImage("plane_shoot_0.png"); plane_shoot_1 = loadImage("plane_shoot_1.png"); plane_shoot_2 = loadImage("plane_shoot_2.png");
plane = new Plane(); size(1000, 650); }
void draw() { background(0); //plane.display(); //plane.movement(); }
class Meteorite { PVector location; PVector velocity;
Meteorite() { location = new PVector(random(0, width), 0); velocity = new PVector(); }
void display() { fill(255, 0, 0); ellipse(location.x, location.y, 100, 100); } }
class Plane { PVector location; PVector velocity; float force = 0.1; int animate;
Plane() { location = new PVector(width/2, height/2); velocity = new PVector(0, 0); }
void display() { animate++;
}
void movement() { if(keyPressed == false) { if(velocity.x >= 0.001) { velocity.x = velocity.x - force; }
} }
https://forum.processing.org/two/discussion/15473/readme-how-to-format-code-and-text
What do you mean with that. I don't see any use of that what I can use in my code.
Please format your code. Edit your post (gear on top right side of any of your posts), select your code and hit
ctrl+o
. Leave an empty line above and below your block of code. Details here: https://forum.processing.org/two/discussion/15473/readme-how-to-format-code-and-textKf