PlayerRenderComponent::PlayerRenderComponent(GameObject* player, function_t func) { gameObjectRef = player; gameObjectRef->AddComponent(COMPONENT_RENDER, this); RenderComponent::RenderComponent(); SceneManager* sceneMan = SceneManager::GetSceneManager(); RenderManager* renderMan = RenderManager::getRenderManager(); std::string playerName = NetworkManager::sInstance->getLobbyMap().find(gameObjectRef->ID)->second; SDLRenderObject * name = sceneMan->InstantiateBlankObject(sceneMan->findLayer("layer2"), 0, 0, 0, 0); int r, g, b; if (gameObjectRef->posY < 0){ r = 200, g=0, b = 200; } else r = 255, g = 255, b=0; name->setResourceObject(renderMan->renderText(playerName.c_str(), r, g, b, 20, "BowlbyOneSC-Regular")); //name->setParent(base); name->setPos(0, -60); allObjs["name"] = name; if (allObjs["box"])allObjs["box"]->visible = true; //pick random egg resource. currently hardcoded to 74 SDLRenderObject* egg = sceneMan->InstantiateObject(sceneMan->findLayer("layer2"), 74, 0, 0); egg->visible = false; egg->setParent(allObjs["base"]); allObjs["egg"] = egg; //assign animations func(&objRef, allObjs, animations); }
void ChickenClassComponent::animation(SDLRenderObject** objRef, map_obj& allObjs, map_anim& animations) { SceneManager* sceneMan = SceneManager::GetSceneManager(); RenderManager* renderMan = RenderManager::getRenderManager(); SDLRenderObject * base = sceneMan->InstantiateObject(sceneMan->findLayer("layer2"), 0, 0, 0); base->toggleIfRenderImage(); SDLRenderObject * armL = sceneMan->InstantiateObject(sceneMan->findLayer("layer2"), 100103, 0, 0); SDLRenderObject * legL = sceneMan->InstantiateObject(sceneMan->findLayer("layer2"), 100105, 30, 300); SDLRenderObject * body = sceneMan->InstantiateObject(sceneMan->findLayer("layer2"), 100101, 0, -18); SDLRenderObject * legR = sceneMan->InstantiateObject(sceneMan->findLayer("layer2"), 100104, 50, 300); SDLRenderObject * armR = sceneMan->InstantiateObject(sceneMan->findLayer("layer2"), 100102, 0, 0); //PlayerPhysicsComponent pos = gameObjectRef->GetComponent(COMPONENT_PHYSICS); //objRef->setAnchor(0.5, 0.5); armR->setAnchor(174 / double(armR->renderRect.w), 154 / double(armR->renderRect.h)); armL->setAnchor(178 / double(armL->renderRect.w), 168 / double(armL->renderRect.h)); legR->setAnchor(128 / double(legR->renderRect.w), 39 / double(legR->renderRect.h)); legL->setAnchor(253 / double(legL->renderRect.w), 62 / double(legL->renderRect.h)); //armR->setCurrentFrame(1); body->setParent(base); armL->setParent(body); armR->setParent(body); legL->setParent(body); legR->setParent(body); //body->setScale(0.1); //body->calcScale(50,50); body->setScale(body->calcXScale(50)); //body->setScale(body->calcXScale(90)); *objRef = base; allObjs["base"] = base; allObjs["body"] = body; allObjs["legL"] = legL; allObjs["legR"] = legR; allObjs["armL"] = armL; allObjs["armR"] = armR; SDLRenderObject * box = sceneMan->InstantiateBlankObject(sceneMan->findLayer("layer2"), 0, 0, 0, 0); box->setIfRenderRect(true); //box->setParent(base); allObjs["box"] = box; //SDLRenderObject * name = sceneMan->InstantiateBlankObject(sceneMan->findLayer("layer2"), 0, 0, 0, 0); // changing the values in InstantiateBlankObject does not stop the text from being stretched // need fixing (to not stretch text to fill box) // text, R, G, B, fontsize, fontname //std::string playerName = GamerServices::sInstance->GetLocalPlayerName(); //name->setResourceObject(renderMan->renderText(playerName.c_str(), 200, 0, 200, 20, "BowlbyOneSC-Regular")); //name->setParent(base); //name->setPos(0, -60); //allObjs["name"] = name; /////// IDLE ANIMATION std::list<motion> motions; motions.push_back(makeMotion(keyframeJump(armR, 0), 0.0, 0.0)); motions.push_back(makeMotion(moveCircArc(armR, 0, 50, 50, 0, 360), 0, 1)); motions.push_back(makeMotion(moveCircArc(armL, 0, 50, 50, 180, 360), 0, 1)); motions.push_back(makeMotion(rotateTransform(legR, 0, 0), 0, 0)); motions.push_back(makeMotion(rotateTransform(legL, 0, 0), 0, 0)); Animation* idle = new Animation(400, motions); animations["idle"] = idle; //auto mot = idle.motions.begin(); //currentAnimation = idle; ////// WALKING ANIMATION std::list<motion> motions2; motions2.push_back(makeMotion(keyframeJump(armR, 0), 0.0, 0.0)); motions2.push_back(makeMotion(moveCircArc(armR, 0, 50, 50, 0, 360), 0, 1)); motions2.push_back(makeMotion(moveCircArc(armL, 0, 50, 50, 180, 360), 0, 1)); motions2.push_back(makeMotion(rotateTransform(legR, -60, 120), 0, 0.5, ease_QuadInOut)); motions2.push_back(makeMotion(rotateTransform(legR, 60, -120), 0.5, 0.5, ease_QuadInOut)); motions2.push_back(makeMotion(rotateTransform(legL, 60, -120), 0, 0.5, ease_QuadInOut)); motions2.push_back(makeMotion(rotateTransform(legL, -60, 120), 0.5, 0.5, ease_QuadInOut)); //motions2.push_back(makeMotion(rotateTransform(legR, -30, 60), 0.5, 0.5, ease_QuadIn)); animations["walk"] = new Animation(400, motions2); ////// THROW ANIMATION std::list<motion> motions3; motions3.push_back(makeMotion(keyframeJump(armR, 1), 0.0, 0.0)); motions3.push_back(makeMotion(rotateTransform(armR, -30, 0), 0.0, 1.0,ease_QuadOut)); animations["throw"] = new Animation(100, motions3); ////// CHARGE ANIMATION std::list<motion> motions4; motions4.push_back(makeMotion(rotateTransform(armR,-20,0), 0.0, 0.0)); animations["charge"] = new Animation(100, motions4); }
void UITypeComponent::createUIType(UIType ID){ SceneManager* sceneMan = SceneManager::GetSceneManager(); SDLRenderObject *play; switch (ID){ case PLAY_BUTTON: play = sceneMan->InstantiateObject(sceneMan->findLayer("layer1"), 19, uiObjectRef->posX, uiObjectRef->posY, true); objRef = play; allObjs.push_back(play); break; case CANCEL_BUTTON: play = sceneMan->InstantiateObject(sceneMan->findLayer("layer1"), 22, uiObjectRef->posX, uiObjectRef->posY, true); objRef = play; allObjs.push_back(play); break; case BACK_BUTTON: play = sceneMan->InstantiateObject(sceneMan->findLayer("layer1"), 23, uiObjectRef->posX, uiObjectRef->posY, true); objRef = play; allObjs.push_back(play); break; case JOIN_BUTTON: play = sceneMan->InstantiateObject(sceneMan->findLayer("layer1"), 24, uiObjectRef->posX, uiObjectRef->posY, true); objRef = play; allObjs.push_back(play); break; case OPTIONS_BUTTON: play = sceneMan->InstantiateObject(sceneMan->findLayer("layer1"), 29, uiObjectRef->posX, uiObjectRef->posY, true); objRef = play; allObjs.push_back(play); break; case READY_BUTTON: play = sceneMan->InstantiateObject(sceneMan->findLayer("layer1"), 26, uiObjectRef->posX, uiObjectRef->posY, true); objRef = play; allObjs.push_back(play); break; case PLAYER_SLOT: play = sceneMan->InstantiateObject(sceneMan->findLayer("layer1"), 28, uiObjectRef->posX, uiObjectRef->posY, true); objRef = play; allObjs.push_back(play); break; case CHICKEN: play = sceneMan->InstantiateObject(sceneMan->findLayer("layer1"), CHICKEN, uiObjectRef->posX, uiObjectRef->posY, true); uiObjectRef->setWidthAndHeight(play->getWidth(), play->getHeight()); objRef = play; allObjs.push_back(play); break; case PEACOCK: play = sceneMan->InstantiateObject(sceneMan->findLayer("layer1"), PEACOCK, uiObjectRef->posX, uiObjectRef->posY, true); uiObjectRef->setWidthAndHeight(play->getWidth(), play->getHeight()); objRef = play; allObjs.push_back(play); break; case FLAMINGO: play = sceneMan->InstantiateObject(sceneMan->findLayer("layer1"), FLAMINGO, uiObjectRef->posX, uiObjectRef->posY, true); uiObjectRef->setWidthAndHeight(play->getWidth(), play->getHeight()); objRef = play; allObjs.push_back(play); break; case QUAIL: play = sceneMan->InstantiateObject(sceneMan->findLayer("layer1"), QUAIL, uiObjectRef->posX, uiObjectRef->posY, true); uiObjectRef->setWidthAndHeight(play->getWidth(), play->getHeight()); objRef = play; allObjs.push_back(play); break; case TURKEY: play = sceneMan->InstantiateObject(sceneMan->findLayer("layer1"), TURKEY, uiObjectRef->posX, uiObjectRef->posY, true); uiObjectRef->setWidthAndHeight(play->getWidth(), play->getHeight()); objRef = play; allObjs.push_back(play); break; case EAGLE: play = sceneMan->InstantiateObject(sceneMan->findLayer("layer1"), EAGLE, uiObjectRef->posX, uiObjectRef->posY, true); uiObjectRef->setWidthAndHeight(play->getWidth(), play->getHeight()); objRef = play; allObjs.push_back(play); break; case INVITE_BUTTON: play = sceneMan->InstantiateObject(sceneMan->findLayer("layer1"), 29, uiObjectRef->posX, uiObjectRef->posY, true); objRef = play; allObjs.push_back(play); break; case TIMER:{ RenderManager* renderMan = RenderManager::getRenderManager(); play = sceneMan->InstantiateObject(sceneMan->findLayer("layer1"), -1, uiObjectRef->posX, uiObjectRef->posY, true); play->setResourceObject(renderMan->renderText("Timer", 247, 92, 15, 50, "BowlbyOneSC-Regular")); objRef = play; allObjs.push_back(play); break; } case LOBBY_TIMER:{ RenderManager* renderMan = RenderManager::getRenderManager(); play = sceneMan->InstantiateObject(sceneMan->findLayer("layer1"), -1, uiObjectRef->posX, uiObjectRef->posY, true); play->setResourceObject(renderMan->renderText("", 247, 92,255, 50, "BowlbyOneSC-Regular")); objRef = play; allObjs.push_back(play); break; } case BIRDSEED_BAR: //TODO: these hardcoded positions are to put it a bit away from the borders of the screen. //We'll need to store them as variables, since PlayerLogicComponent->update has hardcoded //values to match play = sceneMan->InstantiateObject(sceneMan->findLayer("layer1"), 1101, uiObjectRef->posX, uiObjectRef->posY, true); objRef = play; allObjs.push_back(play); break; case BIRDSEED_SHELL: play = sceneMan->InstantiateObject(sceneMan->findLayer("layer1"), 1100, uiObjectRef->posX, uiObjectRef->posY, true); objRef = play; allObjs.push_back(play); break; case CROSSHAIR: play = sceneMan->InstantiateObject(sceneMan->findLayer("layer1"), 1109, uiObjectRef->posX, uiObjectRef->posY, true); objRef = play; allObjs.push_back(play); break; case MENU_NAME:{ std::string playerName = GamerServices::sInstance->GetLocalPlayerName(); RenderManager* renderMan = RenderManager::getRenderManager(); SDLRenderObject * name = sceneMan->InstantiateBlankObject(sceneMan->findLayer("layer2"), 0, 0, 0, 0); int x, y; renderMan->getWindowSize(&x, &y); play = sceneMan->InstantiateObject(sceneMan->findLayer("layer1"), -1, (float)x / 2.0f, (float)y / 2.0f, true); play->setResourceObject(renderMan->renderText(playerName.c_str(), 255, 0, 255, 50, "BowlbyOneSC-Regular")); break; } // CHARGE BAR needs to follow player posX/posY at a slight offset // using 1102 and 1103 for object IDs // position is currently hardcoded, need to move to follow the player sprite location case CHARGE_BAR: play = sceneMan->InstantiateObject(sceneMan->findLayer("layer1"), 1103, uiObjectRef->posX, uiObjectRef->posY, true); objRef = play; allObjs.push_back(play); break; case CHARGE_SHELL: play = sceneMan->InstantiateObject(sceneMan->findLayer("layer1"), 1102, uiObjectRef->posX, uiObjectRef->posY, true); objRef = play; allObjs.push_back(play); break; case KILL_NOTIFICATION:{ play = sceneMan->InstantiateObject(sceneMan->findLayer("layer1"), -1, uiObjectRef->posX, uiObjectRef->posY, true); objRef = play; RenderManager* renderMan = RenderManager::getRenderManager(); objRef->setResourceObject(renderMan->renderText("", 255, 0, 255, 30, "BowlbyOneSC-Regular")); objRef->visible = false; allObjs.push_back(play); } } }