Ejemplo n.º 1
0
void ofxTLTrack::_draw(){
	ofPushStyle();
	
	if(focused){
		ofFill();
		ofSetColor(timeline->getColors().highlightColor, 50);
		ofRect(bounds.x, bounds.y, bounds.width, bounds.height);
	}
	
	ofNoFill();
	if(hover){
		ofSetColor(timeline->getColors().textColor);
	}
	else{
		ofSetColor(timeline->getColors().outlineColor);
	}	
	ofRect(bounds.x, bounds.y, bounds.width, bounds.height);
	ofPopStyle();

	ofPushStyle();
    draw();
	ofPopStyle();
	
	if(isPlaying){
		float playheadScreenX = millisToScreenX(currentTrackTime());
		if(isOnScreen(playheadScreenX)){
			ofPushStyle();
			ofSetColor(timeline->getColors().keyColor);
			ofLine(playheadScreenX, bounds.getMinY(), playheadScreenX, bounds.getMaxY());
			ofPopStyle();
		}			
	}
	viewIsDirty = false;
}
Ejemplo n.º 2
0
void PlayerObject::update(vec2 accel, float timeStep, std::vector<Object> worldObjects)
{
	speed += (accel * timeStep);
	desiredPos += (speed * timeStep);
	boundingCircle.center = desiredPos;
	bool collide = false;
	for (auto &object : worldObjects)
	{
		vec2 collisionVec = checkCollision(object.boundingBox, boundingCircle);
		if (collisionVec != vec2(0.f, 0.f)){
			collide = true;
			speed = speed - (collisionVec * dotProduct(speed, collisionVec)) * 1.85f;
            break;
		}
	}
	if (!collide){
		position = desiredPos;
		entity->setPos(desiredPos.x, desiredPos.y);
	}
	else{
		desiredPos = position;
		boundingCircle.center = position;
	}

	if (!isOnScreen(vec2(1280, 720), boundingCircle.center))
	{
		vec2 a(600, 0);
		entity->setPos(a.x, a.y);
		position = a;
		desiredPos = position;
		boundingCircle = BoundingCircle(position, size.x / 2);
		speed = vec2(0, 0);
	}
}
Ejemplo n.º 3
0
//TODO: find a way to make this not happen every frame
void ofxTLTicker::updateBPMPoints(){
	
	bpmScreenPoints.clear();

	double currentPoint = 0;
	double oneMeasure = 1.0/(bpm/60.);
	double halfMeasure = oneMeasure/2;
	double quarterMeasure = halfMeasure/2;

	bool showMeasure = false;
	bool showHalfMeasure = false;
	bool showQuarterMeasure = false;
	showMeasure = screenXForTime(oneMeasure) - screenXForTime(0) > 20;
	if(showMeasure){
		showHalfMeasure = screenXForTime(halfMeasure) - screenXForTime(0) > 20;
		if (showHalfMeasure) {
			showQuarterMeasure = screenXForTime(halfMeasure) - screenXForTime(0) > 20;
		}
	}

	int currentMeasure = 0;        
	while(currentPoint < timeline->getDurationInSeconds()){
		ofxTLBPMPoint measures[4];
		int numMeasures = 0;
		if(showMeasure){
			measures[0].millis = currentPoint * 1000;
			measures[0].screenX = millisToScreenX(measures[0].millis);
			measures[0].weight = 4;
			numMeasures = 1;
		}
		if(showHalfMeasure){
			measures[1].millis = (currentPoint+halfMeasure) * 1000;
			measures[1].screenX = millisToScreenX(measures[1].millis);
			measures[1].weight = 2;
			numMeasures = 2;
		}
		if(showQuarterMeasure){
			measures[2].millis = (currentPoint+quarterMeasure) * 1000;
			measures[2].screenX = millisToScreenX(measures[2].millis);
			measures[2].weight = 1;
			measures[3].millis = (currentPoint+halfMeasure+quarterMeasure) * 1000;
			measures[3].screenX = millisToScreenX(measures[3].millis);
			measures[3].weight = 1;
			numMeasures = 4;
		}
		
		for(int m = 0; m < numMeasures; m++){
			if( isOnScreen(measures[m].screenX) ){
				bpmScreenPoints.push_back( measures[m] );
			}
		}

		currentMeasure++;
		currentPoint = currentMeasure*oneMeasure;
	}

}
Ejemplo n.º 4
0
void ofxTLTicker::updateBPMPoints(){
	
	bpmScreenPoints.clear();
	if(!timeline->getIsFrameBased()){
		double currentPoint = 0;
		double oneMeasure = 1.0/(bpm/60.);
		double halfMeasure = oneMeasure/2;
		double quarterMeasure = halfMeasure/2;
		
		bool showMeasure = false;
		bool showHalfMeasure = false;
		bool showQuarterMeasure = false;
		showMeasure = screenXForTime(oneMeasure) - screenXForTime(0) > 20;
		if(showMeasure){
			showHalfMeasure = screenXForTime(halfMeasure) - screenXForTime(0) > 20;
			if (showHalfMeasure) {
				showQuarterMeasure = screenXForTime(halfMeasure) - screenXForTime(0) > 20;
			}
		}
		
			
		while(currentPoint < timeline->getDurationInSeconds()){
			ofxTLBPMPoint measures[4];
			int numMeasures = 0;
			if(showMeasure){
				measures[0].screenX = screenXForTime(currentPoint);
				measures[0].weight = 4;
				numMeasures = 1;
			}
			if(showHalfMeasure){
				measures[1].screenX = screenXForTime(currentPoint+halfMeasure);
				measures[1].weight = 2;
				numMeasures = 2;
			}
			if(showQuarterMeasure){
				measures[2].screenX = screenXForTime(currentPoint+quarterMeasure);
				measures[2].weight = 1;
				measures[3].screenX = screenXForTime(currentPoint+halfMeasure+quarterMeasure);
				measures[3].weight = 1;
				numMeasures = 4;
			}
			
//			cout << "measures " << measures[0].screenX << endl;
			
			for(int m = 0; m < numMeasures; m++){
				if( isOnScreen(measures[m].screenX) ){
					bpmScreenPoints.push_back( measures[m] );
				}
			}

			currentPoint += oneMeasure;
		}
	}	
}
Ejemplo n.º 5
0
void ImageCollection::layoutExpanded()
{
    tl.complete();

    _collapseLayer.moveToParent(&_listItem);
    _collapseLayer.z().setValue(1.);
    GfxCanvasItem *i = nameItem(false);
    if(i) i->visible().setValue(0.);
    int pauses = 0;

    int f = focused();
    for(int ii = count() - 1; ii >= 0; --ii) {

        Image *img = image(ii);

        if(!isOnScreen(ii)) {
            img->imageParent().setValue(0.);
            img->visible().setValue(1.);
            img->quality().setValue(0.);
            img->x().setValue(0);
            img->y().setValue(0);
            img->scale().setValue( SMALL_ZOOM );
            img->rotate().setValue(0);
        } else {
            int pauseTime = pauses * 50 + 150;
            pauses++;
            tl.pause(img->visible(), pauseTime);
            tl.pause(img->x(), pauseTime);
            tl.pause(img->y(), pauseTime);
            tl.pause(img->rotate(), pauseTime);
            tl.pause(img->scale(), pauseTime);
            tl.pause(img->quality(), pauseTime);
            tl.pause(img->imageParent(), pauseTime);
            tl.set(img->imageParent(), 0.);
            tl.set(img->visible(), 1.);
            tl.set(img->quality(), 0.);
            tl.move(img->x(), 0, 150);
            tl.move(img->y(), 0, 150);

            if(f == ii) {
                tl.move(img->scale(), SMALL_ZOOM, 150);
                tl.sync(img->z(), img->scale());
                tl.set(img->z(), 1.);
                tl.move(img->scale(), ZOOMED_ZOOM, 50);
            } else {
                tl.move(img->scale(), SMALL_ZOOM, 150);
            }
            tl.move(img->rotate(), 0, 150);
        }
    } 
}
Ejemplo n.º 6
0
// paints all the graphic tiles, including the highlighting of the selected tile
void SelectableMap::paint(int highlightTileX, int highlightTileY)
{
	SDL_Rect windowClip;

	windowClip.x = x*tileSize;
	windowClip.y = y*tileSize;
	windowClip.w = limit.w;
	windowClip.h = limit.h;

	applySurface(limit.x,limit.y,g->image,screen,&windowClip);

	if(highlightTileX != -1 && highlightTileY != -1 && isOnScreen(highlightTileX,highlightTileY))
	{
		applySurface(limit.x+(highlightTileX-x)*tileSize,limit.y+(highlightTileY-y)*tileSize,highlightTile,screen);
	}
}
Ejemplo n.º 7
0
void ImageCollection::layoutExpandedFromTime()
{
    tl.complete();
    int f = focused();
    int pauses = 0;
    for(int ii = 0; ii < count(); ++ii) {
        Image *img = image(ii);

        if(!isOnScreen(ii)) {
            img->imageParent().setValue(0.);
            img->visible().setValue(1.);
            img->quality().setValue(0.);
            img->x().setValue(0);
            img->y().setValue(0);
            img->scale().setValue( SMALL_ZOOM );
            img->rotate().setValue(0);
        } else {
            int pauseTime = pauses * 50;
            pauses++;
            if(ii)
                img->setParent(image(0));
            img->z().setValue(-ii);
            tl.pause(img->visible(), pauseTime);
            tl.pause(img->x(), pauseTime);
            tl.pause(img->y(), pauseTime);
            tl.pause(img->rotate(), pauseTime);
            tl.pause(img->scale(), pauseTime);
            tl.pause(img->quality(), pauseTime);
            tl.pause(img->imageParent(), pauseTime);
            tl.set(img->imageParent(), 0.);
            tl.set(img->visible(), 1.);
            tl.set(img->quality(), 0.);
            tl.move(img->x(), 0, 150);
            tl.move(img->y(), 0, 150);

            if(f == ii) {
                tl.move(img->scale(), SMALL_ZOOM, 150);
                tl.sync(img->z(), img->scale());
                tl.set(img->z(), 1.);
                tl.move(img->scale(), ZOOMED_ZOOM, 50);
            } else {
                tl.move(img->scale(), SMALL_ZOOM, 150);
            }
            tl.move(img->rotate(), 0, 150);
        }
    }
}
Ejemplo n.º 8
0
void ImageCollection::layoutTime()
{
    tl.complete();

    // Collapse focus
    if(focused() != -1) {
        Image *foc = image(focused());
        tl.move(foc->scale(), SMALL_ZOOM, 50);
    }
    tl.sync();
    int seen = 0;
    for(int ii = 0; ii < count(); ++ii) {
        Image *img = image(ii);

        if(!isOnScreen(ii)) {
            img->imageParent().setValue(2.);
            img->visible().setValue(0.);
            img->scale().setValue(SMALL_ZOOM);
        } else {
            if(!seen) {
                QPoint p = img->mapTo(&_timeItem, QPoint(0, 0));
                _subTimeItem.x().setValue(p.x());
                _subTimeItem.y().setValue(p.y());
                tl.move(img->scale(), TIMEVIEW_ZOOM, 200);
                tl.move(_subTimeItem.x(), 0, 200);
                tl.move(_subTimeItem.y(), 0, 200);
            } 

            tl.pause(img->x(), seen * 20);
            tl.pause(img->y(), seen * 20);
            tl.pause(img->imageParent(), seen * 20);
            tl.set(img->imageParent(), 2.);
            tl.move(img->x(), 0, 150);
            tl.move(img->y(), 0, 150);
            if(seen) {
                tl.sync(img->visible(), img->y());
                tl.set(img->visible(), 0.);
            }

            seen++;
        }
    }
    GfxCanvasItem *i = nameItem();
    i->visible().setValue(0.);
}
Ejemplo n.º 9
0
//--------------------------------------------------------------
// Checks whether the given rectangle is on screen.
//--------------------------------------------------------------
bool mpeClientTCP::isOnScreen(float _x, float _y, float _w, float _h) {
    return (isOnScreen(_x, _y) || 
            isOnScreen(_x + _w, _y) ||
            isOnScreen(_x + _w, _y + _h) ||
            isOnScreen(_x, _y + _h));
}
Ejemplo n.º 10
0
int Bullet::update() { //returns 1 if bullet if off the screen
	if(isOnScreen()) {
		return 0;
	}
	return 1;
}
Ejemplo n.º 11
0
void ImageCollection::layoutCollapsed()
{
    tl.complete();

    _collapseLayer.moveToParent(&_iconItem);

    QPoint p = collapsePoint();

    int seenOnScreen = 0;
    int f = focused();

    _collapseLayer.z().setValue(-10000.);
    for(int ii = count() - 1; ii >= 0; --ii) {

        Image *img = image(ii);
        img->moveToParent(iconItem());

        if(!isOnScreen(ii))
            continue;

        seenOnScreen++;

        int pauseTime = (seenOnScreen - 1) * 50;
        tl.pause(img->x(), pauseTime);
        tl.pause(img->y(), pauseTime);
        tl.pause(img->rotate(), pauseTime);
        img->z().setValue(-ii);

        if(ii == f) {
            tl.move(img->scale(), SMALL_ZOOM, 50);
            tl.sync(img->z(), img->scale());
            img->z().setValue(1);
            tl.set(img->z(), -ii);

            if(pauseTime > 50)
                tl.pause(img->scale(), pauseTime - 50);
        } else {
            tl.pause(img->scale(), pauseTime);
        }
    }
    seenOnScreen = 0;
    for(int ii = 0; ii < count(); ++ii) {
        if(!isOnScreen(ii))
            continue;
        seenOnScreen++;

        Image *img = image(ii);

#define PHOTO_OFFSET 7
        int idx = seenOnScreen;
        switch(idx) {
            case 0:
                tl.move(img->x(), p.x() - PHOTO_OFFSET, 150);
                tl.move(img->y(), p.y() - PHOTO_OFFSET, 150);
                tl.sync(img->quality(), img->x());
                tl.set(img->quality(), 1.);
                break;
            case 1:
                tl.move(img->x(), p.x() + PHOTO_OFFSET, 150);
                tl.move(img->y(), p.y() - PHOTO_OFFSET, 150);
                tl.sync(img->quality(), img->x());
                tl.set(img->quality(), 1.);
                break;
            case 2:
                tl.move(img->x(), p.x() + PHOTO_OFFSET, 150);
                tl.move(img->y(), p.y() + PHOTO_OFFSET, 150);
                tl.sync(img->quality(), img->x());
                tl.set(img->quality(), 1.);
                break;
            case 3:
                tl.move(img->x(), p.x() - PHOTO_OFFSET, 150);
                tl.move(img->y(), p.y() + PHOTO_OFFSET, 150);
                tl.sync(img->quality(), img->x());
                tl.set(img->quality(), 1.);
                break;
            default:
                tl.move(img->x(), p.x(), 150);
                tl.move(img->y(), p.y(), 150);
                //tl.set(img->quality(), 0.);
                break;
        }
        int rotate = (qrand() % 40) - 20;
        if(isOnScreen(ii)) {
            tl.move(img->scale(), SMALL_ZOOM * .7, 150);
            tl.move(img->rotate(), rotate, 150);
            tl.sync(image(ii)->imageParent(), image(ii)->x());
            tl.set(image(ii)->imageParent(), 1.);
        } else {
            img->scale().setValue(SMALL_ZOOM * .7);
            img->rotate().setValue(rotate);
            img->visible().setValue(0.);
            img->imageParent().setValue(1.);
        }
    } 
    tl.sync();
    seenOnScreen = 0;
    for(int ii = 0; ii < count(); ++ii) {
        if(!isOnScreen(ii))
            continue;
        seenOnScreen++;

        if(seenOnScreen > 4) 
            tl.set(image(ii)->visible(), 0.);
    }
    GfxCanvasItem *i = nameItem();
    tl.move(i->visible(), 1., 300);
}
Ejemplo n.º 12
0
//--------------------------------------------------------------
// Checks whether the given rectangle is on screen.
//--------------------------------------------------------------
bool ofxMPEClient::isOnScreen(float _x, float _y, float _w, float _h) {
    return (isOnScreen(_x, _y) ||
            isOnScreen(_x + _w, _y) ||
            isOnScreen(_x + _w, _y + _h) ||
            isOnScreen(_x, _y + _h));
}
Ejemplo n.º 13
0
void ofxTLBeatTicker::draw(){
	if (!isSetup || disabled)
		return;

	ofPushStyle();

	int textH, textW;
	string text;

	if(viewIsDirty){
		refreshTickMarks();
	}

	drawBPMGrid = true;
	tickerMarks.setStrokeColor( ofColor(0, 0, 240) );
	tickerMarks.setStrokeWidth(1);
	tickerMarks.draw(bounds.x, bounds.y);

	if(drawBPMGrid){
		if(viewIsDirty){
			updateBPMPoints();
		}
		ofPushStyle();

		ofSetColor(0, 0, 0, 200);
		ofSetLineWidth(1);

		int siz = bpmScreenPoints.size();
		int howmany;
		if (siz > 20)
			howmany = siz / 15;
		else if (siz > 12)
			howmany = 4;
		else howmany = 4;
		for(int i = 0; i < bpmScreenPoints.size(); i++) {
			if (isOnScreen(bpmScreenPoints[i].screenX)) {
				int bi = floor(bpmScreenPoints[i].beat);
				//if ((bi) % 4 == 1) { // draw bpms indices
				if ((bi) % howmany == 1) { // draw bpms indices
#if DRAW_FXCKING_GRID
						ofLine(bpmScreenPoints[i].screenX, getBottomEdge(), bpmScreenPoints[i].screenX, totalDrawRect.y+totalDrawRect.height);
#endif
						text = tostr(bi);
						textW = timeline->getFont().stringWidth(text);
						timeline->getFont().drawString(text, bpmScreenPoints[i].screenX - textW/2, getBottomEdge()-20);
				}
			}
		}
		ofPopStyle();
	}

	textH = timeline->getFont().getLineHeight();
	textW = 3;


	//draw current frame
	int currentFrameX;
	if (timeline->getIsFrameBased()) {
		//text = ofToString(timeline->getCurrentFrame());
		text = tostr(timeline->millisecToBeat(hoverTime));
		currentFrameX = screenXForIndex(timeline->getCurrentFrame());
	} else{
		//text = timeline->formatTime(timeline->getCurrentTime());
		text = tostr(timeline->millisecToBeat(hoverTime));
		currentFrameX = screenXForTime(timeline->getCurrentTime());
		//currenttimeline->normalizedXtoScreenX(timeline->beatToNormalizedX(currentPoint), zoomBounds); //;timeline->millisToScreenX(timeline->beatToMillisec(measures[0].beat));
	}
	currentFrameX = ofClamp(currentFrameX, bounds.getMinX(), bounds.getMaxX());

	//draw playhead line
	ofSetLineWidth(1);
	ofLine(currentFrameX, totalDrawRect.y, currentFrameX, totalDrawRect.y+totalDrawRect.height);
	//text = tostr(timeline->millisecToBeat(hoverTime)+1 - startBeat);
	unsigned long startBeat = timeline->normalizedXToBeat(zoomBounds.min);// * timeline->getDurationInMilliseconds();
	text = tostr( timeline->normalizedXToBeat( screenXtoNormalizedX( millisToScreenX(hoverTime), zoomBounds) ) + 1);
	//cout << "ofxTLBeatTicker: hoverTime: " << hoverTime << " text:"<< text << endl;
	float screenX = ofClamp(millisToScreenX(hoverTime), bounds.getMinX(), bounds.getMaxX());
	timeline->getFont().drawString(text, screenX, bounds.y+textH+25);
	ofPopStyle();

}
Ejemplo n.º 14
0
bool Bullet::NeedsDestruction()
{
	return needsDestruction || !isOnScreen();
}