int Map::setRandomMap() { unsigned int min = 5; for (int h = 0; h < getHeight(); ++h) { for (int w = 0; w < getWidth(); ++w) { if (h == 0 || h == getHeight() - 1 || w == 0 || w == getWidth() - 1) setBox(std::make_pair(h, w), SOLID); else { setBox(std::make_pair(h, w), EMPTY); setTmpBox(std::make_pair(h, w)); } } } if (getTmpMap().size() < ((getNbPlayers() * min) + (getNbBots() * min))) return (1); setPlayersMap(); setBotsMap(); setBlockMap(5, Map::SOLID); setBlockMap(80, Map::BREAK); return (0); }
void Aexample::action(double time, double dtime, double beat, double dbeat) { int w=getVideoWidth(); int h=getVideoHeight(); float l=((AexampleFront *)front)->level->get(); dword cl=((AexampleFront *)front)->color0->get(); dword cc=((AexampleFront *)front)->color1->get(); dword cr=((AexampleFront *)front)->color2->get(); Asample *snd=((AexampleBack *)back)->in; Avideo *vin=((AexampleBack *)back)->vin; Avideo *out=((AexampleBack *)back)->out; sword smp[64*2]; sword bas[64*2]; sword med[64*2]; sword tre[64*2]; int nget=0; l=(l<0.5f)?(l*2.f):((l-0.5f)*10.f+1.f); if(snd->isConnected()) { snd->enter(__FILE__,__LINE__); snd->skip(maxi(snd->avaible()-64, 0)); nget=snd->getBuffer(smp, bas, med, tre, 64); snd->leave(); } out->enter(__FILE__,__LINE__); vin->enter(__FILE__,__LINE__); { Abitmap *b=out->getBitmap(); Abitmap *bin=vin->getBitmap(); if(b) { int nx=b->w>>2; int ny=b->h>>1; int v=0; if(bin) { bin->flags|=bitmapGLOBALALPHA; bin->alpha=0.05f; b->set(0, 0, bin, bitmapDEFAULT, bitmapDEFAULT); } else b->boxfa(0, 0, b->w, b->h, 0xff000000, 0.05f); setBox(b, v+=nx, ny, bas, nget, cl, l); setBox(b, v+=nx, ny, med, nget, cc, l); setBox(b, v+=nx, ny, tre, nget, cr, l); } } vin->leave(); out->leave(); }
void ABST::setSegmentRunTable(ASRT & newSegment, uint32_t no) { uint32_t tempLoc = 29 + getStringLen(29) + 1 + 1; for (unsigned int i = 0; i < getServerEntryCount(); i++) { tempLoc += getStringLen(tempLoc) + 1; } tempLoc++; for (unsigned int i = 0; i < getQualityEntryCount(); i++) { tempLoc += getStringLen(tempLoc) + 1; } tempLoc += getStringLen(tempLoc) + 1; //DrmData tempLoc += getStringLen(tempLoc) + 1; //MetaData int countLoc = tempLoc; tempLoc++; //skip segmentRuntableCount //attempt to reach the wanted position unsigned int i; for (i = 0; i < getInt8(countLoc) && i < no; ++i) { tempLoc += getBoxLen(tempLoc); } //we are now either at the end, or at the right position //let's reserve any unreserved space... if (no + 1 > getInt8(countLoc)) { int amount = no + 1 - getInt8(countLoc); if (!reserve(payloadOffset + tempLoc, 0, amount * 8)) { return; }; //set empty erro boxes as contents for (int j = 0; j < amount; ++j) { memcpy(data + payloadOffset + tempLoc + j * 8, "\000\000\000\010erro", 8); } setInt8(no + 1, countLoc); //set new count tempLoc += (no - i) * 8; } //now, tempLoc is at position for string number no, and we have at least an erro box reserved. setBox(newSegment, tempLoc); }
Trap::Trap(int x, int y) { LogManager &log_manager = LogManager::getInstance(); #ifdef REGISTER // Need to update fire rate control each step. registerInterest(DF_STEP_EVENT); #endif // Set object type. setType("Trap"); auto& resMgr = ResourceManager::getInstance(); setSprite(resMgr.getSprite("trap")); setSpriteSlowdown(4); setAltitude(1); // Set starting location. WorldManager &world_manager = WorldManager::getInstance(); Position pos(7, world_manager.getBoundary().getVertical() / 2); setPosition(Position(x, y)); setBox(Box(Position(0, 0), getSprite()->getWidth(), getSprite()->getHeight())); //setYVelocity(0.25); // Set firing variables. }
void GameObject::Init( LPDIRECT3DDEVICE9& d3dDevice ) { D3DXMatrixIdentity( &m_Matrix ); InitMesh( d3dDevice ); setBox(); }
void LinearLayout::update() { if (!m_allowedBox.isValid()) return; setBox(m_allowedBox); loadResources(); }
void IOHandler::set(int x, int y, Board::State state) { switch (state) { case Board::Cross: setCross(x, y); break; case Board::Box: setBox(x, y); break; default: assert(0); } }
void CC3TouchBox::setParent( CC3Node* aNode ) { super::setParent( aNode ); deriveNameFrom( aNode ); if ( !m_pMesh ) setBox( getParentBoundingBox() ); }
void CanvasLayout::update() { if (!m_parentBox) return; setBox(*m_parentBox); loadResources(); }
void Map::setPlayersMap() { std::pair<int, int> p; int cornerX; int cornerY; status who; who = P1; srand(time(NULL)); cornerX = 1 + (-2 * (rand() % 2)); cornerY = 1 + (-2 * (rand() % 2)); for (int i = 0; i < getNbPlayers(); ++i) { if (i == 1) { who = P2; cornerX = -1 * cornerX; cornerY = -1 * cornerY; } p.second = (cornerX * (rand() % (getWidth()/10)+2)) + (((cornerX * -1)+1) * (getWidth()/2)); p.first = (cornerY * (rand() % (getHeight()/10)+2)) + (((cornerY * -1)+1) * (getHeight()/2)); setBox(std::make_pair(p.first, p.second), who); popTmpMap(p); createL(p); } }
// Fills the complement of the radius of the trail with minus infties. // The return value true means success. Failure means that during the fill, // we intersected the outside of the quasidiagonal area. // In this case, the operation is not finished. bool borderDetailedAlignMatrix( AlignMatrix& alignMatrix, const Trail& trail, int radius ) { int huBookSize = alignMatrix.size(); int enBookSize = alignMatrix.otherSize(); int huPos, enPos; for ( huPos=0; huPos<huBookSize; ++huPos ) { int rowStart = alignMatrix.rowStart(huPos); int rowEnd = alignMatrix.rowEnd(huPos); for ( enPos=rowStart; enPos<rowEnd; ++enPos ) { alignMatrix.cell(huPos,enPos) = outsideOfRadiusValue; } } // We seriously use the fact that many-to-zero segments are subdivided into one-to-zero segments. // Inside setBox, an exception is thrown if we try to write outside the quasidiagonal. // If we catch such an exception, it means that the quasidiagonal is not thick enough. // In this case, we abandon the whole align, just to be sure. try { for ( int i=0; i<trail.size(); ++i ) { setBox( alignMatrix, trail[i].first, trail[i].second, radius, insideOfRadiusValue ); } } catch ( const char* errorType ) { massert( std::string(errorType) == "out of quasidiagonal" ) return false; } bool verify = true; if (verify) { int numberOfEvaluatedItems(0); for ( huPos=0; huPos<huBookSize; ++huPos ) { int rowStart = alignMatrix.rowStart(huPos); int rowEnd = alignMatrix.rowEnd(huPos); for ( enPos=rowStart; enPos<rowEnd; ++enPos ) { if (alignMatrix[huPos][enPos]==insideOfRadiusValue) { ++numberOfEvaluatedItems; } } } std::cerr << numberOfEvaluatedItems << " items inside the border." << std::endl; } return true; }
void Map::setBlockMap(int percent, status block) { std::pair<int, int> p; int nb; nb = (percent * getTmpMap().size()) / 100; for(int i = 0; i < nb; ++i) { p = getTmpMap()[rand() % getTmpMap().size()]; setBox(std::make_pair(p.first, p.second), block); popTmpMap(p); } }
void Map::setBotsMap() { std::pair<int, int> p; srand(time(NULL)); for (int i = 0; i < getNbBots(); ++i) { while (checkIfCharacter(p = getTmpMap()[rand() % getTmpMap().size()], P1) == 0 || checkIfCharacter(p, P2) == 0 || checkIfCharacter(p, BOT) == 0) ; setBox(std::make_pair(p.first, p.second), BOT); popTmpMap(p); createL(p); } }
void containerFullBox::setContent(Box & newContent, uint32_t no) { int tempLoc = 4; unsigned int contentCount = getContentCount(); for (unsigned int i = 0; i < no; i++) { if (i < contentCount) { tempLoc += getBoxLen(tempLoc); } else { if (!reserve(tempLoc, 0, (no - contentCount) * 8)) { return; }; memset(data + tempLoc, 0, (no - contentCount) * 8); tempLoc += (no - contentCount) * 8; break; } } setBox(newContent, tempLoc); }
Bullet::Bullet(Position hero_pos, int velocityX, int velocityY, int typee) { // Set object properties. setType("Bullet"); setXVelocity(velocityX);// move 1 space right every frame setYVelocity(velocityY); type = typee; auto& resMgr = ResourceManager::getInstance(); if (type == 1) { setSprite(resMgr.getSprite("bullet1")); } else if (type == 2) { setSprite(resMgr.getSprite("bullet-left")); } else if (type == 3) { setSprite(resMgr.getSprite("bullet-right")); } setSpriteSlowdown(4); // Set object type. setBox(Box(Position(0, 0), getSprite()->getWidth(), getSprite()->getHeight())); Position pos1; // Set starting location, based on hero's position passed in. if (velocityY == 0) { Position pos(hero_pos.getX() + 3 * velocityX, hero_pos.getY()); pos1 = pos; } if (velocityX == 0 ) { Position pos(hero_pos.getX(), hero_pos.getY() + 3 * velocityY); pos1 = pos; } setPosition(pos1); }
bool MyGLWidget::qt_invoke( int _id, QUObject* _o ) { switch ( _id - staticMetaObject()->slotOffset() ) { case 0: setBox(); break; case 1: setWire(); break; case 2: setHidden(); break; case 3: setFlat(); break; case 4: setFlatWire(); break; case 5: setSmooth(); break; case 6: setSmallTetra(); break; case 7: TrackMouseModality(); break; case 8: SectionMouseModality(); break; case 9: SwitchTextSimplex(); break; case 10: SwitchTextPhysics(); break; case 11: SwitchTextQuality(); break; default: return QGLWidget::qt_invoke( _id, _o ); } return TRUE; }
Platform::Platform() { setType("Platform"); isItThick = false; size = 50; setSolidness(HARD); setXVelocity(0.0); setYVelocity(0.0); setAltitude(3); // Make them in the background. WorldManager &world_manager = WorldManager::getInstance(); //Position pos(random() % world_manager.getBoundary().getHorizontal(), // random() % world_manager.getBoundary().getVertical()); Position pos(0, 15); setPosition(pos); height = 5; setBox(Box(Position(), size, height)); thecolor = rand() % 7; }
Saucer::Saucer() { LogManager &log_manager = LogManager::getInstance(); auto& resMgr = ResourceManager::getInstance(); setSprite(resMgr.getSprite("saucer")); // Set object type. setType("Saucer"); setBox(Box(Position(0, 0), getSprite()->getWidth(), getSprite()->getHeight())); // Set speed in vertical direction. setXVelocity(-0.25); // 1 space every 4 frames setSpriteSlowdown(4); moveToStart(); #ifdef REGISTER // Register interest in "nuke" event. registerInterest(NUKE_EVENT); #endif }
Platform::Platform(bool thickness, int sizee, int heightt, int x, int y, float x_speed, float y_speed) { setType("Platform"); isItThick = thickness; size = sizee; setSolidness(HARD); setXVelocity(x_speed); move_countdown = 10; setYVelocity(y_speed); setAltitude(3); // Make them in the background. WorldManager &world_manager = WorldManager::getInstance(); //Position pos(random() % world_manager.getBoundary().getHorizontal(), // random() % world_manager.getBoundary().getVertical()); Position pos(x, y); setPosition(pos); height = heightt; setBox(Box(Position(), size, height)); thecolor = rand() % 7; }
Bullet::Bullet(Position hero_pos, int velocityX) { // Set object properties. setType("Bullet"); setXVelocity(velocityX);// move 1 space right every frame //setYVelocity(velocityY); type = 0; auto& resMgr = ResourceManager::getInstance(); setSprite(resMgr.getSprite("bullet")); setSpriteSlowdown(4); // Set object type. setBox(Box(Position(0, 0), getSprite()->getWidth(), getSprite()->getHeight())); // Set starting location, based on hero's position passed in. //if (velocityY == 0 && velocityX != 0) Position pos(hero_pos.getX() + 3 * velocityX, hero_pos.getY()); //if (velocityY != 0 && velocityX == 0) // Position pos(hero_pos.getX(), hero_pos.getY() + 3 * velocityY); //if (velocityY != 0 && velocityX != 0) // Position pos(hero_pos.getX() + 3 * velocityX, hero_pos.getY() + 3 * velocityY); setPosition(pos); }
void setBox3(const Real& s0, const Real& s1, const Real& s2){ setBox(Vector3r(s0,s1,s2)); }
CHitbox::CHitbox(void) { offsetX = 0; offsetY = 0; setBox(0, 0, 0, 0); }
/** If we should remeasure and update the bounding box dimensions, do so. */ void CC3TouchBox::updateAfterTransform( CC3NodeUpdatingVisitor* visitor ) { if (m_shouldAlwaysMeasureParentBoundingBox) setBox( getParentBoundingBox() ); }
AABox::AABox( Vec3 &corner, float x, float y, float z) { setBox(corner,x,y,z); }
CHitbox::CHitbox(int p_offsetx, int p_offsety, int p_w, int p_h) { offsetX = p_offsetx; offsetY = p_offsety; setBox(offsetX, offsetY, p_w, p_h); }
AABB::AABB( sf::Vector3<float> &corner, float x, float y, float z) { setBox(corner,x,y,z); }