Skip to content

Instantly share code, notes, and snippets.

@tado
Last active December 23, 2015 23:38
Show Gist options
  • Select an option

  • Save tado/6710857 to your computer and use it in GitHub Desktop.

Select an option

Save tado/6710857 to your computer and use it in GitHub Desktop.
#include "Particle.h"
void Particle::setup(ofVec2f _position){
position = _position;
}
void Particle::draw(){
ofSetHexColor(0x3399cc);
ofCircle(position, 10);
}
#pragma once
#include "ofMain.h"
class Particle {
public:
ofVec2f position;
void setup(ofVec2f position);
void draw();
};
#include "testApp.h"
//--------------------------------------------------------------
void testApp::setup(){
// 画面基本設定
ofSetFrameRate(60);
ofBackground(63);
for(int i = 0; i < NUM; i++){
float posX = ofRandom(ofGetWidth());
float posY = ofRandom(ofGetHeight());
particle[i].setup(ofVec2f(posX, posY));
}
}
//--------------------------------------------------------------
void testApp::update(){
}
//--------------------------------------------------------------
void testApp::draw(){
// 設定した場所に円を描く
for(int i = 0; i < NUM; i++){
particle[i].draw();
}
}
#pragma once
#include "ofMain.h"
#include "Particle.h"
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);
void dragEvent(ofDragInfo dragInfo);
void gotMessage(ofMessage msg);
static const int NUM = 100;
Particle particle[NUM];
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment