Created
February 27, 2017 05:29
-
-
Save sledge-1/10b4c4ba17b64a3c12c4cf729a025d9d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "block.h" | |
#include "ofMain.h" | |
struct block{ | |
int x; | |
int y; | |
int z; | |
float h; | |
float w; | |
float d; | |
}; | |
struct block *constructBlock(int x, int y,int z, float h, float w, float d){ | |
struct block *myBlock = (struct block*)malloc(sizeof(struct block)); | |
myBlock->x = x; | |
myBlock->y = y; | |
myBlock->z = z; | |
myBlock->h = h; | |
myBlock->w = w; | |
myBlock->d = d; | |
return myBlock; | |
} | |
void move_block_down_and_right(struct block *block){ | |
block->x++; | |
block->y--; | |
} | |
void block_draw(struct block* block){ | |
ofDrawBox(block->x, block->y,block->z, block->h, block->w, block->d); | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma once | |
struct block *constructBlock(int x, int y, float h, float w); | |
void dot_draw(struct block* block); | |
void move_block_down_and_right(struct block *block); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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){ | |
ofColor (0,230,38); | |
ofFill(); | |
ofDrawCircle(dot->x, dot->y,dot->r); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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*); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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()); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "ofApp.h" | |
#include "dot.h" | |
#include "block.h" | |
//-------------------------------------------------------------- | |
void ofApp::setup(){ | |
//ofSetBackgroundColor(60,150,10); | |
rick_morty.load("/home/sledge/of_v0.9.8_linux64_release/apps/myApps/TaylorHW11/bin/data/images/rick_morty.jpg"); | |
ofSetCircleResolution(60); | |
whiteDot = dot_struct(0,0,20.0); | |
block = constructBlock(1000, 5, 0, 10.0, 10.0, 0.0); | |
} | |
//-------------------------------------------------------------- | |
void ofApp::update(){ | |
dot_move_right(whiteDot); | |
dot_move_down(whiteDot); | |
//dot_grow(whiteDot); | |
move_block_down_and_right(block); | |
} | |
//-------------------------------------------------------------- | |
void ofApp::draw(){ | |
rick_morty.draw(0,0,1062,600); | |
dot_draw(whiteDot); | |
block_draw(block); | |
} | |
//-------------------------------------------------------------- | |
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){ | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma once | |
#include "ofMain.h" | |
class ofApp : public ofBaseApp{ | |
public: | |
struct dot *whiteDot; | |
struct block *block; | |
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