void drawGreta(const Vector natCenter) { double angle; Vector natCoordConnect; Vector circleVectors[SIGN_HG_CIRCLE_LINE_NUM]; for (int i = 0; i < SIGN_HG_CIRCLE_LINE_NUM; i++) { angle = i * 2 * M_PI / SIGN_HG_CIRCLE_LINE_NUM; Vector natCoord = Vector(natCenter.x + (cos(angle) * SIGN_HG_CIRCLE_RADIUS), natCenter.y + (sin(angle) * SIGN_HG_CIRCLE_RADIUS)); circleVectors[i] = convertNatToGl(natCoord); if (fequals(angle, (3.0 / 2) * M_PI)) { natCoordConnect = natCoord; } } glColor3f(COLOR_GRETA.r, COLOR_GRETA.g, COLOR_GRETA.b); glBegin(GL_LINE_LOOP); ns_glVertex2Vectors(circleVectors, SIGN_HG_CIRCLE_LINE_NUM); glEnd(); Vector glCoordConnect = convertNatToGl(natCoordConnect); Vector glCoordConnectLineEnd = convertNatToGl(Vector(natCoordConnect.x, natCoordConnect.y - 500)); Vector glCoordCrossLine = convertNatToGl(Vector(natCoordConnect.x - 150, natCoordConnect.y - 250)); Vector glCoordCrossLineEnd = convertNatToGl(Vector(natCoordConnect.x + 150, natCoordConnect.y - 250)); const Vector lineVectors[] = {glCoordConnect, glCoordConnectLineEnd, glCoordCrossLine, glCoordCrossLineEnd}; glBegin(GL_LINES); ns_glVertex2Vectors(lineVectors, 4); glEnd(); }
void UINode::renderDebug (int x, int y, int textY) const { const int panelX = getRenderX(); const int panelY = getRenderY(); const int w = getRenderWidth(false); const int h = getRenderHeight(false); const Color* color[5]; color[0] = &colorGreen; color[1] = &colorBlue; color[2] = &colorRed; color[3] = &colorYellow; color[4] = &colorCyan; const int index = (panelX * 22 * h + panelY * 23 * w) % 5; renderRect(x + getRenderX(false), y + getRenderY(false), w, h, *color[index]); if (!fequals(_padding, 0.0f)) { renderRect(x + panelX, y + panelY, getRenderWidth(), getRenderHeight(), *color[index]); } renderFilledRect(x + getRenderCenterX(), y + getRenderCenterY(), 4, 4, colorRed); renderFilledRect(x + panelX, y + panelY, 4, 4, colorBlue); const BitmapFontPtr& font = getFont(MEDIUM_FONT); int panelTextY = textY; for (UINodeListConstIter i = _nodes.begin(); i != _nodes.end(); ++i) { const UINode* nodePtr = *i; if (!nodePtr->hasFocus()) continue; nodePtr->renderDebug(x + panelX, y + panelY, panelTextY); const std::string debugInfo = "[id=" + nodePtr->getId() + "]"; _frontend->renderFilledRect(x - 1, panelTextY + 1, font->getTextWidth(debugInfo) + 2, font->getTextHeight(debugInfo) + 2, colorGrayAlpha); font->print(debugInfo, colorCyan, x, panelTextY); panelTextY += font->getTextHeight(debugInfo); } }
void drawHansel(const Vector natCenter) { double angle; Vector natCoordConnect; Vector circleVectors[SIGN_HG_CIRCLE_LINE_NUM]; for (int i = 0; i < SIGN_HG_CIRCLE_LINE_NUM; i++) { angle = i * 2 * M_PI / SIGN_HG_CIRCLE_LINE_NUM; Vector natCoord = Vector(natCenter.x + (cos(angle) * SIGN_HG_CIRCLE_RADIUS), natCenter.y + (sin(angle) * SIGN_HG_CIRCLE_RADIUS)); circleVectors[i] = convertNatToGl(natCoord); if (fequals(angle, 0.2 * M_PI)) { natCoordConnect = natCoord; } } glColor3f(COLOR_HANSEL.r, COLOR_HANSEL.g, COLOR_HANSEL.b); glBegin(GL_LINE_LOOP); ns_glVertex2Vectors(circleVectors, SIGN_HG_CIRCLE_LINE_NUM); glEnd(); Vector glCoordConnect = convertNatToGl(natCoordConnect); Vector glCoordConnectLineEnd = convertNatToGl(Vector(natCoordConnect.x + 350, natCoordConnect.y + 300)); Vector glCoordArrowLineEnd_1 = convertNatToGl(Vector(natCoordConnect.x + 100, natCoordConnect.y + 300)); Vector glCoordArrowLineEnd_2 = convertNatToGl(Vector(natCoordConnect.x + 350, natCoordConnect.y + 50)); const Vector lineVectors[] = {glCoordConnect, glCoordConnectLineEnd, glCoordConnectLineEnd, glCoordArrowLineEnd_1, glCoordConnectLineEnd, glCoordArrowLineEnd_2}; glBegin(GL_LINES); ns_glVertex2Vectors(lineVectors, 6); glEnd(); }
bool onDiffLevels(Lift &lift) { float const deltaY = 0.01; if (fequals(headPoints[0].Y() - W_HEAD_SIZE, lift.getBeginP().Y() + deltaY)) { return false; } return true; }
void UINode::addFocus (int32_t x, int32_t y) { _focusMouseX = x; _focusMouseY = y; if (_focus) return; _focus = true; Log::debug(LOG_CLIENT, "focus for %s", getId().c_str()); for (Listeners::iterator i = _listeners.begin(); i != _listeners.end(); ++i) { (*i)->onAddFocus(); } if (!fequals(_focusAlpha, 0.0f)) setAlpha(_focusAlpha); }
void simulateWorld(float tstart, float tend) { float dt = 50; for (float ts = tstart; ts < tend; ts += dt) { float te; if (tend >= ts + dt) { te = ts + dt; } else { te = tend; } greenWorm.control(ts, te); redWorm.control(ts, te); //utkozesdetekt //piros utoleri a zoldet int const lastPoint = greenWorm.getLength() / W_TAIL_RESOLUTION; if (fequals(redWorm.getHeadPoints()[0].X(), greenWorm.getHeadPoints()[0].X()) && fequals(redWorm.getHeadPoints()[0].Y(), greenWorm.getHeadPoints()[0].Y())) { gameOver = true; win = true; } } }
void UINodeSlider::setValue (float value) { if (value > _max) return; if (value < _min) return; if (fequals(value, _value)) return; _value = value; for (Listeners::iterator i = _listeners.begin(); i != _listeners.end(); ++i) { (*i)->onValueChanged(); } }
int findMaxIndexDouble(double * x, int n) { int i, index; assert(n > 0); index = 0; for (i = 0; i < n; i++) { #if (FORCE_DETERM_ARITH) if (! fequals(x[i], x[index])) #endif if (x[i] > x[index]) index = i; } return index; }
void UINode::removeFocus () { if (!_focus) return; Log::debug(LOG_CLIENT, "remove focus for %s", getId().c_str()); _focus = false; _focusMouseX = -1; _focusMouseY = -1; for (Listeners::iterator i = _listeners.begin(); i != _listeners.end(); ++i) { (*i)->onRemoveFocus(); } if (!fequals(_focusAlpha, 0.0f)) restoreAlpha(); for (UINodeListIter i = _nodes.begin(); i != _nodes.end(); ++i) { UINode* node = *i; if (!node->hasFocus()) continue; node->removeFocus(); } }
void UINode::renderLine (int x1, int y1, int x2, int y2, const Color& color) const { const float alpha = fequals(_alpha, 1.0f) ? color[3] : _alpha; const Color alphaColor = { color[0], color[1], color[2], alpha }; _frontend->renderLine(x1, y1, x2, y2, alphaColor); }
void UINode::renderFilledRect (int x, int y, int w, int h, const Color& color) const { const float alpha = fequals(_alpha, 1.0f) ? color[3] : _alpha; const Color alphaColor = { color[0], color[1], color[2], alpha }; _frontend->renderFilledRect(x, y, w, h, alphaColor); }
void checkKilled(Lift &lift) { if (!onTheLift(lift) && fequals(lift.getBeginP().Y(), fieldElements[6][0].Y())) { gameOver = true; } }