Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

version inicial

  • Loading branch information...
commit e0e3b30b3c807285f4291e97bbb0a37afec3d322 1 parent baa94e3
@lucasdm lucasdm authored
View
15 .gitignore
@@ -0,0 +1,15 @@
+*.app
+build/
+Project.xcconfig
+*.xccodeproj/
+openFrameworks-Info.plist
+
+tallerOF_025.xcodeproj/lucasdm.mode1v3
+
+tallerOF_025.xcodeproj/lucasdm.pbxuser
+
+tallerOF_025.xcodeproj/project.pbxproj
+
+tallerOF_025.xcodeproj/project.xcworkspace/contents.xcworkspacedata
+
+tallerOF_025.xcodeproj/xcshareddata/xcschemes/tallerOF_025.xcscheme
View
0  bin/data/.gitkeep
No changes.
View
32 src/Particula.cpp
@@ -0,0 +1,32 @@
+#include "Particula.h";
+
+Particula::Particula(){
+ tamanio = ofRandom(8);
+ color.set(ofRandom(255),ofRandom(255),ofRandom(255));
+ pos.set(ofGetWindowWidth()/2,ofGetWindowHeight()/2);
+ vel.set(ofRandom(-1,1),ofRandom(-1,1));
+ acc.set(ofRandom(-1,1),ofRandom(-1,1));
+}
+
+void Particula::agregarFuerza(ofVec2f fuerza){
+ acc += fuerza;
+}
+
+void Particula::update(){
+ vel += acc;
+ pos += vel;
+ acc *= 0;
+}
+
+void Particula::draw(){
+ ofSetColor(color);
+ ofCircle(pos.x, pos.y, tamanio);
+}
+
+bool Particula::pasoElBorde(){
+ bool rta = false;
+ if ( pos.x < 0 || pos.y < 0 || pos.x > ofGetWindowWidth() || pos.y > ofGetWindowHeight())
+ rta = true;
+
+ return rta;
+}
View
22 src/Particula.h
@@ -0,0 +1,22 @@
+
+#ifndef PARTICULA
+#define PARTICULA
+
+#include "ofMain.h"
+
+class Particula {
+public:
+ Particula();
+
+ void update();
+ void draw();
+ bool pasoElBorde();
+ void agregarFuerza(ofVec2f fuerza);
+
+ ofColor color;
+ ofVec2f pos, vel, acc;
+
+ int tamanio;
+
+};
+#endif
View
16 src/main.cpp
@@ -0,0 +1,16 @@
+#include "ofMain.h"
+#include "testApp.h"
+#include "ofAppGlutWindow.h"
+
+//========================================================================
+int main( ){
+
+ ofAppGlutWindow window;
+ ofSetupOpenGL(&window, 1024,768, 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 testApp());
+
+}
View
81 src/testApp.cpp
@@ -0,0 +1,81 @@
+#include "testApp.h"
+
+//--------------------------------------------------------------
+void testApp::setup(){
+ ofSetCircleResolution(200);
+ ofEnableSmoothing();
+ ofSetVerticalSync(true);
+ ofHideCursor();
+ ofSetFullscreen(true);
+ for(int i = 0; i < TOTAL; i++){
+ p[i].pos.set(ofRandom(ofGetWindowWidth()),ofRandom(ofGetWindowHeight()));
+ }
+}
+
+//--------------------------------------------------------------
+void testApp::update(){
+ ofSetWindowTitle("fps: " + ofToString(ofGetFrameRate()));
+ for(int i = 0; i < TOTAL; i++){
+ p[i].agregarFuerza(ofVec2f(0,0.0098));
+ p[i].update();
+
+ if (p[i].pasoElBorde()){
+ p[i] = Particula();
+ p[i].pos.set(mouseX,mouseY);
+ }
+ }
+}
+
+//--------------------------------------------------------------
+void testApp::draw(){
+ ofBackground(0);
+
+ for(int i = 0; i < TOTAL; i++){
+ p[i].draw();
+ }
+}
+
+//--------------------------------------------------------------
+void testApp::keyPressed(int key){
+
+}
+
+//--------------------------------------------------------------
+void testApp::keyReleased(int key){
+
+}
+
+//--------------------------------------------------------------
+void testApp::mouseMoved(int x, int y ){
+
+}
+
+//--------------------------------------------------------------
+void testApp::mouseDragged(int x, int y, int button){
+
+}
+
+//--------------------------------------------------------------
+void testApp::mousePressed(int x, int y, int button){
+
+}
+
+//--------------------------------------------------------------
+void testApp::mouseReleased(int x, int y, int button){
+
+}
+
+//--------------------------------------------------------------
+void testApp::windowResized(int w, int h){
+
+}
+
+//--------------------------------------------------------------
+void testApp::gotMessage(ofMessage msg){
+
+}
+
+//--------------------------------------------------------------
+void testApp::dragEvent(ofDragInfo dragInfo){
+
+}
View
23 src/testApp.h
@@ -0,0 +1,23 @@
+#pragma once
+
+#include "ofMain.h"
+#include "Particula.h"
+#define TOTAL 500
+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);
+ Particula p[TOTAL];
+};
Please sign in to comment.
Something went wrong with that request. Please try again.