Loading...
Processing Forum
Recent Topics
All Forums
Screen name:
trumpetface
trumpetface's Profile
2
Posts
0
Responses
0
Followers
Activity Trend
Last 30 days
Last 30 days
Date Interval
From Date :
To Date :
Go
Loading Chart...
Posts
Responses
PM
Show:
All
Discussions
Questions
Expanded view
List view
Private Message
Any ideas how to make this select a random image at mouseclick?
[10 Replies]
28-Nov-2011 08:33 AM
Forum:
Programming Questions
PImage bgImage; // reserve some memory for images
int imageNumber = 0; // the number of the current image
int numberOfImages = 15; // the total number of images
void setup()
{
size(320,480);
//load the first image into the memory
bgImage = loadImage("Homepage.gif");
}
void draw()
{
//draw the image to the screen
image(bgImage, 0, 0,width, height);
}
// the function that runs when the mouse is pressed
void mousePressed()
{
// add 1 to the imageNumber to move onto the next image
imageNumber = imageNumber + 1;
// if the number goes above the total number of images
if (imageNumber >= numberOfImages)
{
// reset image number to one
imageNumber = 1;
}
//load the new image to the memory
bgImage = loadImage("iBlame" + imageNumber +".gif");
}
Help needed with Random background Images
[1 Reply]
11-Nov-2011 11:37 AM
Forum:
Programming Questions
Hi, I'm hours new to Processing.
I was wondering if I could have some support.
I'm trying to create a button that makes the background image change randomly.
For some reason I'm finding this incredibly hard.
String[] words = { "i1.png", "i2.png", "i3.png", "i4.png", "i5.png", "i6.png", "i7.png" };
int index = int(random(words.length)); // same as int(random(NUMBER))
(words[index]);
This is the pile of junk I have so far.
«Prev
Next »
Moderate user : trumpetface
Forum