Random x,y position
in
Programming Questions
•
1 year ago
Hello,
I'm making a game where a frog has to eat flies. The flies have to move randomly around the screen, but I have no idea how to do this. I think you need a random function where the parameters are x and y. Any help on this?
- int variabele1;
- int variabele2;
- PImage a;
- void setup() {
- size(600,600);
- frameRate(25);
- smooth();
- oscP5 = new OscP5(this,"239.0.0.1",7777);
- a= loadImage("Naamloos-1.png");
- }
- void draw() {
- background(255);
- image(a,0,0);
- //vlieg1
- PImage c;
- c= loadImage("vlieg3.png");
- image(c,mouseX,mouseY);
- //vlieg2
- c= loadImage("vlieg.png");
- image(c,100,100);
- //vlieg3
- c= loadImage("vlieg1.png");
- image(c,200,200);
- //vlieg4
- c= loadImage("vlieg2.png");
- image(c,300,300);
- //kikker
- c= loadImage("kikker.png");
- image(c,210,420);
- //uncomment dit voor te testen. variabele1 en 2 hangen dan aan de muiscoordinaten vast
- //als de server draait, comment je deze terug.
- //variabele1 = mouseX;
- //variabele2 = mouseY;
- }
1