Screen re-positioning

Hey I’m a beginner to openframeworks and I was wondering how I would make the screen change positions. I want to make a game kind of like where you’re a circle and the screen moves with the player. The player would always be at the center of the screen. Anything would help and I feel like it might be something very basic but I’ve been looking all over for a solution and cant find anything. Thanks in advance!!!

You can use matrices.
For example, if the player is located at

ofPoint player;

You can do in ofApp::draw() :

// Save current matrix

// Center the view around the player
ofTranslate( ofGetWidth() / 2.f, ofGetHeight() / 2.f );
ofTranslate( - player.x, - player.y );

// Draw all the graphics that must take place in the scrolling view
// This include the player:
ofSetColor( 255, 0, 0 );
ofCircle( player, 40 ); // or ofDrawCircle( player, 40 ); in OF 0.9.0

// Restore previous matrix

// Here you can draw things that are not in the scrolling view, like informations, HUD, score, GUI...

Full working example for OF 0.8.4 : (1.8 KB)

For matrices tutorial:

1 Like

wow dude this is exactly what i was looking for and thanks so much for the help!!!