I thought this would be easy, and it should be. But here is my problem. In the for loop, the blocks are drawing spaces in between and running off the screen. The size of each square is equal to the distance of the 1st rect / 10 ( or at least I'm pretty sure). Each time the loop iterates, there is a space I believe to be 175 pixels between the new rect. When I manipulate the 'x' component of the rect() the squares will eventuall overlap but will be too big for the rect() i'm drawing in. Can someone please help?
void gameBoard() {
float x = width*.175;
float y = height*.175;
rectMode(CENTER);
//rect1 outlines game board
rect(width/2,height/2,width*.75,height*.75);
//i = amount of game spaces - 10
for(int i = 1; i < 11; i++) {
//rect2
//reason for w & h / 10 is equal to width of rect2 / 10
I'm in the beginning part of this project. Having trouble with getting nested for loops to do what I want. Initially, what I am trying to do is create 3 cells that has 3 columns and 27 rows. They are drawing on top of each other and can not figure out how to get it to work. If I can get this cornerstone, than I'll be able to make the other components.
This is my initial code.
//think low level
// the parts of this function
// maze component
// particle movement component
//first make maze called drawBlocks
//global variables - what variables are needed for maze component
Could someone guide me to figure out my problem? What I am trying to do is have a ball drop randomly to fall down stairs. I have not included code so that the ball will 'bounce' from the stairs, I'm just trying to get it to move right now.
float gravity;
float dampen;
void setup () {
background(255);
size(1000,1000);
stairs(width/1000, height/10, 100,100);
//collide(); // ball hitting stairs and falling
//window(); staic background window
}
void draw () {
ball(width/random(500), height/20, -20,-20); // sets random location for ball drop in an effort for different outcomes
//sun(width*.3, height/3, 50,50); // attempt to have the sun rise in background
int x = 15;
int y = 15;
}
void ball (float x, float y, float w, float h) {
float moveX = 3.5;
float moveY = 4.5;
float gravity = 1.5;
float dampen = 2.5;
fill(255,0,0);
ellipse(x,y,w,h);
// may be cool to have a mouse drop of ball
x += moveX;
y += moveY;
moveX = gravity;
moveY = dampen;
}
void stairs(float x, float y, float w, float h) { // function stairs making stairs
//pushMatrix(); do not entirely understand matrix stack
fill(0); // black background
for (int i = 0; i < 10; i++) { // begin loop for stairs
// rectMode(CORNER);
rect(x,y,w,h); // paramaterized from function stairs which contain values
translate(w,h); // w and h come from values in stairs ();