Example #1
0
void CIceChunk::smash()
{
	if (onscreen)
	{
		playSound(SOUND_CHUNKSMASH);
		CIceBit *chunk;

		// upleft
		chunk = new CIceBit(mp_Map, getXPosition(), getYPosition(), -1, -1);
		m_Object.push_back(chunk);

		// upright
		chunk = new CIceBit(mp_Map, getXPosition(), getYPosition(), 1, -1);
		m_Object.push_back(chunk);

		// downleft
		chunk = new CIceBit(mp_Map, getXPosition(), getYPosition(), -1, 1);
		m_Object.push_back(chunk);

		// downright
		chunk = new CIceBit(mp_Map, getXPosition(), getYPosition(), 1, 1);
		m_Object.push_back(chunk);
	}
	exists = false;
}
void CIceChunk::smash()
{
	if (onscreen)
	{
	    if(!silent)
		playSound(SOUND_CHUNKSMASH);
	    
	    silent = true;
	    CIceBit *chunk;

		// upleft
		chunk = new CIceBit(mp_Map, getXPosition(), getYPosition(), -1, -1);
		spawnObj(chunk);

		// upright
		chunk = new CIceBit(mp_Map, getXPosition(), getYPosition(), 1, -1);
		spawnObj(chunk);

		// downleft
		chunk = new CIceBit(mp_Map, getXPosition(), getYPosition(), -1, 1);
		spawnObj(chunk);

		// downright
		chunk = new CIceBit(mp_Map, getXPosition(), getYPosition(), 1, 1);
		spawnObj(chunk);
	}
	exists = false;
}
Example #3
0
void Obstacle::render(GameData &data)
{
	if (obsType == COLUMN) 
		data.renderModel(GameData::COLUMN_MODEL_INDEX, getXPosition(), getYPosition(), getZPosition(), getYAngle(), 0.0f, 2.0f);
	else if (obsType == BARREL)
		data.renderModel(GameData::BARREL_MODEL_INDEX, getXPosition(), getYPosition(), getZPosition(), getYAngle(), 0.0f, 2.0f);
	if (DEBUG) renderBoundingCilinder();
}
Example #4
0
CVortiMom::CVortiMom(CMap *p_map, Uint32 x, Uint32 y,
		std::vector<CPlayer>& Player,
		std::vector<CObject*>& Object) :
CObject(p_map, x, y, OBJ_MOTHER),
m_Player(Player),
m_Object(Object)
{
	HealthPoints = MOTHER_HP;
	state = MOTHER_WALK;
	animframe = 0;
	animtimer = 0;
	canbezapped = true;

	if (m_Player[0].getXPosition() > getXPosition())
		dir = RIGHT;
	else
		dir = LEFT;

	blockedr = blockedl = 0;

	if(mp_Map->m_Difficulty > 2)
		HealthPoints++;
	else if(mp_Map->m_Difficulty < 2)
		HealthPoints--;
}
Example #5
0
void CRope::getShotByRay(object_t &obj_type)
{
	if(state == ROPE_IDLE)
	{
		if ( exists && canbezapped )
		{
			// rope got broke! time to drop the stone
			state = ROPE_DROPSTONE;
			droptimer = 0;
			// hide the rope
			mSpriteIdx = BLANKSPRITE;
			// get upper left corner of the stone
			const int x = (getXPosition()>>CSF);
			const int y = (getYPosition()>>CSF);
			stoneX = x - 4;
			stoneY = y + 1;

			// Create a Colision Rect the way, everthing below gets smashed and on the Stone stays unharmed
			moveTo( (stoneX<<CSF), (stoneY<<CSF)+((1<<CSF)/2) );

			// get color of background
			bgtile = gBehaviorEngine.getPhysicsSettings().misc.changestoneblock;

			// Set BBox so the getTouched Function works on the enemies.
			m_BBox(0, 0,
				(STONE_WIDTH<<CSF),
				(STONE_HEIGHT<<CSF)-((1<<CSF)/2) );

			falldist = 0;
		}
	}
Example #6
0
/*************************************************************************
	set the movement range of the thumb for the horizontal axis.
*************************************************************************/
void Thumb::setHorzRange(float min, float max)
{
    Sizef parentSize(getParentPixelSize());

	// ensure min <= max, swap if not.
	if (min > max)
	{
		float tmp = min;
		max = min;
		min = tmp;
	}

	d_horzMax = max;
	d_horzMin = min;

	// validate current position.
	const float cp = CoordConverter::asAbsolute(getXPosition(), parentSize.d_width);

	if (cp < min)
	{
		setXPosition(cegui_absdim(min));
	}
	else if (cp > max)
	{
		setXPosition(cegui_absdim(max));
	}

}
Example #7
0
/*************************************************************************
	set the movement range of the thumb for the horizontal axis.
*************************************************************************/
void Thumb::setHorzRange(float min, float max)
{
	// ensure min <= max, swap if not.
	if (min > max)
	{
		float tmp = min;
		max = min;
		min = tmp;
	}

	d_horzMax = max;
	d_horzMin = min;

	// validate current position.
	float cp = getXPosition();

	if (cp < min)
	{
		setXPosition(min);
	}
	else if (cp > max)
	{
		setXPosition(max);
	}

}
Example #8
0
void CAutoRay::process()
{
	if( (mp_Map->getAnimtiletimer()%GUNFIRE_TIMER) == 0 )
	{
		unsigned int x,y;
		CRay *NewRay;
		x = getXPosition();
		y = getYPosition();

		if (m_type==VERTICAL)
		{
			NewRay = new CRay(mp_Map, x+(4<<STC), y+(1<<CSF), DOWN, OBJ_AUTORAY_V, m_index, 124);
			NewRay->sprite = RAY_VERT_EP3;
			NewRay->m_Direction = DOWN;
		}
		else
		{
			NewRay = new CRay(mp_Map, x+(1<<CSF), y+(4<<STC), DOWN, OBJ_AUTORAY, m_index, 124);
			NewRay->sprite = ENEMYRAYEP3;
			NewRay->m_Direction = RIGHT;
		}
		m_Objvect.push_back(NewRay);

		g_pSound->playStereofromCoord(SOUND_TANK_FIRE, PLAY_NOW, scrx);
	}
}
Example #9
0
void COrbatrix::getTouchedBy(CSpriteObject& theObject)
{
    if(dead || theObject.dead)
        return;

    // Was it a bullet, make it zap/zot
    if( dynamic_cast<CBullet*>(&theObject) )
    {
        setAction(A_ORBATRIX_FLOAT);
        theObject.dead = true;
        return;
    }
    
    if( CPlayerBase *player = dynamic_cast<CPlayerBase*>(&theObject) )
    {
        if(!mGivesKey)
        {
            // Only kill Keen, if Orbatrix bounces
            if(getActionNumber(A_ORBATRIX_BOUNCE))
            {
                player->kill();
            }
        }
        else
        {
            stItemGalaxy &Item = player->m_Inventory.Item;
            Item.m_gem.red++;
            spawnObj(new CItemEffect(mp_Map, 0, getXPosition(), getYPosition(), got_sprite_item_pics[2][2], FADEOUT));
            dead = true;
            exists = false;
        }
    }
}
Example #10
0
void CAutoRay::process()
{
	if( (mp_Map->getAnimtiletimer()%GUNFIRE_TIMER) == 0 )
	{
		unsigned int x,y;
		CRay *NewRay;
		x = getXPosition();
		y = getYPosition();

		if (m_type==VERTICAL)
		{
			NewRay = new CRay(mp_Map, x+(4<<STC), y+(1<<CSF), CENTER, DOWN, OBJ_AUTORAY_V, m_index, 124);
			NewRay->sprite = RAY_VERT_EP3;
			NewRay->m_VertDir = DOWN;
		}
		else
		{
			NewRay = new CRay(mp_Map, x+(1<<CSF), y+(4<<STC), CENTER, DOWN, OBJ_AUTORAY, m_index, 124);
			NewRay->sprite = ENEMYRAYEP3;
			NewRay->m_HorDir = RIGHT;
		}
		g_pBehaviorEngine->EventList().spawnObj(NewRay);

		if(!silent)
		{
		    playSound(SOUND_TANK_FIRE);
		    silent = true;
		}		
	}
}
void CSoundWave::process()
{
	// destroy the sound wave if it's been offscreen for a good amount
	// of time. this is to prevent a massive buildup of soundwaves
	// slowly traveling through walls all the way across the level
	// (which can crash the game due to running out of object slots).
	if (!onscreen)
	{
		if (offscreentime > SNDWAVE_OFFSCREEN_KILL_TIME)
		{
			exists = false;
			return;
		}
		else offscreentime++;
	}
	else offscreentime = 0;

	// fly through the air
	int x = getXPosition()>>CSF;
	if (m_HorDir == RIGHT)
	{
		sprite = SNDWAVE_RIGHT_FRAME + animframe;

		if (x > static_cast<int>(mp_Map->m_width) )
			exists=false;
		else
		{
			if(gpBehaviorEngine->mDifficulty>=NORMAL)
				moveRight(SNDWAVE_SPEED_FAST);
			else
				moveRight(SNDWAVE_SPEED);
		}
	}
	else
	{
		sprite = SNDWAVE_LEFT_FRAME + animframe;

		if (x < 2)
			exists = false;
		else
		{
			if (gpBehaviorEngine->mDifficulty>=NORMAL)
				moveLeft(SNDWAVE_SPEED_FAST);
			else
				moveLeft(SNDWAVE_SPEED);
		}
	}

	// animation
	if (animtimer > SNDWAVE_ANIM_RATE)
	{
		animframe ^= 1;
		animtimer = 0;
	}
	else animtimer++;
}
Example #12
0
void CVarPlatform::process()
{
    int xBlockPos = target.x - getXPosition();
    int yBlockPos = target.y - getYPosition();
    
    const int xBlockPosAbs = (xBlockPos<0) ? -xBlockPos : xBlockPos;
    const int yBlockPosAbs = (yBlockPos<0) ? -yBlockPos : yBlockPos;
    
    if( xBlockPosAbs < MOVE_SPEED && yBlockPosAbs < MOVE_SPEED )
    {
        const Uint16 object = mpMap->getPlaneDataAt(2, target.x, target.y);

        Vector2D<int> speed(xBlockPos, yBlockPos);
        movePlat(speed);

        readDirection(object, xDirection, yDirection );
        detectNextTarget(target, xDirection, yDirection);
    }
    
    if(yDirection == UP && blockedu)
        yDirection = DOWN;
    else if(yDirection == DOWN && blockedd)
        yDirection = UP;
    
    if(xDirection == RIGHT && blockedr)
        xDirection = LEFT;
    else if(xDirection == LEFT && blockedl)
        xDirection = RIGHT;
    
    Vector2D<int> speed;
    
    if(yDirection == UP)
    {
        speed.y = -MOVE_SPEED;
    }
    else if(yDirection == DOWN)
    {
        speed.y = MOVE_SPEED;
    }
    
    
    if(xDirection == RIGHT)
    {
        speed.x = MOVE_SPEED;
    }
    else if(xDirection == LEFT)
    {
        speed.x = -MOVE_SPEED;
    }
    
    movePlat(speed);
    
    CPlatform::process();
}
Example #13
0
CDoor::CDoor(CMap *pmap, Uint32 x, Uint32 y, Uint32 doorspriteID):
CVorticonSpriteObject(pmap, x, y, OBJ_DOOR, 0)
{
	sprite=doorspriteID;
    GsSprite &Doorsprite = gGraphics.getSprite(mSprVar,sprite);
	timer = 0;
	Doorsprite.setHeight(32);
	inhibitfall = true;
	x = getXPosition()>>CSF;
	y = getYPosition()>>CSF;
	mp_Map->redrawAt(x, y);
	mp_Map->redrawAt(x, y+1);
}
Example #14
0
// the ice cannon itself
void CIceCannon::process()
{
	// keep spawner object invisible and properly positioned
	if(	(mp_Map->getAnimtiletimer()%GUNFIRE_TIMER_EP1) == 0 )
	{
		int newpos_x = getXPosition();
		int newpos_y = getYPosition();
		if(vector_x > 0) newpos_x += 512;
		CIceChunk *chunk = new CIceChunk(mp_Map, newpos_x, newpos_y,
								vector_x, vector_y, m_Player, m_Object);
		m_Object.push_back(chunk);
	}
}
Example #15
0
bool MWindow::isMouseOverWindow(void)
{
	POINT p;

	GetCursorPos(&p);
	p.x -= getXPosition();
	p.y -= getYPosition();

	if(p.x >= 0 && p.y >= 0 && p.x < (int)getWidth() && p.y < (int)getHeight())
		return true;

	return false;
}
Example #16
0
CDoor::CDoor(CMap *pmap, Uint32 x, Uint32 y, Uint32 doorspriteID):
CVorticonSpriteObject(pmap, x, y, OBJ_DOOR)
{
	sprite=doorspriteID;
	CSprite &Doorsprite = g_pGfxEngine->getSprite(sprite);
	timer = 0;
	Doorsprite.setHeight(32);
	inhibitfall = true;
	x = getXPosition()>>CSF;
	y = getYPosition()>>CSF;
	mp_Map->redrawAt(x, y);
	mp_Map->redrawAt(x, y+1);
}
Example #17
0
void CVortiNinja::init()
{
	state = NINJA_STAND;
	timetillkick = (rnd()%(NINJA_MAX_TIME_TILL_KICK-NINJA_MIN_TIME_TILL_KICK))+NINJA_MIN_TIME_TILL_KICK;
	if (mp_Map->m_Difficulty>1) timetillkick /= 3;

	if (m_Player[0].getXPosition() < getXPosition())
		dir = LEFT;
	else
		dir = RIGHT;

	animtimer = 0;
	animframe = 0;
	dying = false;
}
/**
 * Checks whether the game is over and if yes stops timer and emits gameOver().
 *
 * @return When it is over true, otherwise false.
 */
bool GameController::checkGameOver()
{
	QSharedPointer< ::GameLogic::FourInALine::Game> game = this->game->getGameLogic();

	if (game->isOver())
	{
		auto board = game->getBoard();
		auto winningCells = board->findWinningCells();

		qDebug() << "[" << this << "::checkGameOver ] " << "Game is over.";

		this->abortRequest();

		if (this->game->getGameLogic()->hasTimeLimit())
		{
			this->remainingSeconds = 0;
			this->timeLimitTimer->stop();
		}

		for (auto it = winningCells.begin(); it != winningCells.end(); it++)
		{
			emit this->setCellHighlighted(it.getXPosition(), it.getYPosition(), true);
		}

        if (this->game->isSavingHighscore())
        {
            Database* database = ::FourInALine::getInstance()->getDatabase();
            int result = 0;
            if (game->isDraw())
                result = 2;
            else if (this->game->getWinningPlayer() == this->game->getFirstPlayer())
                result = 1;
            database->insertHighscore(this->game->getFirstPlayer()->getName(), this->game->getSecondPlayer()->getName(), result);
        }

		emit this->gameOver(game->isDraw());

		// this->game could be a new game after gameOver has been emitted!

		return true;
	}

	return false;
}
Example #19
0
bool CAutoRay::isNearby(CVorticonSpriteObject &theObject)
{       
    if( CPlayer *player = dynamic_cast<CPlayer*>(&theObject) )
    {
	int distx = player->getXPosition() - getXPosition();
	if(distx<0)
	    distx = -distx;
	
	int disty = player->getYPosition() - getYPosition();
	if(disty<0)
	    disty = -disty;
	
	if( disty < SILENT_DIST && distx < SILENT_DIST )
	{
	    silent = false;	
	}
    }

    return true;
}
Example #20
0
bool CGarg::isNearby(CVorticonSpriteObject &theObject)
{       
    if(CPlayer *player = dynamic_cast<CPlayer*>(&theObject))
    {
	if( state == GARG_LOOK )
	{
		if (looktimes>GARG_NUM_LOOKS)
		{
			// try to head towards Keen...
			if (player->getXPosition() < getXPosition())
				movedir = LEFT;
			else
				movedir = RIGHT;
		}		
	}
	
	else if( state == GARG_MOVE )
	{
		// is keen on same level?
		if ( player->getYDownPos() >= getYDownPos()-(16<<STC) )
		{
		    if ( player->getYDownPos() <= getYDownPos()+(16<<STC) )
		    {
			keenonsameleveltimer++;
			if (keenonsameleveltimer > GARG_SAME_LEVEL_TIME)
			{ // charge!!
				keenonsameleveltimer = 0;
				timer = 0;
				looktimes = 1;
				about_to_charge = 1;
				state = GARG_LOOK;
			}
			
			return true;
		    }
		}
		keenonsameleveltimer = 0;
	}	
    }
    return true;
}
Example #21
0
bool CFoob::isNearby(CVorticonSpriteObject &theObject)
{
    if(CPlayer *player = dynamic_cast<CPlayer*>(&theObject))
    {
        if ( (player->getYDownPos() >= getYUpPos()-(2<<CSF)) &&
             (player->getYDownPos() <= getYDownPos()+(1<<CSF)) )
        {
            onsamelevel = true;
            SpookedByWho = player->m_index;
        }

        if(state == FOOB_SPOOK)
        {
            mSpriteIdx = FOOB_SPOOK_FRAME;

            if (spooktimer > FOOB_SPOOK_SHOW_TIME)
            {
                state = FOOB_FLEE;
                OffOfSameLevelTime = 0;
                // run away from the offending player

                if (player->getXPosition() < getXPosition())
                    dir = RIGHT;
                else
                    dir = LEFT;

                // in hard mode run TOWARDS the player (he's deadly in hard mode)
                if (gBehaviorEngine.mDifficulty == HARD)
                {
                    dir = (dir==LEFT) ? RIGHT : LEFT;
                }

            }
            else spooktimer++;
        }
    }
    
    return true;
}
Example #22
0
// the ice cannon itself
void CIceCannon::process()
{
	// keep spawner object invisible and properly positioned
	if( mTimer >= GUNFIRE_TIMER_EP1 )
	{
		int newpos_x = getXPosition();
		int newpos_y = getYPosition();
		if(vector_x > 0) newpos_x += 512;
		CIceChunk *chunk = new CIceChunk(mp_Map, newpos_x, newpos_y,vector_x, vector_y);
		if(!silent)
		{
		    playSound(SOUND_CANNONFIRE);
		    silent = true;
		}

		spawnObj(chunk);
		mTimer = 0;
	}
	else
	{
	    mTimer++;
	}
}
Example #23
0
bool CYorp::isNearby(CVorticonSpriteObject &theObject)
{       
    if( state == YORP_LOOK )
    {
	if (looktimes>numlooks && timer==YORP_LOOK_TIME-(YORP_LOOK_TIME/4))
	{
	        if( CPlayer *player = dynamic_cast<CPlayer*>(&theObject) )
		{
		    movedir = (player->getXPosition() < getXPosition()) ? LEFT : RIGHT;
		}		

		// unless we're can't go that way
		if (blockedl) movedir = RIGHT;
		if (blockedr) movedir = LEFT;

		timer = 0;
		walkframe = 0;
		dist_traveled = 0;
		state = YORP_MOVE;
	}
    }
    return true;
}
/**
 * Undoes the last move.
 */
void GameController::undoLastMove()
{
	qDebug() << "[" << this << "::undoLastMove ] " << "Undo last move";

	bool gameWasOverBefore = this->game->getGameLogic()->isOver();

	this->abortRequest();

	if (gameWasOverBefore)
	{
		auto winningCells = this->game->getGameLogic()->getBoard()->findWinningCells();

		for (auto it = winningCells.begin(); it != winningCells.end(); it++)
		{
			emit this->setCellHighlighted(it.getXPosition(), it.getYPosition(), false);
		}
	}

	auto nMoves = this->game->getGameLogic()->getNumberOfMoves();

	auto position = this->game->getGameLogic()->computeMovePosition(nMoves - 1);
	this->game->getGameLogic()->undoLastMove();

	emit this->removeCell(position.first, position.second);

	position = this->game->getGameLogic()->computeMovePosition(nMoves - 2);
	this->game->getGameLogic()->undoLastMove();

	emit this->removeCell(position.first, position.second);

	if (gameWasOverBefore)
	{
		emit this->gameNotOverAnymore();
	}

	this->requestNextMove();
}
Example #25
0
void CSpriteItem::getTouchedBy(CSpriteObject &theObject)
{
	if( CPlayerBase* pPlayer = dynamic_cast<CPlayerBase*>(&theObject) )
	{
		stItemGalaxy &Item = pPlayer->m_Inventory.Item;

		/// Calculate the right animation.
		// Point items
		Uint32 newanimsprite = got_sprite_item_pics[0];
		if( m_basesprite >= 103 && m_basesprite <= 116 )
		{
			newanimsprite = got_sprite_item_pics[4+(m_basesprite-103)/2];
			switch(m_basesprite)
			{
			case 103: Item.m_points += 100;	break;
			case 105: Item.m_points += 200;	break;
			case 107: Item.m_points += 500;	break;
			case 109: Item.m_points += 1000;	break;
			case 111: Item.m_points += 2000;	break;
			case 113: Item.m_points += 5000;	break;
			default: break;
			}
			g_pSound->playSound( SOUND_GET_BONUS );
		}

		// raygun
		if( m_basesprite >= 127 && m_basesprite <= 128 )
		{
			Item.m_bullets += 5;
			newanimsprite = got_sprite_item_pics[11];
			g_pSound->playSound( SOUND_GET_AMMO );
		}

		m_ObjectPtrs.push_back(new CItemEffect(mp_Map, 0, getXPosition(), getYPosition(), newanimsprite));


		// Now add the stuff to the inventory

		if( m_basesprite >= 118 && m_basesprite <= 124 )
		{
			switch(m_basesprite)
			{
			case 118: case 119:
				Item.m_gem.red++;
				break;
			case 120: case 121:
				Item.m_gem.yellow++;
				break;
			case 122: case 123:
				Item.m_gem.blue++;
				break;
			case 124: case 125:
				Item.m_gem.green++;
				break;
			default:
				break;
			}
			g_pSound->playSound( SOUND_GET_GEM );
		}

		if ( m_basesprite == 115 )
		{
			Item.m_lifes++;
			g_pSound->playSound( SOUND_EXTRA_LIFE );
		}

		exists = false;
	}
}
void CVorticonElite::process()
{
	if (HealthPoints <= 0 && state != VORTELITE_DYING)
	{
		animtimer = 0;
		frame = 0;
		state = VORTELITE_DYING;
		dying = true;

		if (onscreen)
			playSound(SOUND_VORT_DIE);
	}

	if(state == VORTELITE_CHARGE)
	{
		m_speed = CHARGE_SPEED;
	}
	else if(state == VORTELITE_WALK)
	{
		m_speed = WALK_SPEED;
	}

	reprocess: ;
	switch(state)
	{
	case VORTELITE_CHARGE:
	case VORTELITE_WALK:
		dist_traveled++;

		state = VORTELITE_WALK;

		// If Player is nearby, make vorticon go faster
		if(getYDownPos() > m_Player[0].getYDownPos()-(1<<CSF) and
		   getYDownPos() < m_Player[0].getYDownPos()+(1<<CSF) )
		{
			int dist;
			if(getXMidPos() > m_Player[0].getXMidPos())
				dist = getXMidPos()-m_Player[0].getXMidPos();
			else
				dist = m_Player[0].getXMidPos()-getXMidPos();

			if(dist < PLAYER_DISTANCE)
				state = VORTELITE_CHARGE;
		}


		if (getProbability(VORTELITE_JUMP_PROB) && !mp_Map->m_Dark && !blockedu)
		{  // let's jump.
			initiatejump();
			goto reprocess;
		}
		else
		{
			if (timesincefire > VORTELITE_MIN_TIME_BETWEEN_FIRE)
			{
				if (getProbability(VORTELITE_FIRE_PROB))
				{  	// let's fire
					// usually shoot toward keen
					if (rand()%5 != 0)
					{
						if (getXPosition() < m_Player[0].getXPosition())
						{
							movedir = RIGHT;
						}
						else
						{
							movedir = LEFT;
						}
					}
					timer = 0;
					state = VORTELITE_ABOUTTOFIRE;
				}
			}
			else timesincefire++;
		}

		if (movedir==LEFT)
		{  // move left
			sprite = VORTELITE_WALK_LEFT_FRAME + frame;
			if (!blockedl)
			{
				xinertia = -m_speed;
			}
			else
			{
				movedir = RIGHT;

				// if we only traveled a tiny amount before hitting a wall, we've
				// probably fallen into a small narrow area, and we need to try
				// to jump out of it
				if (dist_traveled < VORTELITE_TRAPPED_DIST && !mp_Map->m_Dark && blockedd)
				{
					initiatejump();
					goto reprocess;
				}
				else dist_traveled = 0;
			}
		}
		else
		{  // move right
			sprite = VORTELITE_WALK_RIGHT_FRAME + frame;
			if (!blockedr)
			{
				xinertia = m_speed;
			}
			else
			{
				movedir = LEFT;

				// if we only traveled a tiny amount before hitting a wall, we've
				// probably fallen into a small narrow area, and we need to try
				// to jump out of it
				if (dist_traveled < VORTELITE_TRAPPED_DIST && !mp_Map->m_Dark && blockedd)
				{
					initiatejump();
					goto reprocess;
				}
				else dist_traveled = 0;
			}
		}

		// walk animation
		if (animtimer > VORTELITE_WALK_ANIM_TIME)
		{
			if (frame>=3) frame=0;
			else frame++;
			animtimer = 0;
		} else animtimer++;
		break;

	case VORTELITE_JUMP:
		if (movedir == RIGHT)
		{ if (!blockedr) moveRight(m_speed); }
		else
		{ if (!blockedl) moveLeft(m_speed); }

		if (blockedd && yinertia >= 0)
		{  // The Vorticon Has landed after the jump!
			state = VORTELITE_WALK;
			goto reprocess;
		}

		break;
	case VORTELITE_ABOUTTOFIRE:
		if (movedir==RIGHT)
		{ sprite = VORTELITE_FIRE_RIGHT_FRAME; }
		else
		{ sprite = VORTELITE_FIRE_LEFT_FRAME; }
		if (timer > VORTELITE_HOLD_GUN_OUT_TIME)
		{
			timer = 0;
			state = VORTELITE_FIRED;

			CRay *newobject;
			if (movedir==RIGHT)
				newobject = new CRay(mp_Map, getXRightPos()+1, getYPosition()+(9<<STC), RIGHT);
			else
				newobject = new CRay(mp_Map, getXLeftPos()-1, getYPosition()+(9<<STC), LEFT);
			newobject->setOwner( m_type, m_index);
			newobject->sprite = ENEMYRAYEP2;
			// don't shoot other vorticon elite
			m_Object.push_back(newobject);

			if (onscreen)
				playSound(SOUND_KEEN_FIRE);
		}
		else timer++;
		break;
	case VORTELITE_FIRED:
		if (movedir==RIGHT)
		{ sprite = VORTELITE_FIRE_RIGHT_FRAME; }
		else
		{ sprite = VORTELITE_FIRE_LEFT_FRAME; }

		if (timer > VORTELITE_HOLD_GUN_AFTER_FIRE_TIME)
		{
			timer = 0;
			frame = 0;
			timesincefire = 0;
			state = VORTELITE_WALK;
			// head toward keen
			if (getXPosition() < m_Player[0].getXPosition())
			{
				movedir = RIGHT;
			}
			else
			{
				movedir = LEFT;
			}
		}
		else timer++;
		break;
	case VORTELITE_DYING:
		sprite = VORTELITE_DYING_FRAME;
		if (animtimer > VORTELITE_DIE_ANIM_TIME)
		{
			sprite = VORTELITE_DEAD_FRAME;
			dead = true;
		}
		else
		{
			animtimer++;
		}
		break;
	default: break;
	}
}
void CRocket::processFlying()
{
    int xBlockPos = target.x - getXPosition();
    int yBlockPos = target.y - getYPosition();
    
    const int xBlockPosAbs = (xBlockPos<0) ? -xBlockPos : xBlockPos;
    const int yBlockPosAbs = (yBlockPos<0) ? -yBlockPos : yBlockPos;
    
    
    if( xBlockPosAbs < MOVE_SPEED && yBlockPosAbs < MOVE_SPEED )
    {
	const Uint16 object = mp_Map->getPlaneDataAt(2, target.x, target.y);
	
	Vector2D<int> speed(xBlockPos, yBlockPos);	    
	moveDir(speed);
	playSound(SOUND_ROCKET_DRIVE);
	
	// Happens when the rocket find a place where to stop
	if(object == 0x6A || object == 0x69)
	{
	    xDirection = CENTER;
	    yDirection = UP;
	    setAction(A_ROCKET_SIT);
	    detectNextTarget(target, xDirection, yDirection);
	    
	    Vector2D<int> newPlayerPos = m_Pos;
	    
	    newPlayerPos.y = getYDownPos();
	    newPlayerPos.x = getXRightPos();
	    
	    mpCarriedPlayer->moveToForce(newPlayerPos);
	    mpCarriedPlayer->solid = true;
	    mpCarriedPlayer->dontdraw = false;
	    mpCarriedPlayer = nullptr;
	    return;
	}

	readDirection(object, xDirection, yDirection );
	
	// If there is an object that changes the direction of the rocket, apply it!	
	detectNextTarget(target, xDirection, yDirection);		
    }
    
    Vector2D<int> speed;
    
    if(yDirection == UP)
    {
	speed.y = -MOVE_SPEED;
    }
    else if(yDirection == DOWN)
    {
	speed.y = MOVE_SPEED;
    }    
    
    if(xDirection == RIGHT)
    {
	speed.x = MOVE_SPEED;
    }
    else if(xDirection == LEFT)
    {
	speed.x = -MOVE_SPEED;
    }
    
    if(mpCarriedPlayer != nullptr)
    {
	mpCarriedPlayer->moveDir(speed);
    }
    moveDir(speed);
}
Example #28
0
void CGuardRobot::process()
{
	switch(state)
	{
	case LOOK:
		// animation
		if (animtimer > LOOK_ANIM_TIME)
		{
			frame ^= 1;
			animtimer = 0;
		}
		else
			animtimer++;

		sprite = LOOK_FRAME + frame;

		// when time is up go back to moving
		if (timer > LOOK_TOTALTIME)
		{
			timetillcanfire = (rnd()%(MAX_TIME_TILL_CAN_FIRE-MIN_TIME_TILL_CAN_FIRE))+MIN_TIME_TILL_CAN_FIRE;
			timetillcanfirecauseonsamelevel = TIME_BEFORE_FIRE_WHEN_SEE;
			firetimes = 0;
			state = WALK;
			frame = 0;
			animtimer = 0;
			timer = 0;
			dist_to_travel = TRAVELDIST;
		}
		else
			timer++;

		break;

	case WALK:
		// hover animation
		if (animtimer > WALK_ANIM_TIME)
		{
			if (frame>=3) frame=0;
			else frame++;
			animtimer = 0;
		} else animtimer++;

		if (movedir==LEFT)
			sprite = WALK_LEFT_FRAME + frame;
		else
			sprite = WALK_RIGHT_FRAME + frame;

		// if we're about to, or just did, fire a volley, don't move
		if (!hardmode)
		{
			if (pausetime)
			{
				pausetime--;
				return;
			}
		}
		else
			pausetime = 0;

		// are we firing a volley?
		if (firetimes)
		{
			// is it time to fire the next shot in the volley?
			if (!timetillnextshot)
			{
				CRay *newobject;
				if (onscreen)
					playSound(SOUND_TANK_FIRE);
				if (movedir==RIGHT)
					newobject = new CRay(mp_Map,getXRightPos()+(8<<STC), getYUpPos()+(5<<STC), RIGHT);
				else
					newobject = new CRay(mp_Map,getXPosition(), getYUpPos()+(5<<STC), LEFT);
				newobject->setOwner(OBJ_GUARDROBOT, m_index);
				newobject->sprite = ENEMYRAYEP2;

				m_ObjectVect.push_back(newobject);

				timetillnextshot = TIME_BETWEEN_SHOTS;
				if (!--firetimes)
				{
					pausetime = FIRE_PAUSE_TIME;
				}
			}
			else
			{
				timetillnextshot--;
			}

			// don't move when firing except on hard mode
			if (hardmode)
				return;

		}
		else
		{  // not firing a volley
			if (!timetillcanfire)
			{
				guard_fire();
			}
			else
			{
				timetillcanfire--;
			}

		}

		turnaroundtimer = 0;

		if (movedir==LEFT)
		{  // move left
			if (!blockedl)
			{
				xinertia = -WALK_SPEED;
				dist_to_travel--;
			}
			else
			{
				frame = 0;
				timer = 0;
				animtimer = 0;
				state = LOOK;
				movedir = RIGHT;
			}
		}
		else
		{  // move right
			sprite = WALK_RIGHT_FRAME + frame;
			if (!blockedr)
			{
				xinertia = WALK_SPEED;
				dist_to_travel--;
			}
			else
			{
				frame = 0;
				timer = 0;
				animtimer = 0;
				state = LOOK;
				movedir = LEFT;
			}
		}
		break;
	default : break;
	}
}
Example #29
0
/* Render */
void MediKitObject::render(GameData &data)
{
	if (isPickedUp()) return;
	data.renderModel(GameData::MEDIKIT_MODEL_INDEX, getXPosition(), getYPosition(), getZPosition(), getYAngle(), 0.0f, 2.0f);
	if (DEBUG) renderBoundingCilinder();
}
Example #30
0
// AI for the Spark object in the Tantalus Ray Machine's of ep2
void CSpark::process()
{
	int mx,my,x,y;

	mx = getXPosition() >> CSF;
	my = getYPosition() >> CSF;

	if (state==SPARK_ANIMATE)
	{
		sprite = SPARK_BASEFRAME + frame;
	}
	else
	{
		sprite = BLANKSPRITE;
	}

	switch(state)
	{
	case SPARK_ANIMATE:
		if (timer > SPARK_ANIMRATE)
		{
			frame++;
			if (frame > 3) frame = 0;
			timer = 0;
		} else timer++;

		if ( mHealthPoints <= 0 && state == SPARK_ANIMATE )
		{
			playSound(SOUND_SHOT_HIT);

			// break the glass and blow out the electric arcs
			mp_Map->setTile(mx - 2, my, 492, true);
			mp_Map->setTile(mx - 1, my, 546, true);
			mp_Map->setTile(mx, my, 547, true);
			mp_Map->setTile(mx + 1, my, 548, true);
			mp_Map->setTile(mx + 2, my, 492, true);
			// remove the unneeded dome tiles
			mp_Map->setTile(mx - 1, my-1, BG_GREY, true);
			mp_Map->setTile(mx, my-1, BG_GREY, true);
			mp_Map->setTile(mx + 1, my-1, BG_GREY, true);
			// break the switch
			mp_Map->setTile(mx - 3, my + 4, 506, true);

			// meltdown!
			state = SPARK_BLOWUP1;
			timer = 0;
			blowy = 0;
		}
		break;
	case SPARK_BLOWUP1:
		// one by one blow out the purple thingies below the device
		if (timer > SPARK_BLOW_DELAY)
		{
			timer = 0;
			my = my+3+blowy;
			mp_Map->setTile(mx, my, 505, true);
			// spawn a ZAP! or a ZOT!
            CRay *newobject = new CRay(mp_Map, mx<<CSF, my<<CSF, CENTER, DOWN, getSpriteVariantId());
			newobject->state = CRay::RAY_STATE_SETZAPZOT;
			newobject->setOwner(m_type, m_index);
			gEventManager.add( new EventSpawnObject(newobject) );
			playSound(SOUND_SHOT_HIT);

			blowy++;
			if (blowy >= 3)
			{
				state = SPARK_BLOWUP2;
				blowx = 0;
			}
		}
		else timer++;
		break;
	case SPARK_BLOWUP2:
		// blow out the glowing cells
		if (timer > SPARK_BLOW_DELAY)
		{
			if (blowx >= 4)
			{
				// done blowing up the glowcells
				// static the targeting display
				mx = mx - 7;
				my = my + 2;
				for(y=0;y<3;y++)
				{
					for(x=0;x<3;x++)
					{
						mp_Map->setTile(mx+x,my+y,533, true);
					}
				}
				exists = false;
				return;
			}

			timer = 0;
			mx = mx + blowx + 3;
			for(y=3;y<6;y++)
			{
				//my = my+3+y;
				//my = my+y;
				mp_Map->setTile(mx, my+y, 549, true);
				// spawn a ZAP! or a ZOT!
                CRay *newobject = new CRay(mp_Map, mx<<CSF, (my+y)<<CSF, CENTER, DOWN, getSpriteVariantId());
				newobject->setOwner(m_type ,m_index);
				newobject->state = CRay::RAY_STATE_SETZAPZOT;
				playSound(SOUND_SHOT_HIT);
				gEventManager.add(new EventSpawnObject(newobject));
			}

			blowx++;
		}
		else timer++;
		break;
	default: break;
	}  // end of state switch for SE_SPARK
}