Matrix<float,2,1> Breach::getAdjustedShotPoint(const Wall& wall, const Matrix<float,2,1> shotPoint) { float x = shotPoint[0]; float y = shotPoint[1]; float aNorm = wall.getAxisA().norm(); float bNorm = wall.getAxisB().norm(); if (x - DEFAULT_BREACH_WIDTH /2/aNorm < 0) x = DEFAULT_BREACH_WIDTH /2/aNorm; if (x + DEFAULT_BREACH_WIDTH /2/aNorm > 1) x = 1 - DEFAULT_BREACH_WIDTH /2/aNorm; if (y - DEFAULT_BREACH_HEIGHT/2/bNorm < 0) y = DEFAULT_BREACH_HEIGHT/2/bNorm; if (y + DEFAULT_BREACH_HEIGHT/2/bNorm > 1) y = 1 - DEFAULT_BREACH_HEIGHT/2/bNorm; if (x < 0 || y < 0) return shotPoint; return Matrix<float,2,1>((float[]){x, y});
void Board::clearWall(bool hORv, int x, int y) { Wall * temp; for (int i = -1; i < 2; i++) { if (hORv) { temp = dynamic_cast<Wall*>(board_[x + i][y]); temp->demolish(); }else{ temp = dynamic_cast<Wall*>(board_[x][y + i]); temp->demolish(); } } }
void Block::addDoor(){ Wall* temp = wall[MapModelContainer::getMirror()]; temp->setFrame(new BreakableModel(DOORFRAME, MapModelContainer::getMirror(), MapModelContainer::getCondition(DOORFRAME), MapModelContainer::getIndex(DOORFRAME))); temp->setDoor(new DoorModel(MapModelContainer::getMirror(), MapModelContainer::getShift(), MapModelContainer::getInvert(), MapModelContainer::getAngle(), MapModelContainer::getIndex(DOOR))); LevelMap::updateMap(); }
void WallSet::init(Vec2 viewPoint) { int i = 0; //endPoint = 1136 * 1.3f; endPoint = 0; while (i < 5){ Wall* wall = Wall::create(); wall->regen(); wall->setPosition(endPoint, 0); this->addChild(wall); walls.push_back(wall); endPoint += SPACE; i++; } }
Wall* Wall::create(ValueMap& model) { Wall *pRet = new Wall(model); if (pRet && pRet->init()) { pRet->autorelease(); return pRet; } else { delete pRet; pRet = NULL; return NULL; } }
Wall* Wall::create(int id) { Wall *pRet = new Wall(id); if (pRet && pRet->init()) { pRet->autorelease(); return pRet; } else { delete pRet; pRet = NULL; return NULL; } }
void drawAt(int x, int y, Shape s){ if(s == ATTACKER){ attackers[attackersSize] = Attacker(x,y - 3); attackersSize ++; }else{ if(board[x][y].getMyStatus() == EMPTY){ int index = -1; if(s == DEFENDER){ index = defendersSize; Defender d (x-5,y-3); if(resources >= d.getCost()){ defenders[defendersSize] = d; defendersSize ++; board[x][y].setMyStatus(OCCUPIED); board[x][y].setOCCupiedBy(s); board[x][y].setShapeIndex(index); resources -= d.getCost(); } }else if(s == RESOURCE_GATHERER){ index = gathererSize; ResourceGatherer r (x-5,y-3, x, y); if(resources >= r.getCost()){ gatherers[gathererSize] = r; gathererSize ++; board[x][y].setMyStatus(OCCUPIED); board[x][y].setOCCupiedBy(s); board[x][y].setShapeIndex(index); resources -= r.getCost(); } }else if(s == WALL){ index = wallSize; Wall r (x-5,y-3); if(resources >= r.getCost()){ walls[wallSize] = r; wallSize ++; board[x][y].setMyStatus(OCCUPIED); board[x][y].setOCCupiedBy(s); board[x][y].setShapeIndex(index); resources -= r.getCost(); } } } } removeSelection(); }
void Display() { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity(); gluLookAt(view[0], view[1], view[2], 0.0, 0.0, 0.0, 0.0, 1.0, 0.0); glPushMatrix(); light_init(); glEnable(GL_TEXTURE_2D); tellurion.draw_tellution(); vase.draw_vase(); wall.wall(); glDisable(GL_TEXTURE_2D);//close the texture map or it will map to other object table.draw_table(); dragon.draw_dragon(); lamp(); //draw shadow tellurion.shadow(); table.shadow(); vase.shadow(); dragon.shadow(); glPopMatrix(); glutSwapBuffers(); }
Wall* Wall::create(const std::string & filename) { Wall* pSprite = new Wall(); if (pSprite->initWithFile(filename)) { pSprite->autorelease(); pSprite->initOptions(); return pSprite; } CC_SAFE_DELETE(pSprite); return NULL; }
Wall* Wall::create(const Size& size,const PhysicsMaterial& pm ) { Wall* wall = new (std::nothrow) Wall; if (wall && wall->init()) { wall->initBody(size,pm); wall->autorelease(); return wall; } else { CC_SAFE_DELETE(wall); return nullptr; } }
void OnDrawFrame() { float dt=NowMs()-savedTime; gameState.flappyBird->update(dt); bool needResetLevel; for(List<Wall>::Node *node = gameState.wallsList.begin; node;) { Wall *wall = node->obj; wall->update(dt, needResetLevel); List<Wall>::Node *next_node = node->next; if(wall->x + wall->w < 0.0f) { delete wall; gameState.wallsList.remove(node); } node = next_node; } if(needResetLevel) gameState.resetLevel(); gameState.idleTime = gameState.idleTime - dt; if(gameState.idleTime <= 0) { gameState.idleTime = 2000.f + ((rand()%1000)*0.001f) * 1000.f; Wall *wall = new Wall; wall->x = gameState.screenWidth / gameState.scale; wall->y = 0.0f; wall->w = 40.0f + ((rand()%1000)*0.001f) * 20.0f; wall->h = 100.0f + ((rand()%1000)*0.001f) * 500.0f; if(gameState.side) { wall->y = 1000.f - wall->h; } gameState.side = !gameState.side; gameState.wallsList.add(wall); } savedTime=NowMs(); glClear(GL_COLOR_BUFFER_BIT); gameState.flappyBird->draw(); for(List<Wall>::Node *node = gameState.wallsList.begin; node; node = node->next) { Wall *wall = node->obj; wall->draw(); } }
int Stage::addWall( int left, int bottom, int width, int height, bool addWallLines) { if (numWalls_ >= MAX_WALLS) { return 0; } else { Wall* wall = new Wall(left, bottom, width, height); walls_[numWalls_++] = wall; if (addWallLines) { Line2D** wallLines = wall->getLines(); for (int x = 0; x < 4; x++) { innerWallLines_[numInnerWallLines_++] = wallLines_[numWallLines_++] = wallLines[x]; } } return 1; } }
void SphereContainer::findWallCollisions(){ for(unsigned i = 0;i<spheres.size();i++){ Wall temp; if(collision.checkForWallCollision( spheres[i].getMassCenter(),spheres[i].getMassCenter(), spheres[i].getRadius(), temp)){ //handle wall collision spheres[i].collisionHandler(temp.getWallDirection()); //inc counter wallCollisionCounter.incCounter(); } } }
/**************************************************************************//** * @author Paul Blasi, Caitlin Taggart * * @par Description: * The display callback. Draws each of the objects and displays score for each * player. If the game is currently paused, it also draws a translucent box * over the play area and the text "Paused". * *****************************************************************************/ void Display(void) { int length; glClear(GL_COLOR_BUFFER_BIT); BALL.Draw(); LEFT_PLAYER.Draw(); RIGHT_PLAYER.Draw(); LEFT_WALL.Draw(); RIGHT_WALL.Draw(); TOP_WALL.Draw(); BOTTOM_WALL.Draw(); NET.Draw(); string right_score = to_string(RIGHT_PLAYER.Score); string left_score = to_string(LEFT_PLAYER.Score); glColor4fv(WHITE); length = glutBitmapLength(GLUT_BITMAP_TIMES_ROMAN_24, (const unsigned char*)left_score.c_str()); glRasterPos2i(50 - (200.0 / SCREEN_WIDTH * length / 2.0), 90); glutBitmapString(GLUT_BITMAP_TIMES_ROMAN_24, (const unsigned char*)left_score.c_str()); length = glutBitmapLength(GLUT_BITMAP_TIMES_ROMAN_24, (const unsigned char*)right_score.c_str()); glRasterPos2i(150 - (200.0 / SCREEN_WIDTH * length / 2.0), 90); glutBitmapString(GLUT_BITMAP_TIMES_ROMAN_24, (const unsigned char*)right_score.c_str()); if (PAUSED) { float alphaBlack[4] = { 0.0, 0.0, 0.0, .60 }; Paddle temp; temp = Paddle(Point(100, 50), 200, 100, alphaBlack); temp.Draw(); glColor4fv(WHITE); length = glutBitmapLength(GLUT_BITMAP_TIMES_ROMAN_24, (const unsigned char*)"PAUSED"); glRasterPos2i(100 - (200.0/SCREEN_WIDTH * length / 2.0), 50); glutBitmapString(GLUT_BITMAP_TIMES_ROMAN_24, (const unsigned char*)"PAUSED"); } //glFlush(); glutSwapBuffers(); }
Wall* Application::createWall(Ogre::String nme, GameObject::objectType tp, Ogre::String meshName, int x, int y, int z, Ogre::Vector3 scale, Ogre::Degree pitch, Ogre::Degree yaw, Ogre::Degree roll, Ogre::SceneManager* scnMgr, GameManager* ssm, Ogre::Real mss, Ogre::Real rest, Ogre::Real frict, bool kinematic, Simulator* mySim) { createRootEntity(nme, meshName, x, y, z); Ogre::SceneNode* sn = mSceneManager->getSceneNode(nme); Ogre::Entity* ent = SceneHelper::getEntity(mSceneManager, nme, 0); const btTransform pos; OgreMotionState* ms = new OgreMotionState(pos, sn); sn->setScale(scale.x, scale.y, scale.z); sn->pitch(pitch); sn->yaw(yaw); sn->roll(roll); Wall* obj = new Wall(nme, tp, mSceneManager, ssm, sn, ent, ms, mySim, mss, rest, frict, scale, kinematic); obj->addToSimulator(); return obj; }
int main() { UserList dataList; Wall userWall; userWall.printAll(); //dataList.readFile(); bool goBackToFirstMenu = true; int choice; while(goBackToFirstMenu == true) { cout << "Look at the menu below and\nenter the corresponding number." << endl; cout << "1)Log in as a user.\n2)Create a new user\n3)Print Users\n4)Delete User" << endl << endl; cin >> choice; menu(choice, goBackToFirstMenu, dataList); cout << "Would you like to go back to the main menu? (Y/N)" << endl; string goBackToMainMenu; cin >> goBackToMainMenu; if(goBackToMainMenu == "Y" || goBackToMainMenu == "y") { goBackToFirstMenu = true; //menu(choice, goBackToFirstMenu, dataList); } else if(goBackToMainMenu == "N" || goBackToMainMenu == "n") { cout << "Goodbye! Hope you have a good one!" << endl; goBackToFirstMenu = false; } else { cout << "Enter a valid choice" << endl; cin >> goBackToMainMenu; } dataList.writeFile(); } return 0; }
RoomObject* XmlWorldBuilder::parseRoomQuadWall(TiXmlElement* e) { Wall* w = new Wall( parseVector(e->FirstChildElement("x0")), parseVector(e->FirstChildElement("x1")), parseVector(e->FirstChildElement("x2")), parseVector(e->FirstChildElement("x3"))); TiXmlElement* t = e->FirstChildElement("tex-coords"); if (t != NULL) { w->setTexCoords( parseVector(t->FirstChildElement("t0")), parseVector(t->FirstChildElement("t1")), parseVector(t->FirstChildElement("t2")), parseVector(t->FirstChildElement("t3"))); } const char* material = e->Attribute("material"); if (material != NULL) { w->setMaterial(*materials_[material]); } return w; }
unsigned int NetClient::handleWallState(Uint8 *data, unsigned int size) { DEBUGSTR("net", "handleWallState()"); Uint16 eid; CRC32 type; float qx, qy, qz, qw, bx, by, bz; unpack(data, "hl ffff fff", &eid, &type, &qx, &qy, &qz, &qw, &bx, &by, &bz ); Entity* e = st->getEntity(eid); Wall* w = (Wall*) e; // If don't exist, create if (w == NULL) { WallType *wt = GEng()->mm->getWallType(type); if (! wt) { this->error("Invalid wall type " + type); return 34; } w = new Wall(wt, st, bx, bz, by, 0); st->addWall(w); w->eid = eid; } // Update the transform btTransform xform = btTransform( btQuaternion(qx, qy, qz, qw), btVector3(bx, by, bz) ); w->setTransform(xform); return 34; }
void Game::reset() { /* Set up the adding counters */ addWallLimit = WALL_HEIGHT / SCROLL_MOVE_DIST; addWallCounter = 0; addObstLimit = 5 * OBSTACLE_HEIGHT / SCROLL_MOVE_DIST; addObstCounter = 0; scoreLimit = 10; scoreCounter = 0; myScene.clear(); myObjects.clear(); myScore = 0; if (myPlayer == NULL) { delete myPlayer; } /** Set up the player and the initial scene **/ myPlayer = new Player(WALL_WIDTH + 1, EXTRA_SCENE_SPACE + VIEW_HEIGHT - 2*PLAYER_HEIGHT, true); myScene.addItem(myPlayer); for (int i = VIEW_HEIGHT + EXTRA_SCENE_SPACE; i >= 0; i -= WALL_HEIGHT) { Wall* x = new Wall(0, i); Wall* y = new Wall(400 - WALL_WIDTH, i); myObjects.append(x); myScene.addItem(x); myObjects.append(y); myScene.addItem(y); x->setVisible(true); y->setVisible(true); } myScene.addItem(myPlayer); myPlayerWantsToJump = false; /** Make a bunch of walls **/ int i = VIEW_HEIGHT + EXTRA_SCENE_SPACE - WALL_HEIGHT - 1; for (i = i + 1; i >= 0; i -= WALL_HEIGHT) { Wall* x = new Wall(0, i); Wall* y = new Wall(VIEW_WIDTH - WALL_WIDTH, i); myObjects.append(x); myScene.addItem(x); myObjects.append(y); myScene.addItem(y); x->setVisible(true); y->setVisible(true); } }
Wall* ObjectFactory::createWall(WallDTO* wallDTO, b2World* world) { Wall* wall = Wall::create(); wall->setDeadWall(wallDTO->deadWall); b2EdgeShape edge; edge.Set(b2Vec2(0,0),b2Vec2(wallDTO->edge_x/PTM_RATIO,wallDTO->edge_y/PTM_RATIO)); // edge.SetAsBox(1/PTM_RATIO, 4); b2FixtureDef fixDef; fixDef.shape = &edge; fixDef.friction = 0; PhysicData* data = new PhysicData(); data->gameObjectID = WALL; data->bodyId = WALL_BODY; data->data = wall; fixDef.userData = data; b2BodyDef bodyDef; bodyDef.type = b2_staticBody; bodyDef.angle = ccpToAngle(ccp(0,0)); b2Body *body = world->CreateBody(&bodyDef); body->CreateFixture(&fixDef); for (b2Fixture* f = body->GetFixtureList(); f; f = f->GetNext()) { Util::setFixtureGroup(f, GROUP_WALL); } wall->setSkin(body, NULL); wall->setPositionInPixel(ccp(wallDTO->x, wallDTO->y)); wall->setGroup(TERRAIN); return wall; }
bool Stage::isShipInWall(double x, double y) { for (int z = 0; z < numWalls_; z++) { Wall *wall = walls_[z]; double left = wall->getLeft(); double bottom = wall->getBottom(); if (x > left && x < left + wall->getWidth() && y > bottom && y < bottom + wall->getHeight()) { return true; } } Circle2D *shipCircle = new Circle2D(x, y, SHIP_RADIUS); for (int z = 0; z < numWallLines_; z++) { Line2D* line = wallLines_[z]; if (shipCircle->intersects(line)) { delete shipCircle; return true; } } delete shipCircle; return false; }
bool collisionCarWall(Car& car, Wall& wall, glm::mat4 carMatrix) { //can't collide if they are too far apart if (!collisionCircleCircle(car.getCenter(), carRadius, wall.getCenter(), wall.getLength()/2 + 1)) { //not very wide, and too lazy to do more percise math return false; } glm::mat4 wallMatrix = wall.getMatrix(); glm::vec4 carUR = carMatrix * glm::vec4(0.5,1.0,0.0,1.0); glm::vec4 carLR = carMatrix * glm::vec4(0.5,-1.0,0.0,1.0); glm::vec4 carLL = carMatrix * glm::vec4(-0.5,-1.0,0.0,1.0); glm::vec4 carUL = carMatrix * glm::vec4(-0.5,1.0,0.0,1.0); glm::vec4 wallUR = wallMatrix * glm::vec4(1.0,0.2,0.0,1.0); glm::vec4 wallLR = wallMatrix * glm::vec4(1.0,-0.2,0.0,1.0); glm::vec4 wallLL = wallMatrix * glm::vec4(-1.0,-0.2,0.0,1.0); glm::vec4 wallUL = wallMatrix * glm::vec4(-1.0,0.2,0.0,1.0); return collisionRectSAT(carUR, carLR, carLL, carUL, wallUR, wallLR, wallLL, wallUL); }
bool Wall::operator!=(const Wall & c) { /* * This function allows us to check if our first wall * is already equal to our RandWall. If they are already * equal then we won't perform the = operator. */ if (getY() == c.getY()) { return false; } return true; }
unsigned int NetClient::handleWallState(Uint8 *data, unsigned int size) { cout << " handleWallState()\n"; Uint16 eid; CRC32 type; float qx, qy, qz, qw, bx, by, bz; unpack(data, "hl ffff fff", &eid, &type, &qx, &qy, &qz, &qw, &bx, &by, &bz ); Entity* e = st->getEntity(eid); Wall* w = (Wall*) e; // If don't exist, create if (w == NULL) { WallType *wt = st->mm->getWallType(type); if (! wt) return 34; // TODO: Should we err instead? w = new Wall(wt, st, bx, bz, by, 0); st->addWall(w); w->eid = eid; } // Update the transform btTransform xform = btTransform( btQuaternion(qx, qy, qz, qw), btVector3(bx, by, bz) ); w->setTransform(xform); return 34; }
static void CreateWall( int flag, const AcDbObjectId& host, const AcGePoint3d& pt, double angle ) { Wall* pWall; switch( flag ) { case 1: pWall = new PermanentWall( pt, angle ); // 永久挡风墙 break; case 2: pWall = new TemporaryWall( pt, angle ); // 临时挡风墙 break; default: pWall = 0; } if( pWall == 0 ) return; // 关联到巷道上 pWall->setRelatedGE( host ); // 初始化并提交到数据库 if( !ArxUtilHelper::PostToModelSpace( pWall ) ) delete pWall; }
void Game::updateWalls(GameState* state) { //Add/update curwalls, copy curwalls into the state being pushed map<int, GameObject*>& objects = state->map().objects(); for(map<int, GameObject*>::iterator cursor = objects.begin(); cursor != objects.end(); cursor++) { //Is the gameobject a wall? Wall* wall = dynamic_cast<Wall*>(cursor->second); if(wall != 0) { //Did we know this wall existed? if(m_curWalls.count(wall->id()) == 0) { //No - make a copy of it m_curWalls[wall->id()] = static_cast<Wall*>(wall->clone()); } else { //Yes - update our copy of it *(m_curWalls[wall->id()]) = *wall; } } } //Now copy m_curWalls into the list of objects for the state for(map<int, Wall*>::iterator cursor = m_curWalls.begin(); cursor != m_curWalls.end(); cursor++) { //Does the state being pushed already have the wall in question? if(objects.count(cursor->first) == 0) { //No - Make a copy and put it in there cursor->second->setWithinView(false); objects[cursor->first] = cursor->second->clone(); } } }
bool Bomberman::collision(Wall wall) { if(y + width <= wall.getY()) return 0; if(x + length <= wall.getX()) return 0; if(y >= wall.getY() + wall.getWidth()) return 0; if(x >= wall.getX() + wall.getLength()) return 0; return 1; }
//======================================= void draw() { glActiveTexture(GL_TEXTURE0); glPushMatrix(); myTerrain.drawTerrain(); glPopMatrix(); glPushMatrix(); wall.draw(SLOWDOWN); glPopMatrix(); //draw tank glPushMatrix(); myTank.draw(g_ViewMod); glPopMatrix(); glActiveTexture(GL_TEXTURE1); }
bool Shuriken::simpleCollision(Wall wall, double offsetx) { if( m_pos.x() + m_size.x() < wall.pos().x() || m_pos.y() + m_size.y() < wall.pos().y() || m_pos.x() - offsetx > wall.pos().x() + wall.size().x() || m_pos.y() > wall.pos().y() + wall.size().y() ) { return false; } else { return true; } }
void myInit() { glActiveTexture(GL_TEXTURE0); //make the background look like the sky float blue[4] = {0.5,0.5,1.0,0.0}; glClearColor(0.5, 0.5, 1.0, 0.0); glShadeModel(GL_SMOOTH); glEnable(GL_FOG); glFogfv(GL_FOG_COLOR,blue); glFogf(GL_FOG_MODE, GL_EXP2); glFogf(GL_FOG_START, 200); glFogf(GL_FOG_END, 1000); glFogf(GL_FOG_DENSITY, gFogDensity); //initial terrain myTerrain.initializeTerrain("../Data/Texture/Terrain/sand.tga", "../Data/Texture/Terrain/cactus.tga"); //initial ground collision square groundCollSquare.setParameters(TVector(0.0, 1.0, 0.0), gCenterPoint); //initial tank tankHeightPos = myTerrain.GetHeight(gCenterPoint.X()+100.0, gCenterPoint.Z()); myTank.setParameters("T-90.3DS", "../T-90/",TVector(gCenterPoint.X()-600.0, tankHeightPos + 9.0, gCenterPoint.Z()-20), 0.0, &myTerrain, &collisionBoxArray, &wall); myTank.initTank(); unsigned int brickTexture; createTexture("../Data/Texture/Brick/brick.bmp", brickTexture); wall.Init(myTank.getPosition().X() + 50, myTank.getPosition().Y()-8, myTank.getPosition().Z() + 20, NUM_BRICKS, brickTexture, &myTerrain); }