void daynightSetMin(float min) { if (min < getGameState()->gs->getTimeOfDayMin()) { min = getGameState()->gs->getTimeOfDayMin(); } getGameState()->gs->tod_min = min; }
void daynightSetMax(float max) { if (max > getGameState()->gs->getTimeOfDayMin()) { max = getGameState()->gs->getTimeOfDayMin(); } getGameState()->gs->tod_max = max; }
void CameraViewPreInit() { // For some reason loading images in early stage of init solves lagginess/buggyness playerHit = new PlayerHit(getGameState()->getPlayer()); tutorialView = new FightTutorialView(); cameraDefend = new CameraDefend(); manaBar = new ManaBar(); playerAttackView = new PlayerAttackView(getGameState()->getPlayer()); }
/** * Add an object at a given coordinate **/ Pickup* addPickupCoord(string type, btVector3 &coord) { PickupType *pt = GEng()->mm->getPickupType(type); if (pt == NULL) { return NULL; } Pickup *p = new Pickup(pt, getGameState(), coord.x(), coord.y(), coord.z()); getGameState()->addPickup(p); return p; }
/** * Add an object at a given map X/Z coordinate * The Y coordinate is calculated **/ Pickup* addPickupXZ(string type, float x, float z) { PickupType *pt = GEng()->mm->getPickupType(type); if (pt == NULL) { return NULL; } Pickup *p = new Pickup(pt, getGameState(), x, z); getGameState()->addPickup(p); return p; }
/** * Add a vehicle at a map X/Z coordinate * Y will be calculated so it's on the ground **/ Vehicle* addVehicleXZ(string type, float x, float z) { Vehicle *v; VehicleType *vt = GEng()->mm->getVehicleType(type); if (vt == NULL) { return NULL; } v = new Vehicle(vt, getGameState(), x, z); getGameState()->addVehicle(v); return v; }
/** * Add a vehicle at a given coordinate **/ Vehicle* addVehicleCoord(string type, btVector3 &coord) { Vehicle *v; VehicleType *vt = GEng()->mm->getVehicleType(type); if (vt == NULL) { return NULL; } v = new Vehicle(vt, getGameState(), coord.x(), coord.y(), coord.z()); getGameState()->addVehicle(v); return v; }
/** * Add an object at a given map X/Z coordinate * The Y coordinate is calculated **/ Object* addObjectXZ(string type, float x, float z) { Object *o; ObjectType *ot = GEng()->mm->getObjectType(type); if (ot == NULL) { return NULL; } o = new Object(ot, getGameState(), x, z); getGameState()->addObject(o); return o; }
/** * Add an object at a given coordinate **/ Object* addObjectCoord(string type, btVector3 &coord) { Object *o; ObjectType *ot = GEng()->mm->getObjectType(type); if (ot == NULL) { return NULL; } o = new Object(ot, getGameState(), coord.x(), coord.y(), coord.z()); getGameState()->addObject(o); return o; }
void renderMapHealth() { IwGxLightingOff(); Iw2DSetAlphaMode(IW_2D_ALPHA_NONE); Iw2DSetTransformMatrix(CIwFMat2D::g_Identity); int16 w = (double)IwGxGetScreenWidth() * 0.09f; if (w > (int16)healthTexture->GetWidth()) w = (int16)healthTexture->GetWidth(); float whScale = (float)((double)healthTexture->GetWidth() / healthTexture->GetHeight()); int16 h = w * 1/whScale; int leftPadding = IwGxGetScreenWidth() * 0.10f; int topPadding = IwGxGetScreenHeight() * 0.02f; int leftMargin = IwGxGetScreenWidth() * 0.03f; int topMargin = IwGxGetScreenHeight() * 0.05f; CIwFVec2 size = CIwFVec2(w, h); int vitality = getGameState()->getPlayer()->getVitality(); for (int i = 0; i < PLAYER_MAX_VITALITY; i++) { CIwFVec2 topLeft = CIwFVec2(leftPadding + (leftMargin+w)*i, topPadding); if (i < vitality) { Iw2DDrawImage(healthTexture, topLeft, size); } else { Iw2DDrawImage(healthLostTexture, topLeft, size); } } }
void updateGhost() { if (ghost_Player->IsCurrentAnimComplete() && !getGameState()->getGhost()->isDead()) { ghost_Player->PlayAnim(ghost_Anims[GHOST_ANIM_IDLE], 1, CIwAnimBlendSource::LOOPING_F, BLEND_DURATION); } // Update animation player ghost_Player->Update(1.0f / 30.0f); }
/** * Spawn in a player in a random location of a random spawn zone **/ Player* addPlayer(string type, unsigned int fac, unsigned int slot) { Zone *zn = getGameState()->map->getSpawnZone((Faction)fac); if (zn == NULL) { return NULL; } return addPlayerZone(type, fac, slot, zn); }
/** * Spawn in a NPC in a random location of a random spawn zone **/ NPC* addNpc(string type, string aitype, unsigned int fac) { Zone *zn = getGameState()->map->getSpawnZone((Faction)fac); if (zn == NULL) { return NULL; } return addNpcZone(type, aitype, fac, zn); }
/** * Spawn in a NPC at a given map X/Z coordinate **/ NPC* addNpcXZ(string type, string aitype, unsigned int fac, float x, float z) { NPC *p; UnitType *ut = GEng()->mm->getUnitType(type); if (ut == NULL) { return NULL; } AIType *ai = GEng()->mm->getAIType(aitype); if (ai == NULL) { return NULL; } p = new NPC(ut, getGameState(), (Faction)fac, ai, x, z); getGameState()->addUnit(p); return p; }
/** * Spawn in a NPC at the given coordinate **/ NPC* addNpcCoord(string type, string aitype, unsigned int fac, btVector3 &coord) { NPC *p; UnitType *ut = GEng()->mm->getUnitType(type); if (ut == NULL) { return NULL; } AIType *ai = GEng()->mm->getAIType(aitype); if (ai == NULL) { return NULL; } p = new NPC(ut, getGameState(), (Faction)fac, ai, coord.x(), coord.y(), coord.z()); getGameState()->addUnit(p); return p; }
/** * Spawn in a NPC in a random location of the specified zone **/ NPC* addNpcZone(string type, string aitype, unsigned int fac, Zone *zn) { NPC *p; UnitType *ut = GEng()->mm->getUnitType(type); if (ut == NULL) { return NULL; } AIType *ai = GEng()->mm->getAIType(aitype); if (ai == NULL) { return NULL; } p = new NPC(ut, getGameState(), (Faction)fac, ai, zn->getRandomX(), zn->getRandomZ()); getGameState()->addUnit(p); return p; }
/** * Spawn in a player at the given coordinate **/ Player* addPlayerCoord(string type, unsigned int fac, unsigned int slot, btVector3 &coord) { Player *p; UnitType *ut = GEng()->mm->getUnitType(type); if (ut == NULL) { return NULL; } p = new Player(ut, getGameState(), (Faction)fac, slot, coord.x(), coord.y(), coord.z()); // Is it a local player? PlayerState *ps = getGameState()->getLocalPlayer(slot); if (ps != NULL) { ps->p = p; } getGameState()->addUnit(p); return p; }
/** * Spawn in a player at a given map X/Z coordinate **/ Player* addPlayerXZ(string type, unsigned int fac, unsigned int slot, float x, float z) { Player *p; UnitType *ut = GEng()->mm->getUnitType(type); if (ut == NULL) { return NULL; } p = new Player(ut, getGameState(), (Faction)fac, slot, x, z); // Is it a local player? PlayerState *ps = getGameState()->getLocalPlayer(slot); if (ps != NULL) { ps->p = p; } getGameState()->addUnit(p); return p; }
/** * Spawn in a player in a random location of the specified zone **/ Player* addPlayerZone(string type, unsigned int fac, unsigned int slot, Zone *zn) { Player *p; UnitType *ut = GEng()->mm->getUnitType(type); if (ut == NULL) { return NULL; } p = new Player(ut, getGameState(), (Faction)fac, slot, zn->getRandomX(), zn->getRandomZ()); // Is it a local player? PlayerState *ps = getGameState()->getLocalPlayer(slot); if (ps != NULL) { ps->p = p; } getGameState()->addUnit(p); return p; }
void TUIGame::play() { handleCommand("new"); while (true) { // Print last move if (currentMove > 0) { Position prevPos(getPos()); prevPos.unMakeMove(moveList[currentMove - 1], uiInfoList[currentMove - 1]); std::string moveStr= TextIO::moveToString(prevPos, moveList[currentMove - 1], false); if (haveDrawOffer()) moveStr += " (offer draw)"; std::cout << "Last move: " << prevPos.getFullMoveCounter() << (prevPos.isWhiteMove() ? "." : "...") << ' ' << moveStr << std::endl; } /* { std::stringstream ss; ss << "Hash: " << std::hex << std::setw(16) << std::setfill('0') << pos.zobristHash(); std::cout << ss.str() << std::endl; } */ { auto et = Evaluate::getEvalHashTables(); Evaluate eval(*et); int evScore = eval.evalPos(getPos()) * (getPos().isWhiteMove() ? 1 : -1); std::stringstream ss; ss.precision(2); ss << std::fixed << "Eval: " << (evScore / 100.0); std::cout << ss.str() << std::endl; } // Check game state std::cout << TextIO::asciiBoard(getPos()); std::string stateStr = getGameStateString(); if (stateStr.length() > 0) std::cout << stateStr << std::endl; if (getGameState() != Game::ALIVE) activateHumanPlayer(); // Get command from current player and act on it Player& pl = getPos().isWhiteMove() ? *whitePlayer : *blackPlayer; std::vector<Position> posList; getHistory(posList); std::string moveStr = pl.getCommand(getPos(), haveDrawOffer(), posList); if (moveStr == "quit") return; bool ok = processString(moveStr); if (!ok) std::cout << "Invalid move: " << moveStr << std::endl; } }
bool MapViewUpdate() { // Clear the screen IwGxClear(IW_GX_COLOUR_BUFFER_F | IW_GX_DEPTH_BUFFER_F); renderMap(); renderMapPlayer(); renderMapXpBar(); renderMapHealth(); Player* player = getGameState()->getPlayer(); IntroState introState = getGameState()->getIntroState(); if (lastLoses < player->getLoseCount() || lastWins < player->getWinCount()) { lastLoses = player->getLoseCount(); lastWins = player->getWinCount(); mapGhost2->setCentre(CIwFVec2(IwGxGetScreenWidth()*0.80f, IwGxGetScreenHeight()*0.70f)); mapGhost2->setNotice(false); if (introState == INTRO_DEFEND) { mapGhost2->moveGhost(CIwFVec2(IwGxGetScreenWidth()/2, IwGxGetScreenHeight()/2), arrivalCallback); } } if (introState == INTRO_ATTACK) { mapGhost->Update(); mapGhost->Render(); } mapGhost2->Update(); mapGhost2->Render(); IwGxFlush(); IwGxSwapBuffers(); return true; }
void cGame::InitializeGame() { //Initialize Questions InitQuestions(); //Shuffle Questions ///Shuffle(); //Set Game State To Playing if(!getGameState()) { setGameState(true); } }
void setupPlayer() { Player *player = getGameState()->getPlayer(); if (!player->isReady()) { return; } // Set viewing position with the Y axis as upright. viewMatrix.SetIdentity(); viewMatrix.LookAt(CIwFVec3(0,-11,0), CIwFVec3(0,0,100), CIwFVec3(0,-1,0)); // Rotate according to compass heading viewMatrix.PostRotateY(rad(player->getHeading())); IwGxSetViewMatrix(&viewMatrix); }
//------------------------------------------------------------------------------------------------------- void Road::initOther(const Ogre::SceneNode *node) { mName = node->getName(); mTriggerNode = new btGhostObject(); btCollisionShape *shape = new btBoxShape(TRIGGER_SIZE); mTriggerNode->setCollisionShape(shape); btTransform transform; updateTriggerPosition(transform); mTriggerNode->setWorldTransform(transform); mTriggerNode->setCollisionFlags(mTriggerNode->getCollisionFlags() | btCollisionObject::CF_NO_CONTACT_RESPONSE); mTriggerNode->setUserPointer(this, ROAD); getGameState()->mDynamicsWorld->addCollisionObject(mTriggerNode); }
bool CameraViewUpdate() { if (viewFightInitRequired()) initFightView(); bool ghostAvailable = getGameState()->getGhost() != NULL; // Clear the screen IwGxClear(IW_GX_COLOUR_BUFFER_F | IW_GX_DEPTH_BUFFER_F); if (ghostAvailable && (!gameIsHalt() || getGameState()->getGhost()->isDead())) { updateGhost(); } renderCamera(); setupPlayer(); if (ghostAvailable) renderGhost(); playerAttackView->Render(); playerHit->Render(); manaBar->Render(); cameraDefend->Update(); cameraDefend->Render(); tutorialView->Render(); IwGxFlush(); IwGxSwapBuffers(); IwGxTickUpdate(); return true; }
void CameraDefend::Update() { dotAngle += 5; if (dotAngle > 359) dotAngle = 0; Ghost* ghost = getGameState()->getGhost(); if (ghost != NULL && ghost->isAttackDefendable() && !(ghost->getAttack() == NULL || ghost->getAttack()->isOver())) { if (!active) { reinit(); } active = true; getFightTutorial()->triggerTutorial(TUTORIAL_DEFEND); } else { active = false; } }
/** * drawPoints * Zeichnen der bis zu dem Zeitpunkt erreichten Punktzahl. */ void GameWorld::drawPoints() { CMatrix * modelview = getModelView(); modelview->Push(); modelview->Translate(1.8,4.2,0.0); drawNumber(getGameState()->getPoints()); modelview->Pop(); /*glPushMatrix(); glTranslatef(0.8,2.2,0.0); drawNumber(getGameState()->getPoints()); glPopMatrix();*/ }
void MapViewInit() { Player* player = getGameState()->getPlayer(); lastLoses = player->getLoseCount(); lastWins = player->getWinCount(); playerTexture = Iw2DCreateImage("textures/map_player.png"); healthTexture = Iw2DCreateImage("textures/map_health.png"); healthLostTexture = Iw2DCreateImage("textures/map_health_lost.png"); xpBarTexture = Iw2DCreateImage("textures/map_xp_bar.png"); mapTexture = new CIwTexture; mapTexture->LoadFromFile ("textures/map_template.png"); mapTexture->Upload(); mapInit(mapTexture->GetWidth(), mapTexture->GetHeight()); ghostInit(); }
/** * drawEndPoints * Zeichnen der erreichten Endpunktzahl. */ void GameWorld::drawEndPoints() { CMatrix * modelview = getModelView(); modelview->Push(); modelview->Translate(-0.1,2.0,0.0); modelview->Scale(1.5,1.5,1.5); drawNumber(getGameState()->getPoints()); modelview->Pop(); /* glPushMatrix(); glTranslatef(-0.1,1.3,0.0); glScalef(1.5,1.5,1.5); drawNumber(getGameState()->getPoints()); glPopMatrix(); */ }
void CameraDefend::Motion(int32 x, int32 y, uint32 id) { if (!isActive()) return; Ghost* ghost = getGameState()->getGhost(); CIwFVec2 drawEnd = CIwFVec2(x, y); bool dotsCollideWithDrawing = (dotCollides(&dotVertsTopLeftLeft, &dotVertsSizeLeft, touch[id]->drawStart) && dotCollides(&dotVertsTopLeftRight, &dotVertsSizeRight, drawEnd)) || (dotCollides(&dotVertsTopLeftRight, &dotVertsSizeRight, touch[id]->drawStart) && dotCollides(&dotVertsTopLeftLeft, &dotVertsSizeLeft, drawEnd)); if (dotsCollideWithDrawing) { active = false; if (ghost->getAttack() != NULL) defended = true; ghost->getAttack()->setDefended(); /*IwTrace(GHOST_HUNTER, ("Player defend drawing %s; coords %.0f.%.0f to %.0f.%.0f - dot left coord %.0f.%.0f right coord %.0f.%.0f", dotsCollideWithDrawing ? "accpeted" : "rejected", drawStart.x, drawStart.y, drawEnd.x, drawEnd.y, defendVertsLeft[0].x, defendVertsLeft[0].y, defendVertsRight[0].x, defendVertsRight[0].y));*/ } }