Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Sbaw090519

4,354 views

Published on

  • Be the first to comment

Sbaw090519

  1. 1. #import quot;GraphView.hquot; // AppDelegate class interface. @interface AppDelegate : NSObject <UIAccelerometerDelegate> { IBOutlet UIWindow *window; IBOutlet GraphView *graphView; IBOutlet UIToolbar *toolbar; } @property (nonatomic, retain) UIWindow *window; @property (nonatomic, retain) GraphView *graphView; @property (nonatomic, retain) UIToolbar *toolbar; - (IBAction)toggleRun:(id)sender; - (IBAction)toggleFiltering:(id)sender;
  2. 2. #include quot;testApp.hquot; //-------------------------------------------------------------- void testApp::setup(){ } //-------------------------------------------------------------- void testApp::update(){ } //-------------------------------------------------------------- void testApp::draw(){ // ofSetColor(63, 127, 255); // ofCircle(ofGetWidth() / 2, ofGetHeight() / 2, 100); }
  3. 3. #ifndef _TEST_APP #define _TEST_APP #include quot;ofMain.hquot; class testApp : public ofBaseApp{ public: void setup(); void update(); void draw(); ... ( ) ... private: float posX, posY; float speedX, speedY; }; #endif
  4. 4. #include quot;testApp.hquot; void testApp::draw(){ // void testApp::setup(){ ofSetColor(63, 127, 255); ofBackground(0,0,0); // posX = ofGetWidth() / 2; posY = ofGetHeight() / 2; ofCircle(posX, posY, 100); speedX = ofRandom(-5, 5); } speedY = ofRandom(-5, 5); } void testApp::update(){ posX += speedX; if(posX < 0 || posX > ofGetWidth()){ speedX *= -1; } posY += speedY; if(posY < 0 || posY > ofGetHeight()){ speedY *= -1; } }
  5. 5. #ifndef _TEST_APP #define _TEST_APP #include quot;ofMain.hquot; #define BALL_NUM 100 class testApp : public ofBaseApp{ public: void setup(); void update(); void draw(); void keyPressed(int key); void keyReleased(int key); void mouseMoved(int x, int y ); void mouseDragged(int x, int y, int button); void mousePressed(int x, int y, int button); void mouseReleased(int x, int y, int button); void windowResized(int w, int h); private: float posX[BALL_NUM], posY[BALL_NUM]; float speedX[BALL_NUM], speedY[BALL_NUM]; }; #endif
  6. 6. #include quot;testApp.hquot; //-------------------------------------- void testApp::setup(){ ofBackground(0,0,0); for(int i = 0; i < BALL_NUM; i++){ posX[i] = ofGetWidth() / 2; posY[i] = ofGetHeight() / 2; speedX[i] = ofRandom(-1, 1); speedY[i] = ofRandom(-1, 1); } } //-------------------------------------- void testApp::update(){ for(int i = 0; i < BALL_NUM; i++){ posX[i] += speedX[i]; if(posX[i] < 0 || posX[i] > ofGetWidth()){ speedX[i] *= -1; } posY[i] += speedY[i]; if(posY[i] < 0 || posY[i] > ofGetHeight()){ speedY[i] *= -1; } } }
  7. 7. //-------------------------------------- void testApp::draw(){ for(int i = 0; i < BALL_NUM; i++){ // ofSetColor(63, 127, 255); // ofCircle(posX[i], posY[i], 20); } } ... ( )
  8. 8. #ifndef _TEST_APP #define _TEST_APP #include quot;ofMain.hquot; #define BALL_NUM 100 class testApp : public ofBaseApp{ public: void setup(); void update(); void draw(); void keyPressed(int key); void keyReleased(int key); void mouseMoved(int x, int y ); void mouseDragged(int x, int y, int button); void mousePressed(int x, int y, int button); void mouseReleased(int x, int y, int button); void windowResized(int w, int h); private: float posX[BALL_NUM], posY[BALL_NUM]; float speedX[BALL_NUM], speedY[BALL_NUM]; }; #endif
  9. 9. #include quot;testApp.hquot; //-------------------------------------- void testApp::setup(){ ofBackground(0,0,0); for(int i = 0; i < BALL_NUM; i++){ posX[i] = ofGetWidth() / 2; posY[i] = ofGetHeight() / 2; speedX[i] = ofRandom(-1, 1); speedY[i] = ofRandom(-1, 1); } } //-------------------------------------- void testApp::update(){ for(int i = 0; i < BALL_NUM; i++){ posX[i] += speedX[i]; if(posX[i] < 0 || posX[i] > ofGetWidth()){ speedX[i] *= -1; } posY[i] += speedY[i]; if(posY[i] < 0 || posY[i] > ofGetHeight()){ speedY[i] *= -1; } } }
  10. 10. //-------------------------------------- void testApp::draw(){ for(int i = 0; i < BALL_NUM; i++){ // ofSetColor(63, 127, 255); // ofCircle(posX[i], posY[i], 20); } } ... ( )

×