Created
June 24, 2014 12:48
-
-
Save fkaa/51266058c15c8b835b71 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 "ruble.h" | |
Ruble::Ruble(GLFWwindow* wnd) : m_window(wnd) { | |
glfwMakeContextCurrent(m_window); | |
glMatrixMode(GL_PROJECTION); | |
glLoadIdentity(); | |
glOrtho(0, 640, 480, 0, -1, 1); | |
glEnable(GL_BLEND); | |
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); | |
emitter = new Emitter(); | |
} | |
Ruble::~Ruble() { | |
delete emitter; | |
} | |
void Ruble::start() { | |
while (!glfwWindowShouldClose(m_window)) { | |
glClearColor(0, 0, 0, 1); | |
glClear(GL_COLOR_BUFFER_BIT); | |
double x, y; | |
glfwGetCursorPos(m_window, &x, &y); | |
// mouse lines | |
glBegin(GL_LINES); | |
glColor4f(0.56f, 0.34f, 0.84f, 1); | |
glVertex2f(320.f, 240.f); | |
glVertex2f(x, y); | |
glColor4f(0.56f, 0.56f, 0.56f, 0.5f); | |
glVertex2f(320.f, 240.f); | |
glVertex2f(x, 240.f); | |
glVertex2f(x, y); | |
glVertex2f(x, 240.f); | |
glEnd(); | |
glColor4f(1, 1, 1, 1); | |
if (glfwGetKey(m_window, GLFW_KEY_S) == GLFW_PRESS) { | |
if (!toggle) { | |
toggle = true; | |
double angle = atan2(x - 320, y - 240); | |
for (size_t i = 0; i < 360; i++) { | |
emitter->push(Particle(vec2(320.f, 240.f), vec2(sin(angle), cos(angle)), 100.f)); | |
} | |
} | |
} | |
if (glfwGetKey(m_window, GLFW_KEY_S) == GLFW_RELEASE) { | |
toggle = false; | |
} | |
if (glfwGetKey(m_window, GLFW_KEY_R) == GLFW_PRESS) { | |
emitter->clear(); | |
} | |
glBegin(GL_POINTS); | |
emitter->update(); // glVertex2f | |
glEnd(); | |
glfwSwapBuffers(m_window); | |
glfwPollEvents(); | |
} | |
} | |
void Ruble::update() { | |
} | |
void Ruble::draw() { | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment