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
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 #5
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 #6
0
/*************************************************************************
	set the movement range of the thumb for the vertical axis.	
*************************************************************************/
void Thumb::setVertRange(float min, float max)
{
	// ensure min <= max, swap if not.
	if (min > max)
	{
		float tmp = min;
		max = min;
		min = tmp;
	}

	d_vertMax = max;
	d_vertMin = min;

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

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

}
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;
		}		
	}
}
Example #8
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 #9
0
void CRoboRed::processShoot()
{
  // Shoot many times.  
  if(mTimer%16 == 0)
  {
    playSound(SOUND_ROBORED_SHOOT);
    
    direction_t newXDir = xDirection<0 ? LEFT : RIGHT;
    direction_t newYDir = swapYDir ? UP : DOWN;    
    swapYDir = !swapYDir;
    int newX = 	xDirection == RIGHT ? getXRightPos() : getXLeftPos();
    int newY = 	getYPosition() + 0x300;
    spawnObj( new CRedShot( getMapPtr(), 
							     0, 
							     newX, newY,
							     newXDir, newYDir ) );
  }
				
  mTimer++;
  if(mTimer < TIME_SHOOTING)
    return;
  
  mTimer = 0;
  
  setAction(A_RED_PAUSE);
}
Example #10
0
/* Update */
void MediKitObject::update()
{
	setYAngle(getYAngle() + INCREMENT_Y_ANGLE);
	if (!yPositionUpdated) {
		yPositionUpdated = true;
		setYPosition(getYPosition() + 1.0f);
	}
}
Example #11
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 #12
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 #13
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 #14
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 #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;
}
/**
 * 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 #17
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 #18
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++;
	}
}
/**
 * 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();
}
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);
}
void CSectorEffector::se_mortimer_arm()
{
	int mx,my;

	switch(state)
	{
	case ARM_GO:
		// vertical arm 618 620 619
		// pole 597
		// polka dot background 169
		if (timer > ARM_MOVE_SPEED)
		{
			mx = getXPosition() >> CSF;
			my = getYPosition() >> CSF;

			if (dir==DOWN)
			{
				// reached bottom?
				if (mp_Map->at(mx, my+3) == 471)
				{
					timer = 0;
					state = ARM_WAIT;
				}
				else
				{
					// add to the pole
					mp_Map->setTile(mx, my+1, 597, true);
					// create left side of pincher
					mp_Map->setTile(mx-1, my+1, 618, true);
					mp_Map->setTile(mx-1, my+2, 620, true);
					mp_Map->setTile(mx-1, my+3, 619, true);
					// create right side of pincher
					mp_Map->setTile(mx+1, my+1, 618, true);
					mp_Map->setTile(mx+1, my+2, 620, true);
					mp_Map->setTile(mx+1, my+3, 619, true);
					// erase the top of the pincher we don't need anymore
					mp_Map->setTile(mx-1, my, 169, true);
					mp_Map->setTile(mx+1, my, 169, true);
					moveDown(1<<CSF);
				}
			}
			else
			{  // arm going up

				// reached top?
				if (mp_Map->at(mx, my+1)==619)
				{
					timer = 0;
					state = ARM_WAIT;
				}
				else
				{
					// create left side of pincher
					mp_Map->changeTile(mx-1, my+1, 618);
					mp_Map->changeTile(mx-1, my+2, 620);
					mp_Map->changeTile(mx-1, my+3, 619);
					// create right side of pincher
					mp_Map->changeTile(mx+1, my+1, 618);
					mp_Map->changeTile(mx+1, my+2, 620);
					mp_Map->changeTile(mx+1, my+3, 619);
					// erase the bottom of the pincher we don't need anymore
					mp_Map->changeTile(mx-1, my+4, 169);
					mp_Map->changeTile(mx+1, my+4, 169);
					// erase the pole
					mp_Map->changeTile(mx, my+2, 169);

					moveUp(1<<CSF);
				}
			}
			timer = 0;
		}
		else timer++;
Example #22
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 #23
0
void CVortiMom::process()
{
	int prob;

	if (touchPlayer && !m_Player[touchedBy].pdie)
	{
		// don't push the player as he's walking through the exit door
		if (!m_Player[touchedBy].level_done)
		{
			if (m_Player[touchedBy].getXPosition() < getXPosition())
				m_Player[touchedBy].push(*this);
			else
				m_Player[touchedBy].push(*this);
		}
	}


	switch(state)
	{
	case MOTHER_WALK:

		prob = (mp_Map->m_Difficulty>1) ? MOTHER_SPIT_PROB_HARD : MOTHER_SPIT_PROB;
		if (getProbability(prob))
		{
			if (onscreen)
			{
				if(dir == RIGHT)
					dir = LEFT;
				else
					dir = RIGHT;

				state = MOTHER_SPIT;
				timer = 0;
			}
		}

		if (dir==RIGHT)
		{
			sprite = MOTHER_WALK_RIGHT_FRAME + animframe;

			if (blockedr)
			{
				dir = LEFT;
			}
			else
			{
				xinertia = MOTHER_WALK_SPD;
			}
		}
		else
		{
			sprite = MOTHER_WALK_LEFT_FRAME + animframe;

			if (blockedl)
				dir = RIGHT;
			else
				xinertia = -MOTHER_WALK_SPD;
		}

		// walk animation
		if (animtimer > MOTHER_WALK_ANIM_RATE)
		{
			animframe ^= 1;
			animtimer = 0;
		}
		else animtimer++;

		break;

	case MOTHER_SPIT:
		sprite = (dir==RIGHT) ?
				MOTHER_SPIT_RIGHT_FRAME:MOTHER_SPIT_LEFT_FRAME;


		if (timer > MOTHER_SPIT_SHOW_TIME)
		{
			CFireBall *newobject = new CFireBall(mp_Map, getXMidPos()-(3<<STC),
												getYPosition()+(11<<STC), dir,
												OBJ_MOTHER, m_index);
			m_Object.push_back(newobject);

			if (onscreen) g_pSound->playStereofromCoord(SOUND_TANK_FIRE, PLAY_NOW, scrx);
			state = MOTHER_WALK;
		}
		else timer++;
		break;
	case MOTHER_HURT:

		sprite = MOTHER_HURT_FRAME;
		if (timer > MOTHER_HURT_SHOW_TIME)
		{
			if (HealthPoints <= 0)
			{
				sprite = MOTHER_DEAD_FRAME;
				dead = true;
				timer = 0;
				if (onscreen) g_pSound->playStereofromCoord(SOUND_VORT_DIE, PLAY_NOW, scrx);
			}
			else
			{
				state = MOTHER_WALK;
				if (m_Player[0].getXPosition() > getXPosition())
					dir = RIGHT;
				else
					dir = LEFT;
			}
		}
		else timer++;
		break;
	default: break;
	}
}
Example #24
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
}
Example #25
0
void CVortiNinja::process()
{
	bool onsamelevel;

	if (touchPlayer && !m_Player[touchedBy].pdie && \
			state != NINJA_DYING)
		m_Player[touchedBy].kill();

	if (HealthPoints <= 0 && !dying)
	{
		dying = true;
		dietimer = 0;
		playSound(SOUND_VORT_DIE);
	}


	if (dying)
	{
		if (state == NINJA_STAND)
			state = NINJA_DYING;

		dietimer++;
		if (dietimer > NINJA_DYING_SHOW_TIME)
		{
			sprite = NINJA_DEAD_FRAME;
			dead = true;
		}
	}

	switch(state)
	{

	case NINJA_STAND:
		if (m_Player[0].getXPosition() < getXPosition()+(8<<STC))
			dir = LEFT;
		else
			dir = RIGHT;

		if (!timetillkick)
		{
			state = NINJA_KICK;

			if (rnd()&1)
			{
				// high, short jump
				longjump = false;
				yinertia = -120;
			}
			else
			{
				// low, long jump
				longjump = true;
				yinertia = -30;
			}

		}
		else
		{
			// find out if a player is on the same level
			onsamelevel = false;

			std::vector<CPlayer>::iterator it_player = m_Player.begin();
			for( ; it_player != m_Player.end() ; it_player++ )
			{
				if ((it_player->getYPosition() >= getYPosition()-(96<<STC)) &&
					(it_player->getYDownPos() <= (getYDownPos()+(96<<STC))))
				{
					onsamelevel = true;
					break;
				}
			}

			if (onsamelevel)
				timetillkick--;
		}

		sprite = (dir==LEFT) ? NINJA_STAND_LEFT_FRAME : NINJA_STAND_RIGHT_FRAME;
		sprite += animframe;

		if (animtimer > NINJA_STAND_ANIM_RATE)
		{
			animframe ^= 1;
			animtimer = 0;
		}
		else
			animtimer++;
		break;

	case NINJA_KICK:
		if (!dying)
			sprite = (dir==LEFT) ? NINJA_KICK_LEFT_FRAME : NINJA_KICK_RIGHT_FRAME;
		else
			state = NINJA_DYING;

		if (blockedd && yinertia == 0)
		{
			if (!dying)
				init();
			else
				state = NINJA_DYING;

			break;
		}

		if(longjump)
			xinertia = (mp_Map->m_Difficulty>1) ? 150 : 120;
		else
			xinertia = (mp_Map->m_Difficulty>1) ? 95 : 75;

		if (dir==LEFT)
			xinertia = -xinertia;

		break;

	case NINJA_DYING:
		sprite = NINJA_DYING_FRAME;

		if (dietimer > NINJA_DYING_SHOW_TIME)
		{
			sprite = NINJA_DEAD_FRAME;
			dead = true;
		}
		break;
	default: break;
	}
}
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;
	}
}
Example #27
0
void CSpriteItem::getTouchedBy(CSpriteObject &theObject)
{
	if( CPlayerBase* pPlayer = dynamic_cast<CPlayerBase*>(&theObject) )
	{
		const int ep = g_pBehaviorEngine->getEpisode();
		stItemGalaxy &Item = pPlayer->m_Inventory.Item;
		
		int epOff = 0;
		if(ep == 5)
		{
		  epOff = -5;
		}
		else if(ep == 6)
		{
		  epOff = -1;
		}
		  
		int relBase = m_basesprite+epOff;		

		/// Calculate the right animation.
		// Point items
		Uint32 newanimsprite = got_sprite_item_pics[ep-4][0];
		if( relBase >= 103 && relBase <= 113 )
		{
			newanimsprite = got_sprite_item_pics[ep-4][4+(relBase-103)/2];
			switch(relBase)
			{
			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 );
		}
		
		// Check for the extra life
		if ( relBase == 115 )
		{
			newanimsprite = got_sprite_item_pics[ep-4][10];
			Item.m_lifes++;
			g_pSound->playSound( SOUND_EXTRA_LIFE );
		}		
		
		// keycard (Keen 5 only)
		if( ep == 5 && m_basesprite >= 105 && m_basesprite <= 106 )
		{
			Item.m_keycards++;
			newanimsprite = 231;
			g_pSound->playSound( SOUND_GET_CARD );
		}
				

		// Now add the stuff to the inventory
		if(ep == 5)
		{
		  epOff = -4;
		}
		else
		{
		  epOff = 0;
		}
		  
		relBase = m_basesprite+epOff;
		
		// raygun
		if( relBase >= 127 && relBase <= 128 )
		{
			Item.m_bullets += 5;
			newanimsprite = got_sprite_item_pics[ep-4][11];
			g_pSound->playSound( SOUND_GET_AMMO );
		}
		

		if( relBase >= 118 && relBase <= 125 )
		{
			switch(relBase)
			{
			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 );
		}
		
        spawnObj(new CItemEffect(mp_Map, 0, getXPosition(), getYPosition(), newanimsprite, FADEOUT));

		exists = false;
	}
}
Example #28
0
void Element::drawSelf()
{
    glRectf(getXPosition(), getYPosition(), getXPosition() + getWidth(), getYPosition() + getHeight());
}
Example #29
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 (mHealthPoints <= 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:

		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 if(mp_Map->m_Dark)
                {
                    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 if(mp_Map->m_Dark)
                {
                    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, CENTER, getSpriteVariantId());
			else
                newobject = new CRay(mp_Map, getXLeftPos()-1, getYPosition()+(9<<STC), LEFT, CENTER, getSpriteVariantId());
			newobject->setOwner( m_type, m_index);
			newobject->sprite = ENEMYRAYEP2;
			// don't shoot other vorticon elite
			spawnObj(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;
		}
		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;
	}
}