Пример #1
0
bool ShapeGraphs::read( std::ifstream& stream, int version )
{
   // base class read
   if (version >= VERSION_AXIAL_SHAPES) {
      ShapeMaps<ShapeGraph>::read(stream,version);
   }
   else {
      readold(stream,version);
   }

   // these are additional essentially for all line axial maps
   // should probably be kept *with* the all line axial map...
   m_poly_connections.clear();
   m_poly_connections.read(stream);
   m_radial_lines.clear();
   m_radial_lines.read(stream);

   // this is an index to look up the all line map, used by UI to determine if can make fewest line map
   // note: it is not saved for historical reasons
   // will get confused by more than one all line map
   m_all_line_map = getMapRef("All-Line Map");
   if (m_all_line_map == -1) {
      // used to be called All Line Map
      m_all_line_map = getMapRef("All Line Map");
   }
   if (m_all_line_map != -1) {
      at(m_all_line_map).m_map_type = ShapeMap::ALLLINEMAP;
   }

   // VERSION_AXIAL_REGION_FIX -- this fix is now deprecated
   // some awful things could have gone wrong in the past, but the shapemap read should fix automatically

   return true;
}
Пример #2
0
RewriteSubstItem::~RewriteSubstItem()
{
    if ( getType() == REF_MAP )
    {
        delete getMapRef();
    }
}
Пример #3
0
void cPlayer::tick(double milliseconds)
{
    this->bombsLeft += getBombsRef().getRejuvenateCount(this->playerId);

    cMap &map = getMapRef();
    cRect &mapBounds = map.getBounderies();

    int nx = int(this->x - mapBounds.x1);
    int ny = int(this->y - mapBounds.y1);

    if(map(nx, ny).object == cMap::PWRUP_BOMB)
    {
        snd::Snd_Play(snd::SND_PWRUPTAKEN);
        map(nx, ny).object = cMap::NOTHING;
        this->bombsLeft++;
    }
    else if(map(nx, ny).object == cMap::PWRUP_BLOW)
    {
        snd::Snd_Play(snd::SND_PWRUPTAKEN);
        map(nx, ny).object = cMap::NOTHING;
        this->bombBlowLength++;
    }

    if(this->direction != this->desiredDirection)
    {
        while(this->desiredDirection < 0)
        {
            this->desiredDirection += 360;
        }
        while(this->desiredDirection > 360)
        {
            this->desiredDirection -= 360;
        }

        float gap = this->desiredDirection - this->direction;

        if(gap < -180)
        {
            gap = 360 + gap;
        }
        if(gap > 180)
        {
            gap = -360 + gap;
        }

        if((gap < - 1.0) || (gap > 1.0))
        {
            this->direction += gap/300 * milliseconds;
        }
        else
        {
            this->direction = this->desiredDirection;
        }
    }

    if(this->controller == AI)
    {

    }
}
Пример #4
0
void cBombContainer::create(int x, int y, int blowLength, int playerId)
{
    if(this->bombs[y * this->w + x].free)
    {
        this->bombs[y * this->w + x].free = false;
        this->bombs[y * this->w + x].blowLength = blowLength;
        this->bombs[y * this->w + x].fuse = OPT_BOMB_FUSETIME;
        this->bombs[y * this->w + x].playerId = playerId;

        cMap &map = getMapRef();

        map(x, y).walkable = false;
        map(x, y).object = cMap::BOMB;

        snd::Snd_Play(snd::SND_TICKTACK);
    }
}
Пример #5
0
void cPlayer::dropBomb()
{
    if(this->bombsLeft > 0)
    {

        cMap &map = getMapRef();
        cRect &mapBounds = map.getBounderies();

        float nx = this->x - mapBounds.x1;
        float ny = this->y - mapBounds.y1;

        if(map((int)nx, (int)ny).walkable)
        {
            this->bombsLeft --;
            cBombContainer &bombs = getBombsRef();
            bombs.create((int)nx, (int)ny, this->bombBlowLength, playerId);
        }
    }
}
Пример #6
0
bool cBombContainer::blowCheckSpot(int x, int y, std::deque<ptl::cParticle> &newPtls)
{
    cMap &map = getMapRef();
    cRect &mapBounds = map.getBounderies();

    if((x < 0) || (x >= this->w) || (y < 0) || (y >= this->h))
    {
        return false;
    }
    if(map(x, y).object == cMap::BOMB)
    {
        blow(x, y);
    }
    if(map(x, y).blowable)
    {
        int mx = (int)(x + mapBounds.x1);
        int my = (int)(y + mapBounds.y1);
        for(int p = 0; p < OPT_NUM_EXPLO_PTLS / (12/2); p ++)
        {
            ptl::cParticle newPtl(  getRndFloat(0.5, 1.0),
                                    getRndFloat(0.5, 1.0), getRndFloat(0.0, 0.5), getRndFloat(0.0, 0.2),
                                    cVertex(getRndFloat(mx, mx + 1), 0.3, getRndFloat(-my, -my - 1)),
                                    cVertex(getRndFloat(-cos(p), cos(p)), getRndFloat(4.0, 10.0), getRndFloat(-sin(p), sin(p))),
                                    cVertex(0, -0.1, 0)
                                );
            newPtls.push_back(newPtl);
        }
        if(map(x, y).object != cMap::NOTHING)
        {
            if (! map.createPwrUp(x, y))
            {
                map(x, y).walkable = true;
                map(x, y).object = cMap::NOTHING;
            }
            return false;
        }
    }
    else
    {
        return false;
    }
    return true;
}
Пример #7
0
bool cPlayer::collisionAt(float x, float y)
{
    bool collision = false;

    cMap &map = getMapRef();
    cRect &mapBounds = map.getBounderies();
    cBombContainer &bombs = getBombsRef();

    float nx = x - mapBounds.x1;
    float ny = y - mapBounds.y1;

    if(! map(nx, ny).walkable)
    {
        if(bombs(nx, ny).playerId != this->playerId)
        {
            collision = true;
        }
    }

    return collision;
}
Пример #8
0
void cPlayer::move(float relativeX, float relativeY, bool recursive)
{
    float nx = this->x + relativeX;
    float ny = this->y + relativeY;
    float moveAmount = (relativeX != 0 ? fabs(relativeX) : fabs(relativeY));

    // Collision testing
    bool colTL = false, colTR = false, colBL = false, colBR = false, colMap = false;
    this->collideHappened = false;

    // ... with map objects

    if(collisionAt(nx + this->collisionBox.x1, ny - this->collisionBox.y1))  // Top left
    {
        colTL = true;
    }
    if(collisionAt(nx + this->collisionBox.x2, ny - this->collisionBox.y1))  // Top right
    {
        colTR = true;
    }
    if(collisionAt(nx + this->collisionBox.x1, ny - this->collisionBox.y2))  // Bottom left
    {
        colBL = true;
    }
    if(collisionAt(nx + this->collisionBox.x2, ny - this->collisionBox.y2))  // Bottom right
    {
        colBR = true;
    }


    // ... with map bounds
    cMap &map = getMapRef();
    cRect &mapBounds = map.getBounderies();

    if(nx + this->collisionBox.x1 / 2 < mapBounds.x1)
    {
        colMap = true;
    }
    else if(nx + this->collisionBox.x2 / 2 > mapBounds.x2)
    {
        colMap = true;
    }
    if(ny + this->collisionBox.y1 / 2 < mapBounds.y1)
    {
        colMap = true;
    }
    else if(ny + this->collisionBox.y2 / 2 > mapBounds.y2)
    {
        colMap = true;
    }

    if(colTL || colTR || colBL || colBR || colMap)
    {
        this->collideHappened = true;

        if((! recursive) && (! colMap))
        {
            if(relativeY != 0)
            {
                if((colBR && ! colBL) || (colTR && ! colTL))
                {
                    move(-moveAmount, 0, true);
                }
                else if((colBL && ! colBR) || (colTL && ! colTR))
                {
                    move(moveAmount, 0, true);
                }
            }
            else
            {
                if((colTL && ! colBL) || (colTR && ! colBR))
                {
                    move(0, -moveAmount, true);
                }
                else if((colBL && ! colTL) || (colBR && ! colTR))
                {
                    move(0, moveAmount, true);
                }
            }
        }
    }
    else
    {
        this->x += relativeX;
        this->y += relativeY;
    }
}
Пример #9
0
void cBombContainer::blow(int x, int y)
{
    cMap &map = getMapRef();
    cRect &mapBounds = map.getBounderies();

    // Allow player to drop one more bomb now
    this->rejuvenateCount[this->bombs[y * this->w + x].playerId] ++;

    // Play sounds
    snd::Snd_Play(snd::SND_EXPLOSION);

    // Spawn particles
    float mx = x + mapBounds.x1;
    float my = y + mapBounds.y1;
    int blowLength = this->bombs[y * this->w + x].blowLength;
    std::deque<ptl::cParticle> newPtls;

    // Out going
    for(int i = 0; i < OPT_NUM_EXPLO_PTLS / (12/2); i ++)
    {
        ptl::cParticle newPtl(  getRndFloat(0.3, 0.7),
                                1.0, getRndFloat(0.0, 0.5), 0.0,
                                cVertex(mx + 0.5, 0.3, -my - 0.5),
                                cVertex(getRndFloat(-cos(i), cos(i)), getRndFloat(4.0, 10.0), getRndFloat(-sin(i), sin(i))),
                                cVertex(0, -0.1, 0)
                            );
        newPtls.push_back(newPtl);
    }

    // Left/Right going
    for(int i = 0; i < OPT_NUM_EXPLO_PTLS / (12/5); i ++)
    {
        ptl::cParticle newPtl(  getRndFloat(6.0 / blowLength, 6.0 / blowLength),
                                getRndFloat(0.5, 1.0), getRndFloat(0.0, 0.7), 0.0,
                                cVertex(mx + 0.5, 0.3, -my - 0.5),
                                cVertex(getRndFloat(-8.0, 8.0), getRndFloat(-0.1, 0.1), getRndFloat(-0.1, 0.1)),
                                cVertex(0, -0.1, 0)
                            );
        newPtls.push_back(newPtl);
    }

    // Up/Down going
    for(int i = 0; i < OPT_NUM_EXPLO_PTLS / (12/5); i ++)
    {
        ptl::cParticle newPtl(  getRndFloat(6.0 / blowLength, 6.0 / blowLength),
                                getRndFloat(0.5, 1.0), getRndFloat(0.0, 0.7), 0.0,
                                cVertex(mx + 0.5, 0.3, -my - 0.5),
                                cVertex(getRndFloat(-0.1, 0.1), getRndFloat(-0.1, 0.1), getRndFloat(-8.0, 8.0)),
                                cVertex(0, -0.1, 0)
                            );
        newPtls.push_back(newPtl);
    }


    // Remove stuff (crates, aso)
    this->bombs[y * this->w + x].free = true;
    this->bombs[y * this->w + x].playerId = -1;

    map(x, y).walkable = true;
    map(x, y).object = cMap::NOTHING;

    for(int i = x + 1; i <= x + this->bombs[y * this->w + x].blowLength; i ++)
    {
        if(blowCheckSpot(i, y, newPtls) == false)
        {
            break;
        }
    }

    for(int i = x - 1; i >= x - this->bombs[y * this->w + x].blowLength; i --)
    {
        if(blowCheckSpot(i, y, newPtls) == false)
        {
            break;
        }
    }

    for(int j = y + 1; j <= y + this->bombs[y * this->w + x].blowLength; j ++)
    {
        if(blowCheckSpot(x, j, newPtls) == false)
        {
            break;
        }
    }

    for(int j = y - 1; j >= y - this->bombs[y * this->w + x].blowLength; j --)
    {
        if(blowCheckSpot(x, j, newPtls) == false)
        {
            break;
        }
    }


    // Now create them all the particles
    ptl::createParticles(newPtls);
}