# Trouble with assignment for programming class, help!

Hello all,

I am very very new to processing and I'm having trouble with an assignment. I have three circles, and I have to be able to turn them on and off like a light when clicked, one at a time. So off, they should be black, and on they should be yellow; the problem I'm having is getting them to turn on one at a time (like we're supposed to be able to do). And then along with that, I'm not able to get them to 'turn off'. It should alternate between black and yellow.

The second part of the assignment is that when none of the lights are turned on, the background is black, when one is turned on, the background is dark grey, two turned on, light grey, and all three turned on, white.

Does anyone have any tips for me? Below is what I have so far.

Please do not give me a direct answer. Considering this is a university assignment I do not want any sort of academic dishonesty issues, as other people in my class have already dealt with this (and subsequently got kicked out of university)

Remember, this is Python language in processing only! I can not submit this assignment if it is not in python language.

Also, I was playing around so I know that there are a lot of things wrong here. Some of them frankly, I haven't figured out what exactly is wrong. I haven't got to the background part yet, as you may have noticed.

light = 1

light_r = 20

light_d = 40

light_y = 40

light_switch = 0

def setup():

size(200,200)

def draw():

global light_d, light_y

ellipse(40, light_y, light_d, light_d)

ellipse(100, light_y, light_d, light_d)

ellipse(160, light_y, light_d, light_d)

def light_one(x, y, l_x, l_y, l_r):

global light_r

if dist(x, y, l_x, l_y) < light_r:

return True

else:

return False

def light_two(x, y, l_x, l_y, l_r):

global light_r

if dist(x, y, l_x, l_y) < light_r:

return True

else:

return False

def light_three(x, y, l_x, l_y, l_r):

global light_r

if dist(x, y, l_x, l_y) < light_r:

return True

else:

return False

def mouseClicked():

global light_one, light_two, light_three, light_y, light_r

if light_one(mouseX, mouseY, 40, light_y, light_r):

if True:

fill(255,255,0)

ellipse(40, light_y, light_d, light_d)

if False:

return False

if light_two(mouseX, mouseY, 100, light_y, light_r):

if True:

fill(255,255,0)

ellipse(100, light_y, light_d, light_d)

if False:

return False

if light_three(mouseX, mouseY, 160, light_y, light_r):

if True:

fill(255,255,0)

ellipse(160, light_y, light_d, light_d)

if False:

return False

submitted by /u/kk55622

# A generative version of one of Apple’s logo designs for it’s October Special Event

Hi,

Is there any examples of how to code Space Invaders. Mostly the way the aliens keep moving left to right and moving down slowly.

Any help will be appreciated.

Thank you.

submitted by /u/roodshi

# Why doesnt my Spikes apear?

float x = 150; float y = 200;

float okning = 3; int toggle = 0; float r; int gravity = 0.07; int velocity;

int NumbOfSpikes = 10;

//S stands for Spike float[] SPos = new float [NumbOfSpikes]; float[] SX = new float [NumbOfSpikes]; float[] SHeight = new float [NumbOfSpikes];

void setup() { size(900,600);

//Spike Creation for(int i = 0; i < NumbOfSpikes; i++){ SPos[i] = int(random(1,2)); SX[i] = int(random(700,900)); SHeight[i] = int(random(50,150)); }

}

void draw() { //Background background(#132627);

//Stripe pushMatrix(); translate(-200,200); rotate(radians(-50)); fill(#17403c); noStroke(); rect(0,0,1500,170); popMatrix();

//Spikes for(int i = 0; i < NumbOfSpikes; i++){ triangle(SX[i],600,SX[i]+SHeight[i]/2,600,SX+SHeight[i]/4,SHeight[i]*-1)

`` SX[i] -= 1; } ``

//Body Mechanics //Switch Course velocity += gravity;

if(get(x+50,y+50+velocity) == color(#132627)){ if(okning > 0) y += velocity; }

if(get(x+50,y+50-velocity) == color(#132627)){ if(okning < 0) y -= velocity; }

if(mousePressed) velocity = 0;

//Direction of Char if(okning > 0 && r < 30) r++ if(okning < 0 && r > -30) r--

y += r/10;

//Controls if(mousePressed && toggle == 0) { toggle = 1; okning = -okning; }

//Main body fill(#50ff70); triangle(-40,-40,-40,40,40,00);

popMatrix();

//Help //text(r,20,20); //text(y,20,40);

} void mouseReleased() { toggle = 0; }

submitted by /u/XeekerCc

# Set DSLR camera as a visible capture input

Trying to capture live video from my DSLR straight into Processing. Now, since Im using video Processing's library I cannot get the Capture.list() function to "see" the DSLR as a valid input.

So my question is, is there a specific library to achieve this? Been reading about edsdk library but Im quite sure its not what Im looking for.

submitted by /u/cpjags