# Moving Triangles on the screen

It’s ridiculously simple what I’m trying to achieve. I’m trying to have a black screen and white triangle(I can make that) that starts off-screen and will slide from right to left(x-axis) until it’s off the screen on the left side and will there disappear(that I can’t do). For those tasks, is it best to use relative positions or absolute? Because I’d like to have multiple “emitters”, if it’s not too complicated.

I know I will have other question soon too so I’ll ask, I’m thinking about using conditionals, would this work somehow?
float time = ofGetElapsedTimef();
if (time == 5)
//Generate triangle no. 2
elseif (time == 10)
//Generate triangle no.3
etc…
endif

Thanks!
-Hlöðver

``````void testApp::setup(){
ofSetFrameRate(60);
ofBackground(0,0,0);
pos0 = ofPoint(1, 0);
pos1 = ofPoint(1, 768);
pos2 = ofPoint (1024, 1);

p1 = ofPoint (1000,500);
p2 = ofPoint (800,500);
p3 = ofPoint (900,350);

midiOut.listPorts();
midiOut.openPort(0);
channel = 1;
currentPgm = 0;
note = 0;
velocity = 0;
pan = 0;
bend = 0;
touch = 0;
polytouch = 0;

}

//--------------------------------------------------------------
void testApp::update(){

float dt = 0.05 / 60.0;

pos1 += pos2*dt;
pos0 += pos2*dt;

if (pos1.x > p2.x && pos1.x < p1.x){
midiOut.sendNoteOn(1, 60,  40);
}

}

//--------------------------------------------------------------
void testApp::draw(){
ofBackground(0,0,0);
ofSetColor( 255, 255, 255 );

ofSetLineWidth(4);
ofLine(pos0, pos1);
ofTriangle(p3, p2, p1);

}
``````

made this alternative solution, of course I know I have to learn, sweat and cry often to learn but Im still having problems with delaying the midi message

if I do

``````if (pos1.x > p2.x && pos1.x < p1.x){
midiOut.sendNoteOn(1, 60,  40);
midiOut.sendNoteOff(channel, note, velocity);
}
``````

I get nothing.

For your first answer of shooting triangles, you can simply check `if(x > ofGetWidth()) x= 0;` or any postion you want x to be and so the triangle after x crosses the screen ,where x can any x-cordinate of the triangle you are drawing through `ofTriangle(x1,y1,x2,y2,x3,y3)` .Is this what you wanted? Hope it helps…cheers!