How do I tell processing that an object is above another object?
So for example. In my program I have an image, which is shown below everything else. How can I tell processing that this object should be above other ones?
I'm trying to create a scoring system. The problem is that the variables I need to determine my scoring system are inside a class, and when I reference them outside of it, it is telling me that they do not exist.
Is there a way to reference a variable inside a class for use outside of one?
(I have tried creating the scoring system within the class, but it keeps on writing over itself. And putting in a background layer makes other objects not visible).
I want to make a game startup and a game over condition for my game. How do I go about doing this? Do I use the reset function? Or is there a simple way to do this?
Simple question. How does one remove an object from an Array List so that it isn't in the game anymore? This would mean it only affects that individual object of the list, and doesn't just become invisible so it no longer affects the game.
class Missile { float endX; // End X position float endY; // End Y position float endvarX; // Line gradient X float endvarY; // Line gradient Y float startX; // Start of missile line float startY; // start of missile line
int framestore; // frame last missile was created on int Mdelay; //delay between next fire time int posX; //mouse X position of player int posY; //mouse Y position of player float fireX; //starting X co-ordinate of player missile int fireY; //starting Y co-ordinate of player missile
ArrayList<Missile> missilelist; // list in null initially
void setup() { size(700, 500); framestore = 0; Mdelay = (int)random(60, 150); missilelist = new ArrayList<Missile>(); // creates and initially empty ArrayList of missile objects
frameRate(30);
}
void draw() { background(255); if (Mdelay < (frameCount - framestore) ) { for (int i = 0; i < (int)random(3); i = i+1) { // gives the initial value of 0 // then randomized between 3 maximum values. This means there can only be between 1 and // 3 missiles active // then adds +1 to the value of i, but cannot be more than 3. // code courtesy of Jacques missilelist.add(randomMissile()); } framestore = frameCount; }
// render all the missiles. for (Missile b : missilelist) { b.update(); b.render();
At the moment I'm working on using the dist() function for a game I have, and this is a bit of side code I'm working on to figure this out. Presently it is not working properly. I want a red square to appear when the mouse controlled line gets within a certain range...... but I don't know how to give the distance function a range.
Is there a way to program in something like if (pos1 <=20 to pos2) then perform action?
Code is below. Changing <= will cause the square to always appear. Changing it to == and it will not appear even when I try to make them equal in program.
int startX; int startY; float endX; int endY;
float posX; //mouse X position of player int posY; //mouse Y position of player int fireX; int fireY;
Hey people. So I'm working on a Missile Command game. And right now I need to work on Collision mapping.... probably the hardest part.
So I'm wondering if anybody knows how I would add collisions for the line you create when you click, and the lines (Missiles) which come from the top of the screen.
Something with would add an event when this happens would be helpful. Code below. All help is appreciated.
class Missile { float endX; // End X position float endY; // End Y position float endvarX; // Line gradient X float endvarY; // Line gradient Y float startX; // Start of missile line float startY; // start of missile line
ArrayList<Missile> missilelist; // list in null initially
void setup() { size(700, 500); framestore = 0; Mdelay = (int)random(60, 150); missilelist = new ArrayList<Missile>(); // creates and initially empty ArrayList of missile objects
frameRate(30);
}
void draw() { background(255); if (Mdelay < (frameCount - framestore) ) { for (int i = 0; i < (int)random(3); i = i+1) { // gives the initial value of 0 // then randomized between 3 maximum values. This means there can only be between 1 and // 3 missiles active // then adds +1 to the value of i, but cannot be more than 3. //Above code courtesy of Jacques missilelist.add(randomMissile()); } framestore = frameCount; }
// render all the missiles. for (Missile b : missilelist) { b.update(); b.render();
I need some help with this code. I get the error of "cannot find anything named startX". I've substituted in floats and int, but I don't know what to do anymore...
class Missile {
float endX; // End X position
float endY; // End Y position
float endvar; // Line gradient
float startX; // Start of missile line
float startY; // Weight of the missle
I'm working on a game at the moment, I am stuck on something at the moment. I want to create a line which starts from a static starting position, and when I click it will gradually move towards where the mouse was clicked.
I've tried integrating both pieces of code together, but this hasn't seemed to work at all and I think I need some sort of variable system. Could somebody lend me a hand with this?
I want to make it so that the missiles have a few pre determined vectors already. So they have lets say there are 6 cities which they can randomly go to. The thing which changes is the start point which has to be on the top of the screen.
I'm stuck on creating this random angle to the cities. I thought that prehaps I could create some variables which have the co-ordinates for the cities pre determined and then I could input these into the line code. But I'm not entirely sure, I simply need some help on how I would go about coding this.
I relativity new to Processing and I am in need of some help in my program that I'm trying to make.
Basically I want to create a program which makes four rectangles change to a random colour when the mouse is clicked.
The code I've been trying to work with is below-
I can't figure out a way to make it so that whenever the mouse has been clicked, each rectangle will change to a random colour.
Could somebody help me with this?
int value = 100; // This is defining a global variable