Skip to content

Instantly share code, notes, and snippets.

@companje
Created December 6, 2011 11:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save companje/1437868 to your computer and use it in GitHub Desktop.
Save companje/1437868 to your computer and use it in GitHub Desktop.
#include "testApp.h"
//--------------------------------------------------------------
void testApp::setup(){
ofSetFrameRate(60); //limit framerate to 60
ofSetBackgroundAuto(false); //turn off automatic background clearing
ofEnableAlphaBlending(); //enable transparency
ofBackground(0); //set background to black
ball.x = 100; //initial position for ball
ball.y = 200;
}
//--------------------------------------------------------------
void testApp::update(){
ball.x = ball.x + 5; //update position off ball
ball.y = ball.y + 5;
if (ball.x > ofGetWidth()) ball.x = 0; //if ball disappears let it appear again
if (ball.y > ofGetHeight()) ball.y = 0;
}
//--------------------------------------------------------------
void testApp::draw(){
//draw a semi transparent black rectangle
ofSetColor(0,20);
ofRect(0,0,ofGetWidth(),ofGetHeight());
//draw a white circle
ofSetColor(255);
ofCircle(ball.x, ball.y, 50);
}
//--------------------------------------------------------------
void testApp::keyPressed(int key){
}
//--------------------------------------------------------------
void testApp::keyReleased(int key){
}
//--------------------------------------------------------------
void testApp::mouseMoved(int x, int y ){
}
//--------------------------------------------------------------
void testApp::mouseDragged(int x, int y, int button){
}
//--------------------------------------------------------------
void testApp::mousePressed(int x, int y, int button){
}
//--------------------------------------------------------------
void testApp::mouseReleased(int x, int y, int button){
}
//--------------------------------------------------------------
void testApp::windowResized(int w, int h){
}
//--------------------------------------------------------------
void testApp::gotMessage(ofMessage msg){
}
//--------------------------------------------------------------
void testApp::dragEvent(ofDragInfo dragInfo){
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment