void Player::internalDraw(int count) { for (int i = 0; i < count; i++) { internalDraw(); } }
void Thing::internalDraw(const Point& dest, float scaleFactor, int xPattern, int yPattern, int zPattern, int animationPhase) { for(int l = 0; l < getLayers(); ++l) for(int w = 0; w < getDimensionWidth(); ++w) for(int h = 0; h < getDimensionHeight(); ++h) internalDraw(dest - Point(w,h)*Otc::TILE_PIXELS*scaleFactor, scaleFactor, w, h, xPattern, yPattern, zPattern, l, animationPhase); }
void Player::draw() { internalDraw(); DrawEvent drawEvent(game, { hand->cards.back() }, shared_from_this()); game->eventHandler(std::make_shared<DrawEvent>(drawEvent)); }
void Player::draw(int count) { internalDraw(count); auto first = hand->cards.end() - count; auto last = hand->cards.end(); std::vector<std::shared_ptr<Card>> drawnCards(first, last); DrawEvent drawEvent(game, drawnCards, shared_from_this()); game->eventHandler(std::make_shared<DrawEvent>(drawEvent)); }
void draw(sf::RenderTarget& target, sf::RenderStates states) const { if(_visible) internalDraw(target, states); }
void Effect::draw(const Point& p, const Rect&) { internalDraw(p, 0); }
void Missile::draw(const Point& p, const Rect&) { float time = (g_clock.ticks() - m_startTicks) / m_duration; internalDraw(p + Point(m_posDelta.x * time, m_posDelta.y * time), 0); }
void Player::startGameSetup() { board->deck->shuffle(); internalDraw(5); }
void XWindow::handleEvent(XEvent& Event) { switch (Event.type) { case KeyPress: //produceKeyPressed(determineKey(wParam),getKeyModifiers()); _LastKeyboardMouseButtonMask = Event.xkey.state; produceKeyPressed(determineKey(XLookupKeysym(&(Event.xkey), 0)),determineKeyModifiers(Event.xkey.state)); break; case KeyRelease: //produceKeyReleased(determineKey(wParam),getKeyModifiers()); _LastKeyboardMouseButtonMask = Event.xkey.state; produceKeyReleased(determineKey(XLookupKeysym(&(Event.xkey),0)),determineKeyModifiers(Event.xkey.state)); break; case MotionNotify: { _LastKeyboardMouseButtonMask = Event.xmotion.state; _LastMousePosition.setValues(Event.xbutton.x, Event.xbutton.y); if(Event.xmotion.state & Button1MotionMask) { produceMouseDragged(MouseEventDetails::BUTTON1,Pnt2f(Event.xmotion.x, Event.xmotion.y), Vec2f(0.0f,0.0f)); } if(Event.xmotion.state & Button2MotionMask) { produceMouseDragged(MouseEventDetails::BUTTON2,Pnt2f(Event.xmotion.x, Event.xmotion.y), Vec2f(0.0f,0.0f)); } if(Event.xmotion.state & Button3MotionMask) { produceMouseDragged(MouseEventDetails::BUTTON3,Pnt2f(Event.xmotion.x, Event.xmotion.y), Vec2f(0.0f,0.0f)); } if(Event.xmotion.state & Button4MotionMask) { produceMouseDragged(MouseEventDetails::BUTTON4,Pnt2f(Event.xmotion.x, Event.xmotion.y), Vec2f(0.0f,0.0f)); } if(Event.xmotion.state & Button5MotionMask) { produceMouseDragged(MouseEventDetails::BUTTON5,Pnt2f(Event.xmotion.x, Event.xmotion.y), Vec2f(0.0f,0.0f)); } produceMouseMoved(Pnt2f(Event.xmotion.x, Event.xmotion.y), Vec2f(0.0f,0.0f)); break; } case ButtonPress: { _LastKeyboardMouseButtonMask = Event.xbutton.state; _LastMousePosition.setValues(Event.xbutton.x, Event.xbutton.y); MouseEventDetails::MouseButton OSGButton(MouseEventDetails::NO_BUTTON); switch(Event.xbutton.button) { case 1: OSGButton = MouseEventDetails::BUTTON1; break; case 2: OSGButton = MouseEventDetails::BUTTON2; break; case 3: OSGButton = MouseEventDetails::BUTTON3; break; case 4: produceMouseWheelMoved(1, Pnt2f(Event.xbutton.x, Event.xbutton.y)); break; case 5: produceMouseWheelMoved(-1, Pnt2f(Event.xbutton.x, Event.xbutton.y)); break; case 6: OSGButton = MouseEventDetails::BUTTON6; break; case 7: OSGButton = MouseEventDetails::BUTTON7; break; case 8: OSGButton = MouseEventDetails::BUTTON8; break; case 9: OSGButton = MouseEventDetails::BUTTON9; break; case 10: OSGButton = MouseEventDetails::BUTTON10; break; default: OSGButton = MouseEventDetails::NO_BUTTON; break; } if(OSGButton != MouseEventDetails::NO_BUTTON) { produceMousePressed(OSGButton, Pnt2f(Event.xbutton.x, Event.xbutton.y)); } break; } case ButtonRelease: { _LastKeyboardMouseButtonMask = Event.xbutton.state; _LastMousePosition.setValues(Event.xbutton.x, Event.xbutton.y); MouseEventDetails::MouseButton OSGButton(MouseEventDetails::NO_BUTTON); switch(Event.xbutton.button) { case 1: OSGButton = MouseEventDetails::BUTTON1; break; case 2: OSGButton = MouseEventDetails::BUTTON2; break; case 3: OSGButton = MouseEventDetails::BUTTON3; break; case 6: OSGButton = MouseEventDetails::BUTTON6; break; case 7: OSGButton = MouseEventDetails::BUTTON7; break; case 8: OSGButton = MouseEventDetails::BUTTON8; break; case 9: OSGButton = MouseEventDetails::BUTTON9; break; case 10: OSGButton = MouseEventDetails::BUTTON10; break; default: break; } if(OSGButton != MouseEventDetails::NO_BUTTON) { produceMouseReleased(OSGButton, Pnt2f(Event.xbutton.x, Event.xbutton.y)); } break; } case ConfigureNotify: this->resize( Event.xconfigure.width, Event.xconfigure.height ); internalReshape(Vec2f(Event.xconfigure.width, Event.xconfigure.height)); break; case DestroyNotify: produceWindowClosing(); produceWindowClosed(); break; case EnterNotify: produceWindowEntered(); break; case LeaveNotify: produceWindowExited(); break; case UnmapNotify: produceWindowIconified(); break; case MapNotify: produceWindowDeiconified(); break; case FocusIn: produceWindowActivated(); break; case FocusOut: produceWindowDeactivated(); break; case Expose: internalDraw(); break; case ClientMessage: { Atom wm_delete_window=XInternAtom(this->getDisplay(), "WM_DELETE_WINDOW", False); Atom wm_protocols=XInternAtom(this->getDisplay(), "WM_PROTOCOLS", False); if (Event.xclient.message_type == wm_protocols && Event.xclient.data.l[0] == (long)wm_delete_window) { XDestroyWindow(this->getDisplay(),this->getWindow()); } break; } default: //std::cout << "Event Type: " << Event.type << std::endl; break; } }
void XWindow::draw(void) { internalDraw(); }
void Creature::draw(const Point& p, const Rect&) { if(m_showVolatileSquare) { g_painter.setColor(m_volatileSquareColor); g_painter.drawBoundingRect(Rect(p + m_walkOffset - Point(m_type->parameters[ThingType::DisplacementX], m_type->parameters[ThingType::DisplacementY]) + 3, Size(28, 28)), 2); } if(m_showStaticSquare) { g_painter.setColor(m_staticSquareColor); g_painter.drawBoundingRect(Rect(p + m_walkOffset - Point(m_type->parameters[ThingType::DisplacementX], m_type->parameters[ThingType::DisplacementY]) + 1, Size(32, 32)), 2); } g_painter.setColor(Fw::white); if(!outfitProgram) { outfitProgram = PainterShaderProgramPtr(new PainterShaderProgram); outfitProgram->addShaderFromSourceCode(Shader::Vertex, glslMainWithTexCoordsVertexShader + glslPositionOnlyVertexShader); outfitProgram->addShaderFromSourceFile(Shader::Fragment, "/game_shaders/outfit.frag"); assert(outfitProgram->link()); outfitProgram->bindUniformLocation(HEAD_COLOR_UNIFORM, "headColor"); outfitProgram->bindUniformLocation(BODY_COLOR_UNIFORM, "bodyColor"); outfitProgram->bindUniformLocation(LEGS_COLOR_UNIFORM, "legsColor"); outfitProgram->bindUniformLocation(FEET_COLOR_UNIFORM, "feetColor"); outfitProgram->bindUniformLocation(MASK_TEXTURE_UNIFORM, "maskTexture"); } // Render creature if(m_outfit.getCategory() == ThingsType::Creature) { for(m_yPattern = 0; m_yPattern < m_type->dimensions[ThingType::PatternY]; m_yPattern++) { // continue if we dont have this addon. if(m_yPattern > 0 && !(m_outfit.getAddons() & (1 << (m_yPattern-1)))) continue; g_painter.setCustomProgram(outfitProgram); outfitProgram->bind(); outfitProgram->setUniformValue(HEAD_COLOR_UNIFORM, m_outfit.getHeadColor()); outfitProgram->setUniformValue(BODY_COLOR_UNIFORM, m_outfit.getBodyColor()); outfitProgram->setUniformValue(LEGS_COLOR_UNIFORM, m_outfit.getLegsColor()); outfitProgram->setUniformValue(FEET_COLOR_UNIFORM, m_outfit.getFeetColor()); for(int h = 0; h < m_type->dimensions[ThingType::Height]; h++) { for(int w = 0; w < m_type->dimensions[ThingType::Width]; w++) { int spriteId = m_type->getSpriteId(w, h, 0, m_xPattern, m_yPattern, m_zPattern, m_animation); if(!spriteId) continue; TexturePtr spriteTex = g_sprites.getSpriteTexture(spriteId); if(!spriteTex) continue; if(m_type->dimensions[ThingType::Layers] > 1) { int maskId = m_type->getSpriteId(w, h, 1, m_xPattern, m_yPattern, m_zPattern, m_animation); TexturePtr maskTex = g_sprites.getSpriteTexture(maskId); outfitProgram->setUniformTexture(MASK_TEXTURE_UNIFORM, maskTex, 1); } Rect drawRect(((p + m_walkOffset).x - w*32) - m_type->parameters[ThingType::DisplacementX], ((p + m_walkOffset).y - h*32) - m_type->parameters[ThingType::DisplacementY], 32, 32); g_painter.drawTexturedRect(drawRect, spriteTex); } } g_painter.releaseCustomProgram(); } } else if(m_outfit.getCategory() == ThingsType::Item) { for(int l = 0; l < m_type->dimensions[ThingType::Layers]; l++) internalDraw(p + m_walkOffset, l); } else if(m_outfit.getCategory() == ThingsType::Effect) internalDraw(p + m_walkOffset, 0); }
void ofxglVideoRenderer::render() { glPushMatrix(); ofSetColor(r*255, g*255, b*255, a*255); glTranslatef(x, y, z); glRotatef(rx, 1.0, 0.0, 0.0); glRotatef(ry, 0.0, 1.0, 0.0); glRotatef(rz, 0.0, 0.0, 1.0); glScalef(scaleX, scaleY, 1.0f); if(upsideDown) { glScalef(1.0, -1.0f, 1.0f); } //based on rect rendering mode if(rectMode == RECTMODE_CENTER) { internalDraw(-mWidth / 2.0f, -mHeight / 2.0f ,mWidth, mHeight); }else if(rectMode == RECTMODE_LEFTSIDE) { /* +----------- + | + | + | +----------- */ m_Video.draw(0.0f, -mHeight / 2.0f ,mWidth, mHeight); }else if(rectMode == RECTMODE_LEFTBOTTOM) { internalDraw(0.0f, 0.0f ,mWidth, mHeight); }else if(rectMode == RECTMODE_LEFTTOP) { internalDraw(0.0f, -mHeight ,mWidth, mHeight); }else if(rectMode == RECTMODE_RIGHTSIDE) { //I need to test; /* +----------- | + | + | + +----------- */ internalDraw(-mWidth, -mHeight / 2.0f ,mWidth, mHeight); }else if(rectMode == RECTMODE_RIGTHBOTTOM) { internalDraw(-mWidth, 0.0f ,mWidth, mHeight); }else if(rectMode == RECTMODE_RIGTHTOP) { internalDraw(-mWidth, -mHeight ,mWidth, mHeight); }else if(rectMode == RECTMODE_UPPERSIDE) { internalDraw(-mWidth / 2.0f, mHeight ,mWidth, mHeight); }else if(rectMode == RECTMODE_BOTTOMSIDE) { internalDraw(-mWidth / 2.0f, 0.0F ,mWidth, mHeight); }else{ //if rectMode is not define // apply center rendering internalDraw(-mWidth / 2.0f, -mHeight / 2.0f ,mWidth, mHeight); } glPopMatrix(); }