I want to make something like this, but I cannot figure out how..
Those 4 black blocks are on one page. I guess I should use rotate and translate......
Hi, I am new to processing and I am having some problems with PImage
for example, when i want to make 5 by 5 with chrome image,
I would code
PImage img;
void setup(){
size(500, 500);
img= loadImage("chrome.jpg");
}
//drawing the picture 5 by 5 using 'for'
void draw(){
for(int x=0; x<= width; x+= 100){
for (int y=0; y<= height; y+= 100){
image(img, x, y, 100, 100);
}
}
}
.
And I saved "chrome.jpg' in this file, but it doesn't work..
The error sign says 'Prefix string too short'
What i want to know is the way to save the image properly that PImage would work.
Help Please~!! Thank you
hi~
Now I am making a shooting game with processing for homework, and I really need some help as I am
new to this program. Any help and advice would be appreciated very, very much.
The game I want to make is something like below↓
First, some(about 10) circles, which look the same and represents balloons, are drawn on the background randomly.
Second, at the bottom of the background, there is an rectangle, and it works as needle that pops the circles.
The rectangle should be able to move horizontally as it follows the mouse. When mousePressed, the needle shoots up. While the needle can move, the circles should stay still.
Third, when the rectangle(needle) passes through the area of a circle, the circle gets erased. Here, I am considering
using dist() to count the distance between the circle and the rectangle and boolean().
(Fourth, the player has 3 chances of throwing the needle to pop all the circles.)
so far, i have programmed this..
First,
int numCircles = 10;
int [][] circles; // use a two-dimensional array
void setup() {
size(400, 400);
smooth();
noStroke();
circles = new int [numCircles][3]; // define the array, every circle needs three parameters (xPos, yPos, circleDiameter)
// fill array only once
for (int i=0; i<numCircles; i++) {
int circleDiameter=20;
int xPos = int(random(0 + circleDiameter/2, width - circleDiameter/2)); // keep distance from border
int yPos = int(random(0 + circleDiameter/2, height - circleDiameter/2)); // keep distance from border
circles[i][0]= xPos;
circles[i][1]= yPos;
circles[i][2]= circleDiameter; }}
void draw() {
for (int i=0; i<numCircles; i++) {
fill(121,3,254);
ellipse(circles[i][0], circles[i][1], circles[i][2],circles[i][2]); }}
Second, Third,
int y=380;
int x= mouseX;
float dist= sqrt((x-circles[i][0])*(x-circles[i][0])+ (y-circles[i][1])*
(y-circles[i][1]))
void setup(){
size(400, 400);
score=0;
}
void draw(){
background();
rect(x, y, 10, 10);
if(mousePressed==true){
for(int k=0; k<=380; k +=10){
y -= k; // the needle shoots up
}
}
if (dist>circles[i][2]){
int [][]circles=0;
}
the First one works, but the second&third do not seem to work.......
hi~ i am really new to processing, and i really need some help.
i want to place 50 ellipses on a board, and i want them to be placed at random.
so, i've come out with this code, but it sadly it doesn't work.
any help will be appreciated very much. thanx!
int numCircles = 50;
Circle[] circles = new Circle[numCircles]; // define the array
void setup() {
size(800,800);
smooth();
noStroke();
}
void draw() {
for (int i=0; i<numCircles; i++) {
circles[i] = new Circle(random(width),random(height-200), 30, 30); // fill the array with circles at random positions
}
}