Hello everyone, im looking for a simple yet semi complex program that makes clever use of functions. I need to be able to write about these functions in detail and explain how they work. I would use one of my many basic programs but they will definitely not cut it.
I have an exam coming up and this question was in the sample exam. My guess is: its somehow in the final exam.
I know this makes me sound petty but i am just gettting my head around arrays and objects now! Programming is very challenging for me.
So please if you have anything that might help, i'd be extremely greatful.
Hello im trying to use a bunch of numbers being read from a .txt file to draw something (line,rect). Ive got them reading out in println but im a bit lost when it comes to making them into variables or data that can be used to draw something. Heres the code:
Hello ladies and gentlemen, im trying to get a ball to draggable to any cell in the grid. Ive got my grid and the balls set up. but i think my implementation is wrong since i cannot find any method to drag them
Here is what i have so far!
Ball[][] grid; // 2D Array of objects
int cols = 15; // Number of columns and rows in the grid
int rows = 15;
int increment;
void setup() {
size(600, 600);
grid = new Ball[cols][rows];
for (int i = 0; i < cols; i ++ ) {
for (int j = 0; j < rows; j ++ ) {
grid[i][j] = new Ball(i*40, j*40, 40, 40, i + j);
grid[i][j].display();
}
}
for (int i = 0; i < cols; i ++ ) {
for (int j = 14; j < rows; j ++ ) {
grid[i][j].greyscale();
//fill(greyscale);
grid[i][j].drawc();
}
}
}
void draw() {
}
void mousePressed() {
rect (mouseX, mouseY, 30, 30);
}
Hi guys, im having a bit of trouble with getting this grid to generate a new randomised colour for each cell on mousePressed. Ive got it working initally and i though that since the randomcolor() function is being called in setup, calling setup() again should provide a new set of randomised colors. Its not working so well.
Cell[][] grid; // 2D Array of objects
int cols = 30; // Number of columns and rows in the grid
int rows = 30;
void setup() {
size(300, 300);
grid = new Cell[cols][rows];
for (int i = 0; i < cols; i ++ ) {
for (int j = 0; j < rows; j ++ ) {
grid[i][j] = new Cell(i*10, j*10, 10, 10, i + j);
grid[i][j].display();
}
}
}
//void draw() {
//}
void keyPressed() {
for (int i = 0; i < cols; i ++ ) {
for (int j = 0; j < rows; j ++ ) {
grid[i][j].key();
setup();
}
}
}