I have this challenge. I am trying to display the same image in n locations at the same time.
In this case, im looking at placing it at five different location on my Sketch.This is what i have so far. I guess i have to increment the Value of x and y somewhere, but i dont know where.
Please i have this little Challenge, i got this Code with the help of this forum that drops Objects( actually images) at random. I also have a Stationary Object(an Image also). I want to detect when one of these droping objects Touches my Other Stationary Object.
This is what i have so far, it works(so poorly), and does not detect most of these falling objects when they touch my stationary object
I intend to present Questions to my Users from a text file rather than an array.
Im facing Two problems:
1. How do i randomly Read separate lines from the file and
2. i would also love to put comment in the files, but i would not want to read the commented lines,( they are just there to help the user), assuming he intends to add more Questions to the game.
or is there a better Option apart from these two.
thank You
Code i have so far for reading file's content:
File file = new File("data\questions.txt"); FileInputStream fis = null; BufferedInputStream bis = null; DataInputStream dis = null;
try{ fis = new FileInputStream(file);
// Here BufferedInputStream is added for fast reading. bis = new BufferedInputStream(fis); dis = new DataInputStream(bis);
// dis.available() returns 0 if the file does not have more lines. while (dis.available() != 0) { ... }
background(bg);// where bg is a background image, same size as size(X,Y)
should set the background image. Im using eclipse(Helios) for Processing Development, added the required libraries but that code always throws an error "background image must be the same size as your application", funny enough, the same Piece of code loads the background image when run from within the PDE.
I have a challenge, to drop images from various positions in my Program, Im using random() to randomly generate numbers for the x- axis of my Image Location, the Problem is that since my method is called in the draw() function, it loops continuously generating random numbers each time. This makes the circle "shake" when it's droping. This is what i have to far
int z = 10;
int timedelay,time;
void dropBall() {
image(ball, generateRandom(), z);
z += speed * direction;//speed and direction are earlier declared variables
}
public float generateRandom(){
float nextX;
if (z > height + radius) { //height = height of the Screen, radius = radius of image
I have this Challenge, to "drop" an ellipse across a screen every 1 minute, this is the code i have so far
float y = 10;
float speed = 1.0;
float radius = 15.0;
int direction = 1;
int time;
int timeDelay;//Time Delay between calls
void setup() {
size(500, 500);
smooth();
noStroke();
ellipseMode(RADIUS);
time = millis();
timeDelay = 10000;
}
void draw() {
background(0);
fill(255);
if(millis() > time + timeDelay){
dropBall();
//time =millis(); this didnt give me the Desired Effect
}
}
void dropBall(){
ellipse(33, y, radius, radius);
y += speed * direction;
}
void reset(){
time = millis();
print("called");
}
The dropBall() Function is called only once, i guess i'ld probably need to reset the Millis() function?, how would i achieve calling the dropBall() Function every minute
I'm new with processing and i have a little challenge, i have an image say A that moves across my Screen encountering obstacles along it's path. I have the first Obstacle at a position on the screen(500,300 for instance), how do i stop the the already moving image when it approaches this Obstacle.