working on a personal project, involves the timing. So i've got a command that calculates the amount of seconds passed (millis()/1000) and I've defined another integer which is the seconds passed % 10.
void button1(){
if(button1&&button1time==0){
counter++;
}
}
so in the if statement button1 is just a boolean I have and is irrelevant for my question. button1time is the modulo of seconds passed divided by 10. so if that = 0 it means than 10 seconds has passed. (I think all of that is working absolutely fine.)
however it then actually adds 60 every 10 seconds, rather than 1, can anyone shed some light on what i can do to combat this?
EDIT: the title i suppose is a bit off, i just need a way to store the information so that each can be called to see if its colliding with the ball
Hey all again, another question!
The task i'm doing is creating a version of breakout.
This is as far as i got:
But right now i'm stuck on the logic of how to store information for all of the bricks on the screen at once, so that i can begin removing bricks when the ball hits them, any nudge in the direction i should be shooting for is greatly appreciated!
Working on a task i've been set involving using the buffered reader to read in text from a file. The file has the format as followed:
x ## ## ## ##
where x is a letter and ## is a number. This has several lines all of which are consistent. However upon running the code i've put together i'm recieving an arrayindexoutofbounds error.
Any help identifying what i've managed to cock up would be greatly appreciated!
Okay so I have some code that I *THINK* should work, do not bash me if it's miles off but it's getting too much recursion error. Could anyone hint me toward what it looks like i've cocked up on?
void setup(){
size(500,500);
}
void circles(int x, int y, int radius, int numb){
int L=1;
ellipse(x,y,radius,radius);
if(numb>1){
if(L==1){
circles(x,y-radius/4,radius/2,numb);
L++;
}
if(L==2){
circles(x+radius/4,y,radius/2,numb);
L++;
}
if(L==3){
circles(x,y+radius/4,radius/2,numb);
L++;
}
if(L==4){
circles(x-radius/8,y,radius/2,numb);
L = 1;
}
numb=numb-1;
}
}
void draw(){
circles(250,250,250,2);
}
Hey all,
So I've been set an assignment to write a recursive function to produce the following:
size(200,200);
int xpos = width/2;
int ypos = height/2;
int x = width;
int y = height;
ellipse(xpos,ypos,x,y);
ellipse(xpos,4*ypos/8,x/2,y/2);
ellipse(20*xpos/16,4*ypos/8,x/4,y/4);
ellipse(20*xpos/16,5*ypos/8,x/8,y/8);
ellipse(19*xpos/16,5*ypos/8,x/16,y/16);
We weren't given the above code we were just given an image, and I managed to get this code, so the general idea is that the next circle is half the radius of the last one, and goes in the top of the first one, next one on the right, then on the bottom then on the left.
So I understand how to use recursion, I had another task to do in which I created a fibonacci number generator using recursion. However I'm entirely stumped on how this is supposed to work with recursion. So I'm not asking for the answer I'm asking for a nudge in the right direction, if possible, as i've spent many hours contemplating about how to utilize recursion for this task...
Thanks in advanced!
edit:
latest development is:
void setup(){
size(500,500);
}
void circles(int y, int radius, int numb){
float tt = 126*numb/4.0;
fill(tt);
ellipse(width/2,y,radius,radius);
if(numb>1){
numb--;
circles(y-radius/4,radius/2,numb);
}
}
void draw(){
circles(width/2,width,5);
}
but still struggling to get further, we'll see where this leads
Sorry to pester but could anyone help with how to generate a random character? I've been given a task to try and create a 'matrix effect' with the scrolling text of random characters (all printable random characters as specified by the task) i have a slight plan with how i'm going to do parts but could really do with knowing how to generate the random char in the first place!
Completely new to this forum, first time posting. Currently working on some homework for my course and i've finished the first 3 tasks. The next task however is to write a script that draws an image to the canvas 10 times, each time it's drawn getting smaller by 10%. I'm not in the slightest confident with for loops and has hoping for a nudge in the right direction!