Example #1
0
void Enemy::Collided(GameObject *otherObject)
{
	if(otherObject->GetID() == PLAYER)
	{
		TakeLife();
		SetAlive(false);
	}

	if(otherObject->GetID() == BULLET){
		LoseHealth(otherObject->GetDamage());
		if(GetHealth() <= 0)
			SetAlive(false);
	}

}
void CCBManager::NonActivate(){
	for (int idx = 0; idx < CHOCO_NUM; idx++){
		m_Choco[idx].SetAlive(false);
		SINSTANCE(CShadowRender)->DeleteObject(&m_Choco[idx]);
	}
	SetAlive(false);
}
Example #3
0
void Tractor::Init(ALLEGRO_BITMAP *image)
{
	GameObject::Init(100, 100, 1, 1, 0, 0, 50, 50);

	SetID(TRACTOR);
	SetAlive(true);

	money = 50000;
	health = 2;
	fuel = 60;

	move = false;
	wasBlocked = false;
	action = false;

	frameWidth = 50;
	frameHeight = 50;
	
	for (int i = 0; i < 2; i++)
	{
		for (int j = 0; j < 5; j++)
			Supply[i][j] = 0;
	}

	Supply[2][0] = 11;
	Supply[2][1] = 13;
	Supply[2][2] = 15;
	Supply[2][3] = 14;
	Supply[2][4] = 14;

	if (image != NULL)
		Tractor::image = image;
	ResetPodpowiedz();
}
Example #4
0
int Ball::Update(){
    //if object is alive we update it 
    if(isAlive()){
        
        if(stand_on_platform){
            x = dynamic_cast<PlayingState*>(g_GamePtr->GetState())->GetPlatform()->GetX();
            y = dynamic_cast<PlayingState*>(g_GamePtr->GetState())->GetPlatform()->GetY()-15;
        }
        else{
            GameObject::Update();
            
            // we do a boundry checking
            if( x >= g_Game.GetScreen_W() -boundX || x<= boundX)
                dirX *= -1;
            else if( y <= boundY)
                dirY *= -1;
            else if ( y >= g_Game.GetScreen_H()){
                SetAlive(false);
                LoseEffect();
                Platform* platform = dynamic_cast<PlayingState*>(g_GamePtr->GetState())->GetPlatform();
                platform->LoseLife();
                platform->MorphPlatform(-1);            // calling platform to lose it's effect because ball has just died
            }
        }
        // we also update its animation if it exists
        if(animation) animation->Animate();
    }
    return 0;
}
Example #5
0
void Bullet::Collided(GameObject *otherObject){
	if(otherObject->GetID() == ENEMY){
		//switch(GetGun())
		//damage the enemy
		SetAlive(false);
	}
}
Example #6
0
File: Hero.cpp Project: Hiseen/HGE1
void Hero::ResetHero()
{
	SetPos(SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2);
	LV = 0;
	MAX_EXP = 20;
	EXP = 0;
	MAX_DEF = 10;
	MAX_MP = 10;
	SowrdCharge = 0.0;
	MAX_SC = 500;
	state = STAND;
	speedup = false;
	TargetX = GetX();
	TargetY = GetY();
	locked = false;
	Attack = 10;
	lives = 1;
	Isreborned = false;
	adddmg = 0;
	score = 0;
	peerless = false;
	peerless_time = 0;
	ShootCD = 15;
	battlestate = 0;
	bulletnum = 1;
	RageCountDown = 250;
	countaddMp = 200;
	bosskill = 0;
	kills = 0;
	modescore = 0;
	maxcombo = 0;
	itemget = 0;
	combo = 0;
	expadded = 0;
	bstats = no;
	varyHP(100);
	SetMaxHP(100);
	SetDEF(0);
	SetSpeed(SPEED);
	SetDMG(5);
	SetAlive(true);
	BeTheGod(250);
    bulletspeed = 800;
	SetExtraDMG(0);
	SetDelayrender(false);
	recoverMP = 175;
	SetMP(10);
	SetCrit(1);
	SetCritDMG(2);
	ResetBreakArmor();
	SetDodge(1);
	lvuprate = 1;
	magic = 0;
	atk = 0;
	dex = 0;
	knockback = 0;
	ObjectPool::GetObjPool().UnLockToken();
	ObjectPool::GetObjPool().GetSkillToken(LENSBULLET);
	SFXManager::GetSFXManager().PlaySFX(GETSKILLSFX);
}
void CUpFloor::Initialize(D3DXVECTOR3 pos, D3DXQUATERNION rot, D3DXVECTOR3 scale)
{
	strcpy(m_pFileName, "image/down_block.x");
	C3DImage::Initialize();

	m_transform.position = pos;
	StartPos = m_transform.position;
	m_transform.scale = scale;
	m_transform.angle = rot;

	if (scale.z != 1.0f){
		this->Build(D3DXVECTOR3(1.5f * scale.x, 0.3f * scale.y, 1.75f * scale.z), m_transform.position);
	}
	else{
		this->Build(D3DXVECTOR3(1.5f * scale.x, 0.3f * scale.y, 1.0f * scale.z), m_transform.position);
	}

	m_player = SINSTANCE(CObjectManager)->FindGameObject<CPlayer>(_T("TEST3D"));

	m_rigidBody->setActivationState(DISABLE_DEACTIVATION);

	SetAlive(true);
	m_IamFlgKeeper = false;
	C3DImage::SetImage();
}
Example #8
0
void CTurtle::Update(float fElapsedTime)
{
	m_vAnimations[m_nCurrAnimation].Update(fElapsedTime);
	if(GetExperience() >= (100 * GetLevel()))
	{
		CBattleMap::GetInstance()->PlaySFX(CAssets::GetInstance()->aBMcowabungaSnd);
		SetExperience(0/*GetExperience()-(100* GetLevel())*/);
		SetLevel(GetLevel() + 1);
		SetHealthMax((int)((float)GetMaxHealth() * 1.25f));
		SetHealth((int)((float)GetMaxHealth()));
		SetBaseAP(GetBaseAP()+2);
		SetStrength( (int)( (float)GetStrength() * 1.2f ) );
		SetDefense( (int) ( (float)GetDefense() * 1.2f ) );
		SetAccuracy( (int) ( (float)GetAccuracy() * 1.2f ) );
		SetSpeed( (int) ( (float)GetSpeed() * 1.2f ) );
	}
	if( GetHealth() <= 0)
	{
		if(GetAlive() == true)
		{
			CBattleMap::GetInstance()->DecrementNumChars();
			CBattleMap::GetInstance()->DecrementNumTurtles();
			CBattleMap::GetInstance()->SetTurtleDead();
			SetAlive(false);
			if(GetCurrAnimNum() != 9)
				SetCurrAnim(9);
			SetPosZ(0.9f);
		}
	}
}
Example #9
0
void Bullet::Collided(int objectID)
{
	if(objectID == ENEMY || objectID == BORDER)
		SetAlive(false);

	if(objectID == ENEMY)
		ScorePoint();
}
Example #10
0
void Brick::Update()
{
	//GameObject::Update();
	if(health<= 0)
	{
		ScorePoint();
		SetAlive(false);
	}
}
Example #11
0
//------------------------------- Spawn ---------------------------------------
//
//  spawns the bot at the given position
//-----------------------------------------------------------------------------
void Raven_Bot::Spawn(Vector2D pos)
{
    SetAlive();
    m_pBrain->RemoveAllSubgoals();
    m_pTargSys->ClearTarget();
    SetPos(pos);
    m_pWeaponSys->Initialize();
    RestoreHealthToMaximum();
}
Example #12
0
void Projectile::Collided(int ObjectID, col_dir dir){
    if(dir == NO_COLLISION)
        return;
    
    if(ObjectID == BLOCK){
        SetAlive(false);
        dynamic_cast<PlayingState*>(g_GamePtr->GetState())->GetPlatform()->AddPoint();
    }
}
/*
* Sets the states for particles
*
* @author Michael McQuarrie
*
* @return void
*/
bool
CFlagParticleEmitter::CheckAlive()
{
    for(std::vector<TParticle>::iterator iter = m_vecParticles.begin();
            iter != m_vecParticles.end(); ++iter)
    {
        if(iter->bAlive)
        {
            SetAlive(true);
            break;
        }
        else
        {
            SetAlive(false);
        }
    }

    return(IsAlive());
}
Example #14
0
void Moose::Update()
{
	Entity::Update();

	if (!mAlive)
		return;

	if (mAge > 40)
		SetAlive(false);

	mHungerTimer -= mApp->mTimeDelta;
	if (mHungerTimer < 0)
	{
		mHungerTimer = 1000;
		mHunger -= rand()%2 + 1;
		if (mHunger < 0)
			SetAlive(false);
	}
}
Example #15
0
void Asteroid::Collided(int objectID) {
	if (objectID == BORDER) {
		Asteroid::p->LoseLife();
	} else {
		//printf("asteroid collided with: %d \n", objectID);
	}

	if (objectID != ENEMY) {
		SetAlive(false);
	}
}
Example #16
0
void Platform::Init() {
    
    // Initializing ball
    GameObject::Init(g_Game.GetScreen_W()/2.0, g_Game.GetScreen_H() - 10 , 15, 0, 0, 0, animation->GetFrameWidth()/2, animation->GetFrameHeight()/2);
    
    SetAlive(true);
    
    lives = 5;
    score = 0;
    
}
Example #17
0
void Bullet::Update(GameObject *otherObject){
	if(GetAlive()){
		GameObject::Update(otherObject);


		//this needs to change depending on the gun
		distanceTraveled += vel;

		if(distanceTraveled > range)
			SetAlive(false);

		if(x < LEVEL_LEFT_X)
			SetAlive(false);
		else if(x > LEVEL_RIGHT_X)
			SetAlive(false);
		else if(y < LEVEL_TOP_Y)
			SetAlive(false);
		else if(y > LEVEL_BOT_Y)
			SetAlive(false);
	}
}
Example #18
0
Enemy::Enemy(float x, float y, void(*TakeLife)(void), int vel)
//Enemy::Enemy(float x, float y)
{
	SetID(ENEMY);
	SetAlive(true);
	health = 100;
	Enemy::vel = rand() % vel + 0.5;

	GameObject::Init(x, y, 0, 0, 1, 1, 0, 15, 15);

	Enemy::TakeLife = TakeLife;
}
Example #19
0
void player::Init(float x, float y){
	GameObject::Init(x, y, 2, 2, 0, 0, 0, 7, 7);

	SetID(PLAYER);
	SetAlive(true);

	lives = 10;
	score = 0;
	gun = PISTOL;
	ammo[PISTOL] = -1;
	ammo[SHOTGUN] = 0;
	ammo[RIFLE] = 0;
}
			shared_ptr<Projectile> Clone()
			{
				auto clone = make_shared<Projectile>(mId, mName, mFilename, mRef, mWpnId, mSpeed, mAimpointUpdateDelayMs, mCurrentAimpoint, mFinalAimpoint);
				clone->SetPosition(this->GetPosition());
				clone->SetVelocity(this->GetVelocity());
				clone->SetAlive(this->IsAlive());
				clone->SetColor(this->GetColor());
				clone->SetOrigin(this->GetOrigin());
				clone->SetRotation(this->GetRotation());
				clone->SetScale(this->GetScale().x, this->GetScale().y);
				clone->SetZOrder(this->GetZOrder());
				return clone;
			}
Example #21
0
void Ball::StartFlying(){
    

    // starting the ball, if it's not alive we dont allow for starting it again, until it dies
    if(!isAlive()){
        SetAlive(true);
        Init();
    }else if ( stand_on_platform){
        stand_on_platform = false;
        Update();                   //making sure that it will escape platform
    }

}
Example #22
0
Monster::Monster(const TYPE_OF_CHARACTER_ID &type, const position &newpos, SpawnPoint *spawnpoint) throw(unknownIDException)
    : Character(),lastTargetPosition(position(0,0,0)),lastTargetSeen(false), spawn(spawnpoint), monstertype(type) {

    if (monsteridc.get() == 0) {
        monsteridc.reset(new IdCounter(configOptions["monsteridc"], MONSTER_BASE));    // reset monster id to 0xBB000000
    }

    character = monster;
    id = monsteridc->nextFreeId();
    actionPoints = NP_MAX_AP;
    SetAlive(true);
    setType(type);
    pos=newpos;
}
Example #23
0
void Effect::Collided(int ObjectID, col_dir dir){
    
    if(dir == NO_COLLISION)
        return;
    
    if(ObjectID == PLAYER ){
        if( effect_type == MAGNET){
            PlayingState* ps = dynamic_cast<PlayingState*>(g_GamePtr->GetState());
            ps->GetPlatform()->MorphPlatform(effect_type);
            ps->GetBall()->MorphBall(effect_type);
            SetAlive(false);
        }else if ( effect_type == GUN ) {
            PlayingState* ps = dynamic_cast<PlayingState*>(g_GamePtr->GetState());
            ps->GetPlatform()->MorphPlatform(effect_type);
            SetAlive(false);

        }else if ( effect_type == SECONDBALL){
            dynamic_cast<PlayingState*>(g_GamePtr->GetState())->LaunchSecondBall();
            PlayingState* ps = dynamic_cast<PlayingState*>(g_GamePtr->GetState());
            ps->GetPlatform()->MorphPlatform(effect_type);
            SetAlive(false);
        }
    }
}
void CExplodingBullet::Update(float fDelta)
{
	float fRadius = GetSphere().m_Radius;
	fRadius += fDelta * m_fSpeed;

	if( fRadius > m_fMaxRadius )
	{
		CGame::GetInstance()->GetOF()->Destroy(this);
		SetAlive(false);
		m_lEnemies.clear();
		return;
	}

	SetRadius(fRadius);
}
Example #25
0
void
Platform::Init ()
{
  // Initializing ball
  GameObject::Init (static_cast<float>(g_Game.GetScreen_W ())/2.0F,
                    static_cast<float>(g_Game.GetScreen_H ())-10.0F,
                    15.0F,
                    0.0F,
                    0,
                    0,
                    static_cast<float>(animation->GetFrameWidth ())/2.0F,
                    static_cast<float>(animation->GetFrameHeight ())/2.0F);
  SetAlive (true);

  lives = 5;
  score = 0;
}
			void Update(sf::Time& deltaTime)
			{
				mTimeSinceLast = deltaTime.asMilliseconds() - mTimeSinceLast;

				sf::IntRect screen(0, 0, 1280, 720);
				if (!screen.contains((int)this->GetPosition().x, (int)this->GetPosition().y))
					SetAlive(false);

				if (mHasFired)
				{
					if (mElapsed > mAimpointUpdateDelayMs)
					{
						mCurrentAimpoint = mFinalAimpoint;
						mElapsed = 0;
						mAimpointUpdated = true;

						UpdateAngle();
					}
					else
					{
						mElapsed += mTimeSinceLast;
					}

					if ((GetRotation() > mDesiredAngle + 1) || (GetRotation() < mDesiredAngle - 1))
					{
						if (mGuidanceOn)
						{
							if (mDesiredAngle > GetRotation())
								SetRotation(GetRotation() + 0.25f);
							else
								SetRotation(GetRotation() - 0.25f);
						}
					}
					else
					{
						if (mAimpointUpdated)
							mGuidanceOn = false;
					}

					float velx = (float)(cos(Math::ToRadians(GetRotation() - 90.0f)) * mSpeed);
					float vely = (float)(sin(Math::ToRadians(GetRotation() - 90.0f)) * mSpeed);
					SetVelocity(sf::Vector2f(velx, vely));
				}

				Sprite::Update(deltaTime);
			}
Example #27
0
void CRealControlSocket::OnSend()
{
	if (m_pSendBuffer)
	{
		if (!m_nSendBufferLen)
		{
			delete [] m_pSendBuffer;
			m_pSendBuffer = 0;
			return;
		}

		int error;
		int written = m_pBackend->Write(m_pSendBuffer, m_nSendBufferLen, error);
		if (written < 0)
		{
			if (error != EAGAIN)
			{
				LogMessage(MessageType::Error, _("Could not write to socket: %s"), CSocket::GetErrorDescription(error));
				if (GetCurrentCommandId() != Command::connect)
					LogMessage(MessageType::Error, _("Disconnected from server"));
				DoClose();
			}
			return;
		}

		if (written)
		{
			SetAlive();
			m_pEngine->SetActive(CFileZillaEngine::send);
		}

		if (written == m_nSendBufferLen)
		{
			m_nSendBufferLen = 0;
			delete [] m_pSendBuffer;
			m_pSendBuffer = 0;
		}
		else
		{
			memmove(m_pSendBuffer, m_pSendBuffer + written, m_nSendBufferLen - written);
			m_nSendBufferLen -= written;
		}
	}
}
Example #28
0
void CSkyBox::Clear()
{
	//m_d3dxvPosition = D3DXVECTOR3(MONSTER_INIT_X, MONSTER_INIT_Y, MONSTER_INIT_Z);
	m_d3dxvRight = D3DXVECTOR3(1.0f, 0.0f, 0.0f);
	m_d3dxvUp = D3DXVECTOR3(0.0f, 1.0f, 0.0f);
	m_d3dxvLook = D3DXVECTOR3(0.0f, 0.0f, 1.0f);

	m_d3dxvVelocity = D3DXVECTOR3(0.0f, 0.0f, 0.0f);
	m_d3dxvGravity = D3DXVECTOR3(0.0f, 0.0f, 0.0f);
	m_fMaxVelocityXZ = 0.0f;
	m_fMaxVelocityY = 0.0f;
	m_fFriction = 0.0f;

	m_fPitch = 0.0f;
	m_fRoll = 0.0f;
	m_fYaw = 0.0f;

	SetAlive(false);
	// add hp, mp, etx
}
Example #29
0
Player::Player(bool alive, bool collidable, float x, float y, float x_vel, float y_vel, float x_dir, float y_dir, float x_bound, float y_bound, void* sprite_sheet) :
		sprite_row(0)
{
	SetID(peach::PLAYER);
	SetAlive(alive);
	SetCollidable(collidable);

	Player::x = x;
	Player::y = y;
	Player::x_vel = x_vel;
	Player::y_vel = y_vel;
	Player::x_dir = x_dir;
	Player::y_dir = y_dir;
	Player::x_bound = x_bound;
	Player::y_bound = y_bound;

	jumping = false;

	Player::sprite_sheet = sprite_sheet;
}
Example #30
0
void Player::Init()
{
	SetTag("Player");
	SetWidth(c_iPlayerWidth);
	SetHeight(c_iPlayerHeight);
	SetAlive(c_bPlayerAlive);
	SetPosition(c_v2DInitPlayerPos);
	SetSpriteID( CreateSprite( "./images/PlayerShip.png" , GetWidth(), GetHeight(), true));

	eCurrentWeapon = BULLET; //Start with standard Bullets

	m_iBulletTimer = 0;
	m_iMissileTimer = 0;
	m_iLaserTimer = 0;
	m_iBulletArrayPosition = c_iPlayerMaxBullets; // Currently Bullets should be [0] - [7]
	m_iMissileArrayPosition = m_iBulletArrayPosition + c_iPlayerMaxMissiles; // should be [8] - [10]
	m_iLaserArrayPosition = m_iMissileArrayPosition + c_iPlayerMaxLasers; // should be [11] -[21]
	m_iBulletAmmo = c_iPlayerMaxBullets;
	m_iMissileAmmo = c_iPlayerMaxMissiles;
	m_iLaserAmmo = c_iPlayerMaxLasers;

	//Bullets go in list first
	for(int i = c_iPlayerMaxBullets; i > 0; i--)
		 GetProjectiles().push_back(new Bullet);

	//Missiles next
	for(int i = m_iMissileArrayPosition; i > m_iBulletArrayPosition; i--)
		 GetProjectiles().push_back(new Missile);

	//Laser last
	for(int i = m_iLaserArrayPosition; i > m_iMissileArrayPosition; i--)
		 GetProjectiles().push_back(new Laser);

	//Init all owned Projectiles
	for(int i = 0; i <  GetProjectiles().size(); ++i)
	{
		 GetProjectiles()[i]->Init();
	}

	
}