Skip to content

Instantly share code, notes, and snippets.

@sledge-1
Created February 23, 2017 03:07
Show Gist options
  • Save sledge-1/227949e211e336810aa8be172d9e0097 to your computer and use it in GitHub Desktop.
Save sledge-1/227949e211e336810aa8be172d9e0097 to your computer and use it in GitHub Desktop.
#include "dot.h"
#include "ofMain.h"
struct dot {
int x;
int y;
float r;
ofColor color;
};
struct dot *dot_struct(int x, int y, float r){
struct dot *thisDot = (struct dot*)malloc(sizeof(struct dot));
thisDot->x = x;
thisDot->y = y;
thisDot->r = r;
return thisDot;
}
void dot_move_right(struct dot* dot){
dot->x++;
}
void dot_move_down(struct dot* dot){
dot->y++;
}
void dot_grow(struct dot* dot){
float growthRate = 0.0025;
dot->r = dot->r + (dot->r * growthRate);
}
void dot_draw(struct dot* dot){
ofDrawCircle(dot->x, dot->y,dot->r);
ofColor green(0,230,38);
ofSetColor(green);
}
#pragma once
struct dot* dot_struct(int x, int y, float r);
void dot_draw(struct dot*);
void dot_move_right(struct dot*);
void dot_move_down(struct dot*);
void dot_grow(struct dot*);
#include "ofMain.h"
#include "ofApp.h"
//========================================================================
int main( ){
ofSetupOpenGL(1062,600,OF_WINDOW); // <-------- setup the GL context
// this kicks off the running of my app
// can be OF_WINDOW or OF_FULLSCREEN
// pass in width and height too:
ofRunApp(new ofApp());
}
#include "ofApp.h"
#include "dot.h"
//--------------------------------------------------------------
void ofApp::setup(){
//ofSetBackgroundColor(60,150,10);
rick_morty.load("/home/sledge/of_v0.9.8_linux64_release/apps/myApps/TaylorHW11/bin/images/rick_morty.jpg");
ofSetCircleResolution(60);
whiteDot = dot_struct(0,0,20.0);
}
//--------------------------------------------------------------
void ofApp::update(){
dot_move_right(whiteDot);
dot_move_down(whiteDot);
dot_grow(whiteDot);
}
//--------------------------------------------------------------
void ofApp::draw(){
rick_morty.draw(0,0,1062,600);
dot_draw(whiteDot);
}
//--------------------------------------------------------------
void ofApp::keyPressed(int key){
}
//--------------------------------------------------------------
void ofApp::keyReleased(int key){
}
//--------------------------------------------------------------
void ofApp::mouseMoved(int x, int y ){
}
//--------------------------------------------------------------
void ofApp::mouseDragged(int x, int y, int button){
}
//--------------------------------------------------------------
void ofApp::mousePressed(int x, int y, int button){
}
//--------------------------------------------------------------
void ofApp::mouseReleased(int x, int y, int button){
}
//--------------------------------------------------------------
void ofApp::mouseEntered(int x, int y){
}
//--------------------------------------------------------------
void ofApp::mouseExited(int x, int y){
}
//--------------------------------------------------------------
void ofApp::windowResized(int w, int h){
}
//--------------------------------------------------------------
void ofApp::gotMessage(ofMessage msg){
}
//--------------------------------------------------------------
void ofApp::dragEvent(ofDragInfo dragInfo){
}
#pragma once
#include "ofMain.h"
class ofApp : public ofBaseApp{
public:
struct dot *whiteDot;
void setup();
void update();
void draw();
ofImage rick_morty;
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 mouseEntered(int x, int y);
void mouseExited(int x, int y);
void windowResized(int w, int h);
void dragEvent(ofDragInfo dragInfo);
void gotMessage(ofMessage msg);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment