Skip to content

Instantly share code, notes, and snippets.

@tado
Last active December 23, 2015 23: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 tado/6710045 to your computer and use it in GitHub Desktop.
Save tado/6710045 to your computer and use it in GitHub Desktop.
#include "Particle.h" // 必ずヘッダーファイルを読み込む
void Particle::draw(){
// 円を描画
ofSetHexColor(0x3399cc);
ofCircle(position, 10);
}
#pragma once //インクルードガード
#include "ofMain.h" // oFの機能をインポート
class Particle {
public:
void draw();
ofVec2f position;
};
// 最後にセミコロンを忘れずに!!
#include "testApp.h"
//--------------------------------------------------------------
void testApp::setup(){
// 画面基本設定
ofSetFrameRate(60);
ofBackground(63);
// 画面内のランダムな場所を指定
particle.position.x = ofRandom(ofGetWidth());
particle.position.y = ofRandom(ofGetHeight());
}
//--------------------------------------------------------------
void testApp::update(){
}
//--------------------------------------------------------------
void testApp::draw(){
// 設定した場所に円を描く
particle.draw();
}
#pragma once
#include "ofMain.h"
#include "Particle.h" // Particleクラスのヘッダーを読み込む
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);
Particle particle; // Particleをインスタンス化(実体化)
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment