Ejemplo n.º 1
0
TBool CHuiLayout::EffectIsAppliedToChildren() const
    {
    if (Effect() && !LoadingEffect() && !(Effect()->EffectFlags() & KHuiFxEffectExcludeChildrenFlag))
        {
        return ETrue;
        }
    else
        {
        return EFalse;
        }    
    }
Ejemplo n.º 2
0
static void
csound (unsigned char *message, int size)
{
  int             s;
  GETCHAR (message, s);
  Effect (s, next);
}
Ejemplo n.º 3
0
func Holde()
{
  Effect();
  if(! target)  { return(1); }
  target -> SetPosition(GetX(this())-78,GetY(this())-71);
  SetCategory(130);
  return(1);
}
Ejemplo n.º 4
0
// Create the char corpse when i die (STATF_DEAD) or fall asleep (STATF_Sleeping)
// Summoned (STATF_Conjured) and some others creatures have no corpse.
CItemCorpse * CChar::MakeCorpse( bool fFrontFall )
{
	ADDTOCALLSTACK("CChar::MakeCorpse");

	word wFlags = (word)(m_TagDefs.GetKeyNum("DEATHFLAGS", true));
	if (wFlags & DEATH_NOCORPSE)
		return( NULL );
	if (IsStatFlag(STATF_Conjured) && !(wFlags & (DEATH_NOCONJUREDEFFECT|DEATH_HASCORPSE)))
	{
		Effect(EFFECT_XYZ, ITEMID_FX_SPELL_FAIL, this, 1, 30);
		return( NULL );
	}

	CItemCorpse *pCorpse = dynamic_cast<CItemCorpse *>(CItem::CreateScript(ITEMID_CORPSE, this));
	if (pCorpse == NULL)	// weird internal error
		return( NULL );

	tchar *pszMsg = Str_GetTemp();
	sprintf(pszMsg, g_Cfg.GetDefaultMsg(DEFMSG_MSG_CORPSE_OF), GetName());
	pCorpse->SetName(pszMsg);
	pCorpse->SetHue(GetHue());
	pCorpse->SetCorpseType(GetDispID());
	pCorpse->SetAttr(ATTR_MOVE_NEVER);
	pCorpse->m_itCorpse.m_BaseID = m_prev_id;	// id the corpse type here !
	pCorpse->m_itCorpse.m_facing_dir = m_dirFace;
	pCorpse->m_uidLink = GetUID();

	// TO-DO: Fix corpses always turning to the same dir (DIR_N) after resend it to clients

	if (fFrontFall)
		pCorpse->m_itCorpse.m_facing_dir = static_cast<DIR_TYPE>(m_dirFace|0x80);

	int iDecayTimer = -1;	// never decay
	if (IsStatFlag(STATF_DEAD))
	{
		iDecayTimer = (m_pPlayer) ? g_Cfg.m_iDecay_CorpsePlayer : g_Cfg.m_iDecay_CorpseNPC;
		pCorpse->SetTimeStamp(CServerTime::GetCurrentTime().GetTimeRaw());	// death time
		if (Attacker_GetLast())
			pCorpse->m_itCorpse.m_uidKiller = Attacker_GetLast()->GetUID();
		else
			pCorpse->m_itCorpse.m_uidKiller.InitUID();
	}
	else	// sleeping (not dead)
	{
		pCorpse->SetTimeStamp(0);
		pCorpse->m_itCorpse.m_uidKiller = GetUID();
	}

	if ((m_pNPC && m_pNPC->m_bonded) || IsStatFlag(STATF_Conjured|STATF_Sleeping))
		pCorpse->m_itCorpse.m_carved = 1;	// corpse of bonded and summoned creatures (or sleeping players) can't be carved

	if ( !(wFlags & DEATH_NOLOOTDROP) )		// move non-newbie contents of the pack to corpse
		DropAll( pCorpse );

	pCorpse->SetKeyNum("OVERRIDE.MAXWEIGHT", g_Cfg.Calc_MaxCarryWeight(this) / 10);		// set corpse maxweight to prevent weird exploits like when someone place many items on an player corpse just to make this player get stuck on resurrect
	pCorpse->MoveToDecay(GetTopPoint(), iDecayTimer);
	return( pCorpse );
}
Ejemplo n.º 5
0
Action GameState::makeBind(int attId, int defId) const
{
    Action binder;
    binder.attacker = attId;
    binder.defender = defId;
    binder.type = ActionType::EFFECT;
    binder.effect = Effect(*this, binder, EffectType::BOUND);
    return binder;
}
Ejemplo n.º 6
0
Action GameState::makeRegeneration(int id) const
{
    const auto &target = getUnit(id);

    Action regen;
    regen.defender = target.entityId;
    regen.damage = target.hpLeft - target.type->hp;
    regen.type = ActionType::EFFECT;
    regen.effect = Effect(*this, regen, EffectType::HEAL);
    return regen;
}
Ejemplo n.º 7
0
void MechPart::applyDamage(int damage)
{
	int armorDamage = qMin(damage, armorValue);

	damage -= armorDamage;
	armorValue -= armorValue;

	internalValue = qMin(internalValue - damage, 0);

	if (internalValue == 0)
		addEffect(Effect(BTech::EffectType::Destroyed,
		                 BTech::EffectSource::Attack,
		                 Effect::FOREVER));
}
Ejemplo n.º 8
0
EXPORT_C void CHuiLayout::DrawSelf(CHuiGc& aGc, const TRect& aDisplayRect) const
    {
    if (( IsDelayedEffectSource()||Freezed() ) && StoredRenderBuffer())
        {
        DrawStoredBitmap(aGc);        
        return;
        }

    if( Effect() && EffectIsAppliedToChildren() )
        {
        // The layout itself is invisible. Only its children can be seen.
        TBool afterOthers = EFalse;
        const TInt count = Count();
        for(TInt i = 0; i < count; ++i)
            {
            CHuiVisual* visual = iHuiLayoutPrivateData->iChildren[i];
            //Ignore inactive child visuals
            if ( visual->Flags()& EHuiVisualFlagInactive )
                {
                continue; 
                }
            if(visual->Flags() & EHuiVisualFlagDrawAfterOthers)
                {
                afterOthers = ETrue;
                continue;
                }
                
            // @todo  No need to draw children that won't be visible.
            visual->Draw(aGc);
            }       
        if(afterOthers)
            {
            for(TInt i = 0; i < count; ++i)
                {
                if(iHuiLayoutPrivateData->iChildren[i]->Flags() & EHuiVisualFlagDrawAfterOthers)
                    {
                    iHuiLayoutPrivateData->iChildren[i]->Draw(aGc);        
                    }
                }
            }
        }
    else
        {
        CHuiVisual::DrawSelf(aGc, aDisplayRect);
        }
    }
Ejemplo n.º 9
0
void GameState::onStartTurn()
{
    auto &unit = getActiveUnit();
    assert(unit.isAlive());

    if (unit.hasTrait(Trait::REGENERATE) && unit.hpLeft < unit.type->hp) {
        auto regen = makeRegeneration(unit.entityId);
        runActionSeq(regen);
    }

    if (unit.effect.type != EffectType::NONE) {
        unit.effect.apply(*this, unit);
        if (unit.effect.isDone()) {
            unit.effect = Effect();
        }
    }
}
Ejemplo n.º 10
0
void Scene_Play::Update(Game* _game)
{	
	Player::Instance()->Update();
	m_hiphop1.Update();
	m_hiphop2.Update();
	m_hiphop3.Update();
	m_razer.update(500);
	m_leftHand.Update();
	m_rightHand.Update();
	
	DecreaseHpGage();
	StageStart();
	ChangeMusic();
	UI_Music_Check();
	Effect();

	if (m_screenDoor.GetCurrentFrame() != m_screenDoor.GetFrame())
	{
		m_screenDoor.update(200);
	}

	CreateZombie();

	for (int index = 0; index < m_currentZombie; ++index)
	{
		if (m_pzombie[index] == NULL)
			continue;

		m_pzombie[index]->Update();

		if (m_pzombie[index]->IsDeath())
		{
			_game->AddScore(m_pzombie[index]->GetScore());
			SAFE_DELETE(m_pzombie[index]);
			--m_currentZombie;
			++m_nKillZombie;
		}
	}

	_game->AddScore(m_currentStage);

	if (Player::Instance()->GetDeath())
		_game->ChangeScene(new Scene_Score());
	
}
Ejemplo n.º 11
0
Action GameState::makeAttack(int attId, int defId, int aMoveTgt) const
{
    const auto &attacker = getUnit(attId);
    const auto &defender = getUnit(defId);
    if (!attacker.isAlive() || !defender.isAlive()) return {};

    Action action;
    action.attacker = attId;
    action.defender = defId;
    action.aTgt = defender.aHex;

    bool attMoved = (aMoveTgt != attacker.aHex);

    if (!attMoved && isRangedAttackAllowed(attId, defId)) {
        action.type = ActionType::RANGED;
        return action;
    }
    if (!attMoved && isSpellAllowed(attId, defId)) {
        action.type = ActionType::EFFECT;
        action.damage = attacker.num * attacker.type->spell->damage;
        action.effect = Effect(*this, action, attacker.type->spell->effect);
        action.manaCost = attacker.type->spell->cost;
        return action;
    }

    bool isAdjacent = contains(grid_.aryNeighbors(aMoveTgt), defender.aHex);
    if (!isAdjacent || !isMeleeAttackAllowed(attId, defId)) {
        return {};
    }

    auto path = getPath(attacker, aMoveTgt);
    if (path.empty() || path.size() > attacker.getMaxPathSize()) {
        return {};
    }
    action.type = ActionType::ATTACK;
    action.path = path;
    return action;
}
Ejemplo n.º 12
0
bool hasIndex(ItemIndex index, const Item* item) {
  switch (index) {
    case ItemIndex::GOLD:
      return item->getClass() == ItemClass::GOLD;
    case ItemIndex::WOOD:
      return item->getResourceId() == CollectiveResourceId::WOOD;
    case ItemIndex::IRON:
      return item->getResourceId() == CollectiveResourceId::IRON;
    case ItemIndex::ADA:
      return item->getResourceId() == CollectiveResourceId::ADA;
    case ItemIndex::STONE:
      return item->getResourceId() == CollectiveResourceId::STONE;
    case ItemIndex::REVIVABLE_CORPSE: {
      auto corpseInfo = item->getCorpseInfo();
      return item->getClass() == ItemClass::CORPSE && corpseInfo && corpseInfo->canBeRevived;
    }
    case ItemIndex::WEAPON:
      return item->getClass() == ItemClass::WEAPON;
    case ItemIndex::TRAP:
      if (auto& effect = item->getEffect())
        return !!effect->getValueMaybe<Effect::PlaceFurniture>();
      return false;
    case ItemIndex::CORPSE:
      return item->getClass() == ItemClass::CORPSE;
    case ItemIndex::MINION_EQUIPMENT:
      return MinionEquipment::isItemUseful(item);
    case ItemIndex::RANGED_WEAPON:
      return item->getClass() == ItemClass::RANGED_WEAPON;
    case ItemIndex::CAN_EQUIP:
      return item->canEquip();
    case ItemIndex::FOR_SALE:
      return item->isOrWasForSale();
    case ItemIndex::HEALING_ITEM:
      return item->getEffect() == Effect(Effect::Heal{});
    case ItemIndex::RUNE:
      return !!item->getUpgradeInfo();
  }
}
Ejemplo n.º 13
0
bool Button::Action(Game_Manager* gm_)
{
	if(!valid)		
		return true;
	if(!on)
	{
		count++;
		if(count%50==0)
			Effect_switch(gm_,GetPos(),1.0f);

		for (auto & unit : gm_->unit_list)
		{
			if (unit->isPlayer() && unit->isLive())
			{
				if(unit->collution(GetPos(), 10) && !unit->GetNet())
				{
					Effect(gm_, reinterpret_cast<Player *>(unit));
				}				
			}
		}
	}
	return false;
}
Ejemplo n.º 14
0
EXPORT_C void CHuiLayout::Draw(CHuiGc& aGc) const
    {
    if (Flags() & EHuiVisualFlagDrawOnlyAsExternalContent)
    	{
   	    // This is used only as external content visual. Return now if we are not currently drawing
   	    // external content.
    	if (!Display() || !Display()->RosterImpl().IsDrawingExternalContent())
    		{
			return;
    		}
    	}

    if(iOpacity.Now() <= EPSILON && (Effect() && !Effect()->IsSemitransparent()))
        {
        // This will not be visible due to being completely transparent.
        return;
        }

    if (( IsDelayedEffectSource()||Freezed() ) && StoredRenderBuffer())
        {
        DrawStoredBitmap(aGc);        
        return;
        }
    if (!HasActiveChilderen() && !Brushes() && !Effect())
        {
        // No children, no brushes just return.
        return;            
        }
    
    
    /** @todo  Wouldn't it be possible to just extend CHuiVisual::Draw()
               instead of redefining the entire method? */

    THuiRealRect area = DisplayRect();

    // Apply local transformation.
    EnterLocalProjection(aGc, ETrue, 0.f, &area);
    Transform(aGc, ETrue, &area);

    DrawBrushes(aGc, EHuiBrushLayerBackground);

    if(Clipping())
        {
        // @todo  Clipping not going to work if there is a transformation?
        // Layout clipping is not affected by transformation.
        aGc.Enable(CHuiGc::EFeatureClipping);
        aGc.PushClip();
        aGc.Clip(area);
        }

    // Can we draw effect
    TBool canUseEffectDrawing = Effect() && !LoadingEffect();

    // Flag to know what we did
    TBool didDrawEffect = EFalse;
    
    if (canUseEffectDrawing)
        {
        // Note that EHuiVisualFlagOpaqueHint improves performance a lot in cached effect drawing 
        TBool transparent = !(Flags() & EHuiVisualFlagOpaqueHint) && iOpacity.Now() < 1.0f;
        TBool refreshCache = Changed();                
        didDrawEffect =  Effect()->CachedDraw(aGc, area, refreshCache, !transparent);
        }
    
    if ( !didDrawEffect )
        {
        // huilayout does not draw itself, only children.
        }
    else
        {
        // Effect was drawn, OpenGLES/OpenVG may be in different state than what Gc thinks so we restore it.
        aGc.RestoreState();        
        }
    
    if ( !didDrawEffect || (didDrawEffect && !EffectIsAppliedToChildren()))
        {
        // The layout itself is invisible. Only its children can be seen.
        TBool afterOthers = EFalse;
        const TInt count = Count();
        for(TInt i = 0; i < count; ++i)
            {
            CHuiVisual* visual = iHuiLayoutPrivateData->iChildren[i];
            //Ignore inactive child visuals
            if ( visual->Flags()& EHuiVisualFlagInactive )
                {
                continue; 
                }
            if(visual->Flags() & EHuiVisualFlagDrawAfterOthers)
                {
                afterOthers = ETrue;
                continue;
                }

            // @todo  No need to draw children that won't be visible.
            visual->Draw(aGc);
            }       
        if(afterOthers)
            {
            for(TInt i = 0; i < count; ++i)
                {
                if(iHuiLayoutPrivateData->iChildren[i]->Flags() & EHuiVisualFlagDrawAfterOthers)
                    {
                    iHuiLayoutPrivateData->iChildren[i]->Draw(aGc);        
                    }
                }
            }
        }


    if(Clipping())
        {
        // Restore original clipping rectangle.
        aGc.PopClip();
        }


    DrawBrushes(aGc, EHuiBrushLayerForeground);

    // Restore original transformation.
    Transform(aGc, EFalse);
    EnterLocalProjection(aGc, EFalse);
    }
Ejemplo n.º 15
0
void SoundCtrl::quit() {
    auto mMusic = Music(nullptr, Mix_FreeMusic);
    auto mEffect = Effect(nullptr, Mix_FreeChunk);
}
Ejemplo n.º 16
0
Effect::Effect(std::string vs, std::string fs){
	Effect();
	setShaderProgram(vs, fs);
}
Ejemplo n.º 17
0
Effect::Effect(Preset p){
	Effect();
	setPreset(p);
}
Ejemplo n.º 18
0
void E_HandleCommand(HWND dialog, WORD id, WORD code, HWND control)
{
	/* Most of them use this */
	class EditEffect *data = (EditEffect*)GetWindowLongPtr(dialog, DWLP_USER);

	switch (code)
	{
	case BN_CLICKED:
		switch (id)
		{
		case IDC_E_AREA_ALL:
			{
				SetDlgItemInt(dialog, IDC_E_AREAX1, -1, TRUE);
				SetDlgItemInt(dialog, IDC_E_AREAY1, -1, TRUE);
				SetDlgItemInt(dialog, IDC_E_AREAX2, -1, TRUE);
				SetDlgItemInt(dialog, IDC_E_AREAY2, -1, TRUE);
			}
			break;

		case IDC_E_CLEAR:
			{
			    data->e = Effect();
			    LoadEffect(dialog, data);
			}
			break;

		case IDOK:
			{
				bool valid;
				int ret = IDOK;

				SaveEffect(dialog, data);
				valid = data->e.check();

				if (!valid)
					ret = MessageBox(dialog, warnInvalidE, "Effect Editor", MB_OKCANCEL);

				if (ret == IDOK)
				{
					SendMessage(data->parent, EC_Closing,
						MAKELONG(1, valid), reinterpret_cast<LPARAM>(data));
					DestroyWindow(dialog);
				}
			}
			break;

		case IDCANCEL:
			SendMessage(data->parent, EC_Closing,
				0, reinterpret_cast<LPARAM>(data));
			DestroyWindow(dialog);
			break;

		case IDC_E_OPENSEL:
			OnOpenSel(dialog, data);
			break;

		case IDC_E_OPENSEL2:
			if (SingleUnitSelDialogBox(dialog, data->players,
				data->e.uid_loc, (data->e.uid_loc != -1)))
			{
				SetDlgItemInt(dialog, IDC_E_LOCUID, data->e.uid_loc, FALSE);
			}
			break;

		}
		break;

	case CBN_SELCHANGE:
		switch (id)
		{
			case IDC_E_TYPE:
				E_HandleChangeType(dialog, data);
				break;

			case IDC_E_VTYPE:
				E_HandleChangeVType(dialog, data);
				break;

			case IDC_E_RESTYPE:
				if (SendMessage(control, CB_GETCURSEL, 0, 0) >= NUM_STYPES &&
					setts.warnbits & WARN_WEIRDRESOURCE)
					MessageBox(dialog, warnWeirdResource, "Warning", MB_ICONWARNING);
				break;

			case IDC_E_TRIG:
				SetDlgItemInt(dialog, IDC_E_TRIGID, data->e.trig_index, TRUE);
				break;
		}
		break;

	case EN_SETFOCUS:
		E_HandleSetFocus(dialog, id);
		break;

	case EN_KILLFOCUS:
		E_HandleKillFocus(dialog, id);
		break;
	}
}
Ejemplo n.º 19
0
void AFastProjectile::Tick ()
{
	int i;
	DVector3 frac;
	int changexy;

	ClearInterpolation();
	double oldz = Z();

	if (!(flags5 & MF5_NOTIMEFREEZE))
	{
		//Added by MC: Freeze mode.
		if (bglobal.freeze || level.flags2 & LEVEL2_FROZEN)
		{
			return;
		}
	}


	// [RH] Ripping is a little different than it was in Hexen
	FCheckPosition tm(!!(flags2 & MF2_RIP));

	int count = 8;
	if (radius > 0)
	{
		while ( fabs(Vel.X) > radius * count || fabs(Vel.Y) > radius * count)
		{
			// we need to take smaller steps.
			count += count;
		}
	}

	// Handle movement
	if (!Vel.isZero() || (Z() != floorz))
	{
		// force some lateral movement so that collision detection works as intended.
		if ((flags & MF_MISSILE) && Vel.X == 0 && Vel.Y == 0 && !IsZeroDamage())
		{
			Vel.X = MinVel;
		}

		frac = Vel / count;
		changexy = frac.X != 0 || frac.Y != 0;
		int ripcount = count / 8;
		for (i = 0; i < count; i++)
		{
			if (changexy)
			{
				if (--ripcount <= 0)
				{
					tm.LastRipped.Clear();	// [RH] Do rip damage each step, like Hexen
				}
				
				if (!P_TryMove (this, Pos() + frac, true, NULL, tm))
				{ // Blocked move
					if (!(flags3 & MF3_SKYEXPLODE))
					{
						if (tm.ceilingline &&
							tm.ceilingline->backsector &&
							tm.ceilingline->backsector->GetTexture(sector_t::ceiling) == skyflatnum &&
							Z() >= tm.ceilingline->backsector->ceilingplane.ZatPoint(PosRelative(tm.ceilingline)))
						{
							// Hack to prevent missiles exploding against the sky.
							// Does not handle sky floors.
							Destroy ();
							return;
						}
						// [RH] Don't explode on horizon lines.
						if (BlockingLine != NULL && BlockingLine->special == Line_Horizon)
						{
							Destroy ();
							return;
						}
					}

					P_ExplodeMissile (this, BlockingLine, BlockingMobj);
					return;
				}
			}
			AddZ(frac.Z);
			UpdateWaterLevel ();
			oldz = Z();
			if (oldz <= floorz)
			{ // Hit the floor

				if (floorpic == skyflatnum && !(flags3 & MF3_SKYEXPLODE))
				{
					// [RH] Just remove the missile without exploding it
					//		if this is a sky floor.
					Destroy ();
					return;
				}

				SetZ(floorz);
				P_HitFloor (this);
				P_ExplodeMissile (this, NULL, NULL);
				return;
			}
			if (Top() > ceilingz)
			{ // Hit the ceiling

				if (ceilingpic == skyflatnum &&  !(flags3 & MF3_SKYEXPLODE))
				{
					Destroy ();
					return;
				}

				SetZ(ceilingz - Height);
				P_ExplodeMissile (this, NULL, NULL);
				return;
			}
			if (!frac.isZero() && ripcount <= 0) 
			{
				ripcount = count >> 3;
				Effect();
			}
		}
	}
Ejemplo n.º 20
0
Effect QEmitterNode::effect() const
{
	return Effect(m_xmlNode.attribute("particleEffect"));
}
Ejemplo n.º 21
0
/* ConfirmSellItem is called when client recieves ok from server */
T_void StoreConfirmSellItem (T_void)
{
    T_word32 amount;
    T_byte8 stmp[64];
    T_byte8 stmp2[16];
    T_3dObject *p_obj;
    T_inventoryItemStruct *p_inv;

    DebugRoutine ("StoreConfirmSellItem");
    DebugCheck (G_itemToSell != NULL);

    /* move the item from the store inventory to the
       player inventory */
//    if (G_itemToSell->numitems > 1)
//    {
        if (G_itemToSell->itemdesc.type==EQUIP_OBJECT_TYPE_QUIVER)
        {
            /* don't make a new item */
            /* just add 12 arrows */
            Effect (EFFECT_TAKE_AMMO,
                    EFFECT_TRIGGER_GET,
                    G_itemToSell->itemdesc.subtype,
                    12,
                    0,
                    G_itemToSell->object);
        }
        else
        {
            p_obj=ObjectCreateFake();
            DebugCheck (p_obj != NULL);

            ObjectSetType (p_obj,ObjectGetType(G_itemToSell->object));
            ObjectSetAngle (p_obj,0x4000);

            p_inv=InventoryTakeObject (INVENTORY_PLAYER,p_obj);
            /* set 'quick pointer' for mouse hand */
            InventorySetMouseHandPointer (p_inv->elementID);
            InventoryDoEffect(EFFECT_TRIGGER_GET,EQUIP_LOCATION_MOUSE_HAND);
        }

        /* identify arrow type for player */
        StatsPlayerIdentify(ObjectGetType(G_itemToSell->object));

        /* force mouse hand picture update */
//      ControlSetObjectPointer (p_inv->object);
//        StatsChangePlayerLoad(ObjectGetWeight(G_itemToSell->object));
//      G_itemToSell->numitems--;
//    }
//    else
//    {
//        element=InventoryTransferItemBetweenInventories(
//                  G_itemToSell,
//                  INVENTORY_STORE,
//                  INVENTORY_PLAYER);

//        DebugCheck (element != DOUBLE_LINK_LIST_ELEMENT_BAD);
        /* set the mouse hand pointer */
//        InventorySetMouseHandPointer (element);
//    }

    if (G_houseMode==FALSE)
    {
        /* go ahead and sell the item to the player */
        /* subtract the cost of this item */
        if (EffectPlayerEffectIsActive(PLAYER_EFFECT_GOD_MODE)==FALSE)
        {
            amount=ObjectGetValue(G_itemToSell->object);
            StoreConvertCurrencyToString (stmp,amount);
            if (G_itemToSell->itemdesc.type==EQUIP_OBJECT_TYPE_QUIVER)
            {
                switch (G_itemToSell->itemdesc.subtype)
                {
                    case BOLT_TYPE_NORMAL:
                    strcpy (stmp2,"normal");
                    break;
                    case BOLT_TYPE_POISON:
                    strcpy (stmp2,"green");
                    break;
                    case BOLT_TYPE_PIERCING:
                    strcpy (stmp2,"brown");
                    break;
                    case BOLT_TYPE_FIRE:
                    strcpy (stmp2,"red");
                    break;
                    case BOLT_TYPE_ELECTRICITY:
                    strcpy (stmp2,"yellow");
                    break;
                    case BOLT_TYPE_MANA_DRAIN:
                    strcpy (stmp2,"purple");
                    break;
                    case BOLT_TYPE_ACID:
                    strcpy (stmp2,"white");
                    break;
                    default:
                    DebugCheck (0); /* bad bolt! */
                    break;
                }
                MessagePrintf ("^009You bought 12 %s arrows for %s",stmp2,stmp);
            }
            else MessagePrintf ("^009Sold!! for %s",stmp);
            StatsChangePlayerTotalCarriedWealth(-(T_sword32)amount);
        }
        else
        {
            MessageAdd ("^009Well... You're a god... it's free.");
        }
//        StoreUIUpdateGraphics();

    }

    /* resort the inventory */
    InventoryReorder (INVENTORY_STORE,TRUE);

    /* redraw the inventory window */
    InventoryDrawInventoryWindow(INVENTORY_STORE);

    G_itemToSell=NULL;

    DebugEnd();
}
Ejemplo n.º 22
0
bool CChar::NPC_OnHearPetCmd(LPCTSTR pszCmd, CChar *pSrc, bool bAllPets)
{
	ADDTOCALLSTACK("CChar::NPC_OnHearPetCmd");
	// This should just be another speech block !!!

	// We own this char (pet or hireling)
	// pObjTarget = the m_ActTarg has been set for them to attack.
	// RETURN:
	//  true = we understand this. tho we may not do what we are told.
	//  false = this is not a command we know.
	//  if ( GetTargMode() == CLIMODE_TARG_PET_CMD ) it needs a target.

	if ( !m_pNPC || !pSrc->m_pClient )
		return false;

	m_fIgnoreNextPetCmd = false;	// we clear this incase it's true from previous pet commands
	TALKMODE_TYPE mode = TALKMODE_SAY;
	if ( OnTriggerSpeech(true, pszCmd, pSrc, mode) )
	{
		m_fIgnoreNextPetCmd = !bAllPets;
		return true;
	}

	if ((m_pNPC->m_Brain == NPCBRAIN_BERSERK) && !pSrc->IsPriv(PRIV_GM))
		return false;	// Berserk npcs do not listen to any command (except if src is a GM)

	static LPCTSTR const sm_PetCommands[] =
	{
		"ATTACK",
		"BOUGHT",
		"CASH",
		"COME",
		"DROP",
		"DROP ALL",
		"EQUIP",
		"FOLLOW",
		"FOLLOW ME",
		"FRIEND",
		"GO",
		"GUARD",
		"GUARD ME",
		"KILL",
		"PRICE",
		"RELEASE",
		"SAMPLES",
		"SPEAK",
		"STATUS",
		"STAY",
		"STOCK",
		"STOP",
		"TRANSFER",
		"UNFRIEND"
	};

	PC_TYPE iCmd = static_cast<PC_TYPE>(FindTableSorted(pszCmd, sm_PetCommands, COUNTOF(sm_PetCommands)));
	if ( iCmd < 0 )
	{
		if ( !strnicmp(pszCmd, sm_PetCommands[PC_PRICE], 5) )
			iCmd = PC_PRICE;
		else
			return false;
	}

	if ( !NPC_PetCheckAccess(iCmd, pSrc) )
		return true;

	bool bTargAllowGround = false;
	bool bCheckCrime = false;
	LPCTSTR pTargPrompt = NULL;
	CCharBase *pCharDef = Char_GetDef();

	switch ( iCmd )
	{
		case PC_ATTACK:
		case PC_KILL:
			pTargPrompt = g_Cfg.GetDefaultMsg(DEFMSG_NPC_PET_TARG_ATT);
			bCheckCrime = true;
			break;

		case PC_COME:
		case PC_FOLLOW_ME:
			NPC_OnHearPetCmdTarg(PC_FOLLOW, pSrc, pSrc, NULL, NULL);
			break;

		case PC_FOLLOW:
			pTargPrompt = g_Cfg.GetDefaultMsg(DEFMSG_NPC_PET_TARG_FOLLOW);
			break;

		case PC_FRIEND:
			if ( IsStatFlag(STATF_Conjured) )
			{
				pSrc->SysMessage(g_Cfg.GetDefaultMsg(DEFMSG_NPC_PET_TARG_FRIEND_SUMMONED));
				return false;
			}
			pTargPrompt = g_Cfg.GetDefaultMsg(DEFMSG_NPC_PET_TARG_FRIEND);
			break;

		case PC_UNFRIEND:
			pTargPrompt = g_Cfg.GetDefaultMsg(DEFMSG_NPC_PET_TARG_UNFRIEND);
			break;

		case PC_GO:
			pTargPrompt = g_Cfg.GetDefaultMsg(DEFMSG_NPC_PET_TARG_GO);
			bTargAllowGround = true;
			break;

		case PC_GUARD:
			pTargPrompt = g_Cfg.GetDefaultMsg(DEFMSG_NPC_PET_TARG_GUARD);
			bCheckCrime = true;
			break;

		case PC_GUARD_ME:
			NPC_OnHearPetCmdTarg(PC_GUARD, pSrc, pSrc, NULL, NULL);
			break;

		case PC_STAY:
		case PC_STOP:
			Skill_Start(NPCACT_STAY);
			break;

		case PC_TRANSFER:
			if ( IsStatFlag(STATF_Conjured) )
			{
				pSrc->SysMessage(g_Cfg.GetDefaultMsg(DEFMSG_NPC_PET_TARG_TRANSFER_SUMMONED));
				return true;
			}
			pTargPrompt = g_Cfg.GetDefaultMsg(DEFMSG_NPC_PET_TARG_TRANSFER);
			break;

		case PC_RELEASE:
			if ( IsStatFlag(STATF_Conjured) || (m_pNPC->m_bonded && IsStatFlag(STATF_DEAD)) )
			{
				Effect(EFFECT_XYZ, ITEMID_FX_TELE_VANISH, this, 10, 15);
				Sound(SOUND_TELEPORT);
				Delete();
				return true;
			}
			SoundChar(CRESND_NOTICE);
			Skill_Start(SKILL_NONE);
			NPC_PetClearOwners();
			ResendTooltip();
			break;

		case PC_DROP:
		{
			// Drop backpack items on ground
			// NOTE: This is also called on pet release
			CItemContainer *pPack = GetContainer(LAYER_PACK);
			if ( pPack )
			{
				pPack->ContentsDump(GetTopPoint(), ATTR_OWNED);
				break;
			}
			if ( NPC_CanSpeak() )
				Speak(g_Cfg.GetDefaultMsg(DEFMSG_NPC_PET_CARRYNOTHING));
			return true;
		}

		case PC_DROP_ALL:
			DropAll(NULL, ATTR_OWNED);
			break;

		case PC_SPEAK:
			NPC_PetConfirmCommand(true, pSrc);
			return true;

		case PC_EQUIP:
			ItemEquipWeapon(false);
			ItemEquipArmor(false);
			break;

		case PC_STATUS:
		{
			if ( !NPC_CanSpeak() )
				break;

			CItemContainer *pBank = GetContainerCreate(LAYER_BANKBOX);
			TCHAR *pszMsg = Str_GetTemp();
			if ( NPC_IsVendor() )
			{
				CItemContainer *pCont = GetContainerCreate(LAYER_VENDOR_STOCK);
				TCHAR *pszTemp1 = Str_GetTemp();
				TCHAR *pszTemp2 = Str_GetTemp();
				TCHAR *pszTemp3 = Str_GetTemp();
				if ( pCharDef->m_iHireDayWage )
				{
					sprintf(pszTemp1, g_Cfg.GetDefaultMsg(DEFMSG_NPC_VENDOR_STAT_GOLD_1), pBank->m_itEqBankBox.m_Check_Amount);
					sprintf(pszTemp2, g_Cfg.GetDefaultMsg(DEFMSG_NPC_VENDOR_STAT_GOLD_2), pBank->m_itEqBankBox.m_Check_Amount / pCharDef->m_iHireDayWage);
					sprintf(pszTemp3, g_Cfg.GetDefaultMsg(DEFMSG_NPC_VENDOR_STAT_GOLD_3), static_cast<int>(pCont->GetCount()));
				}
				else
				{
					sprintf(pszTemp1, g_Cfg.GetDefaultMsg(DEFMSG_NPC_VENDOR_STAT_GOLD_1), pBank->m_itEqBankBox.m_Check_Amount);
					sprintf(pszTemp2, g_Cfg.GetDefaultMsg(DEFMSG_NPC_VENDOR_STAT_GOLD_4), pBank->m_itEqBankBox.m_Check_Restock, pBank->GetTimerAdjusted() / 60);
					sprintf(pszTemp3, g_Cfg.GetDefaultMsg(DEFMSG_NPC_VENDOR_STAT_GOLD_3), static_cast<int>(pCont->GetCount()));
				}
				sprintf(pszMsg, "%s %s %s", pszTemp1, pszTemp2, pszTemp3);
			}
			else if ( pCharDef->m_iHireDayWage )
			{
				sprintf(pszMsg, g_Cfg.GetDefaultMsg(DEFMSG_NPC_PET_DAYS_LEFT), pBank->m_itEqBankBox.m_Check_Amount / pCharDef->m_iHireDayWage);
			}
			Speak(pszMsg);
			return true;
		}

		case PC_CASH:
		{
			// Give up my cash total.
			if ( !NPC_IsVendor() )
				return false;

			CItemContainer *pBank = GetContainerCreate(LAYER_BANKBOX);
			if ( pBank )
			{
				TCHAR *pszMsg = Str_GetTemp();
				if ( pBank->m_itEqBankBox.m_Check_Amount > pCharDef->m_iHireDayWage )
				{
					sprintf(pszMsg, g_Cfg.GetDefaultMsg(DEFMSG_NPC_PET_GETGOLD_1), pBank->m_itEqBankBox.m_Check_Amount - pCharDef->m_iHireDayWage);
					pSrc->AddGoldToPack(pBank->m_itEqBankBox.m_Check_Amount - pCharDef->m_iHireDayWage);
					pBank->m_itEqBankBox.m_Check_Amount = pCharDef->m_iHireDayWage;
				}
				else
					sprintf(pszMsg, g_Cfg.GetDefaultMsg(DEFMSG_NPC_PET_GETGOLD_2), pBank->m_itEqBankBox.m_Check_Amount);
				Speak(pszMsg);
			}
			return true;
		}

		case PC_BOUGHT:
			if ( !NPC_IsVendor() )
				return false;
			Speak(g_Cfg.GetDefaultMsg(DEFMSG_NPC_PET_ITEMS_BUY));
			pSrc->m_pClient->addBankOpen(this, LAYER_VENDOR_EXTRA);
			break;

		case PC_PRICE:
			if ( !NPC_IsVendor() )
				return false;
			pTargPrompt = g_Cfg.GetDefaultMsg(DEFMSG_NPC_PET_SETPRICE);
			break;

		case PC_SAMPLES:
			if ( !NPC_IsVendor() )
				return false;
			Speak(g_Cfg.GetDefaultMsg(DEFMSG_NPC_PET_ITEMS_SAMPLE));
			pSrc->m_pClient->addBankOpen(this, LAYER_VENDOR_BUYS);
			break;

		case PC_STOCK:
			// Magic restocking container.
			if ( !NPC_IsVendor() )
				return false;
			Speak(g_Cfg.GetDefaultMsg(DEFMSG_NPC_PET_ITEMS_SELL));
			pSrc->m_pClient->addBankOpen(this, LAYER_VENDOR_STOCK);
			break;

		default:
			return false;
	}

	if ( pTargPrompt )
	{
		pszCmd += strlen(sm_PetCommands[iCmd]);
		GETNONWHITESPACE(pszCmd);
		pSrc->m_pClient->m_tmPetCmd.m_iCmd = iCmd;
		pSrc->m_pClient->m_tmPetCmd.m_fAllPets = bAllPets;
		pSrc->m_pClient->m_Targ_UID = GetUID();
		pSrc->m_pClient->m_Targ_Text = pszCmd;
		pSrc->m_pClient->addTarget(CLIMODE_TARG_PET_CMD, pTargPrompt, bTargAllowGround, bCheckCrime);
		return true;
	}

	// Make some sound to confirm we heard it
	NPC_PetConfirmCommand(true, pSrc);
	return true;
}
/* ----------------------------------------------------------------------
 * Author: Julian
 * Date: 27 January 2014
 * Description: Handles the commands
 * ----------------------------------------------------------------------
 */
void Console::newCommand(std::string command, std::string values)
{
	std::transform(command.begin(), command.end(), command.begin(), ::tolower);
	std::vector<std::string> valueList;
	getValues(valueList, values, command);

//==========================================================================================================================
	if(command == "clear_console" ||										// clear_console
		command == "clean_console")											// clean_console
		clearAll();

//==========================================================================================================================
	else if(command == "exit")												// exit
		context.renderWindow->close();
//==========================================================================================================================
	else if(command == "player_set_position")								// player_set_position x:y
	{
		if(valueList.size() == 2)
		{
			const float xPos = stof(valueList[0]);
			const float yPos = stof(valueList[1]);

			context.player->setPosition(xPos, yPos);

			logInfo("Changed Player position to " + valueList[0] + " : " + valueList[1]);
		}
		else
			logError("Syntax is: player_set_position x:y");
	}
//==========================================================================================================================
	else if(command == "player_set_speed")									// player_set_animation value
	{
		if(valueList.size() == 1)
		{
			context.player->setDefaultSpeed(stoi(valueList[0]));
			logInfo("Changed Player velocity to: " + valueList[0]);
		}
		else
			logError("Syntax is: player_set_speed value");
	}
//==========================================================================================================================
	else if(command == "player_play_animation")								// player_play_animation value
	{
		if(valueList.size() == 1 && stoi(valueList[0]) <= TOTAL_ANIMATIONS)
			context.player->playAnimationOnce(stoi(valueList[0]));
		else if(valueList.size() == 1 && stoi(valueList[0]) == TOTAL_ANIMATIONS)
			logError("Your value is too large.");
		else
			logError("Syntax is: player_set_animation value");
	}
//==========================================================================================================================
	else if(command == "player_set_health")									// player_set_health value
	{
		if(valueList.size() == 1)
			context.player->setHealth(stoi(valueList[0]));
		else
			logError("Syntax is: player_set_health value");
	}
//==========================================================================================================================
	else if(command == "show_collision")									// show_collision value
	{
		if(valueList.size() == 1)
			context.player->showCollision(stoi(valueList[0]) !=0); // The !=0 is there in order to prevent a warning, ignore it
		else
			logError("Syntax is: show_collision value (1 or 0)");
	}
//==========================================================================================================================
	else if(command == "player_set_mana")									// player_set_mana value
	{
		if(valueList.size() == 1)
			context.player->setMana(stoi(valueList[0]));
		else
			logError("Syntax is: player_set_mana value");
	}
//==========================================================================================================================
	else if(command == "player_get_position")								// player_get_position
	{
		std::stringstream s, s2;

		s << context.player->getPosition().x / TILE_SIZE;
		s2 << (context.player->getPosition().y - TILE_SIZE/2) / TILE_SIZE;

		logInfo("You are at " + s.str() + ":" + s2.str());
	}
//==========================================================================================================================
	else if(command == "GFX_add" || command == "gfx_add")					// GFX_add
	{
		if(valueList.size() == 1)
		{
			if(valueList[0] == "fade")
				context.effectManager->add(Effect(EffectType::FADE));
		}
		else
			logError("Syntax is: GFX_add value (fade for example)");
	}
//==========================================================================================================================
	else if(command == "time_set")											// time_set
	{
		if(valueList.size() == 3)
		{
			context.globalTime->setTime(std::stoi(valueList[0]), std::stoi(valueList[1]), std::stof(valueList[2]));
			std::stringstream stream;
			stream<<"Current time: "<<context.globalTime->getHours()<<":"<<context.globalTime->getMinutes()<<":"<<int(context.globalTime->getSeconds());
			logInfo(stream.str());
		}
		else
			logError("Syntax is: time_set hours:minutes:seconds");
	}
//==========================================================================================================================
	else if(command == "print")											// print
	{
		if(valueList.size() == 1)
			logInfo(valueList[0]);
		else
			logError("Syntax is: print message");
	}
//==========================================================================================================================
	else if(command == "print_time")											// print_time
	{
		if(valueList.size() == 0)
		{
			std::stringstream stream;
			stream<<"Current time: "<<context.globalTime->getHours()<<":"<<context.globalTime->getMinutes()<<":"<<int(context.globalTime->getSeconds());
			logInfo(stream.str());
		}
		else
			logError("Syntax is: print_time");
	}

//==========================================================================================================================
	else if(command == "help")											// help
	{
		log(" clean_console\tclear_console\texit\tGFX_add <string>", {230, 200, 120});
		log(" gfx_add <string>\titem_add <int>\titem_add <int:int>\tmap_load <string>", {230, 200, 120});
		log(" map_reload\tplayer_get_position\tplayer_play_animation <int>", {230, 200, 120});
		log(" player_set_health <int>\tplayer_set_mana <int>\tplayer_set_position <float:float>", {230, 200, 120});
		log(" player_set_speed <int>\tplayer_set_sprite <string>\tprint <string>\tprint_time", {230, 200, 120});
		log(" show_collision <int>\ttime_set <int:int:int>\ttoggle_gui", {230, 200, 120});
	}
//==========================================================================================================================
	else if (command == "toggle_gui")											// toggle_gui
	{
		if (valueList.size() == 0)
		{
			context.player->setProperty("hideGUI", !context.player->getProperty("hideGUI"));
		}
		else
			logError("Syntax is: toggle_gui");
	}
//==========================================================================================================================
	else if(command == "map_load")											// map_load name
	{
		if(valueList.size() == 1)
		{
			const std::string mapName = valueList[0] + ".tmx";
			context.gameMap->loadMap(mapName);
		}
		else
			logError("Syntax is: map_load name");
	}
//==========================================================================================================================
	else if(command == "map_reload")										// map_reload
	{
		if(valueList.size() == 0)
		{
			context.gameMap->reload();
			logInfo("Updated the map with the latest changes.");
		}

		else
			logError("Syntax is: map_reload");
	}

//==========================================================================================================================
	else if(command == "player_set_sprite")								// player_set_sprite
	{
		if(valueList.size() == 1)
			context.player->changeSprite(valueList[0]);
		else
			logError("Syntax is: player_set_sprite name");
	}
//==========================================================================================================================
	else if(command == "item_add")										// item_add ID
	{
		if(valueList.size() == 2)
			context.player->getInventory().addItem(ItemID(stoi(valueList[0])), stoi(valueList[1]));

		else if(valueList.size() == 1)
			context.player->getInventory().addItem(ItemID(stoi(valueList[0])));

		else
			logError("Syntax is: item_add ID AMMOUNT (amount is optional)");
	}
//==========================================================================================================================
	// No command is correct
	else
		logError("Unknown command.");
}
Ejemplo n.º 24
0
int song_battle(sf::RenderWindow *w, Profile * profile, Stage * stage, Stage * mappedStage) {
	std::string filePath = (*stage).getPath();
	const std::string fileExtension = ".ogg";

	/*
	sf::SoundBuffer buffer;
	buffer.loadFromFile(filepath);

	MusicStream stream;
	stream.load(buffer);
	stream.play();
	*/

	//loading stage
	//load fonts
	sf::Font gameFont;
	if (!gameFont.loadFromFile("arial.ttf")) {
		//error
		std::cout << "Cannot load font\n";
	}

	//load background
	sf::Texture backTexture;
	if (!backTexture.loadFromFile(filePath + ".png")) {
		//error
	}
	backTexture.setSmooth(true);
	backTexture.setRepeated(false);
	sf::Sprite backSprite;
	backSprite.setTexture(backTexture);
	backSprite.setColor(sf::Color(255, 255, 255, 96)); // 1/2 transparent

													   //pause overlay
	sf::RectangleShape pauseOverlay(sf::Vector2f(800, 600));
	pauseOverlay.setFillColor(sf::Color(0, 0, 0, 128));
	/*
	//pause menu
	sf::RectangleShape pauseMenu(sf::Vector2f(400, 400));
	pauseOverlay.setFillColor(sf::Color(0, 0, 0, 128));
	*/
	//resume button
	sf::RectangleShape resumeButton(sf::Vector2f(250, 50));
	resumeButton.setFillColor(sf::Color(0, 0, 0, 160));
	resumeButton.setPosition(275, 250);
	sf::Text resumeText;
	resumeText.setFont(gameFont);
	resumeText.setCharacterSize(20);
	resumeText.setPosition(330, 260);
	resumeText.setString("Resume playing");
	//return button
	sf::RectangleShape returnButton(sf::Vector2f(250, 50));
	returnButton.setFillColor(sf::Color(0, 0, 0, 160));
	returnButton.setPosition(275, 300);
	sf::Text returnText;
	returnText.setFont(gameFont);
	returnText.setCharacterSize(20);
	returnText.setPosition(290, 310);
	returnText.setString("Return to song selection");

	//three pathways for beats to travel/drop through
	sf::Color leftPathColor(102, 1, 46, 128); //anchor/default color
	sf::Color middlePathColor(25, 80, 70, 128); //anchor/default color
	sf::Color rightPathColor(18, 40, 76, 128); //anchor/default color
	sf::ConvexShape leftPath;
	leftPath.setPointCount(4);
	leftPath.setPoint(0, sf::Vector2f(10, 0));
	leftPath.setPoint(1, sf::Vector2f(30, 0));
	leftPath.setPoint(2, sf::Vector2f(100, 600));
	leftPath.setPoint(3, sf::Vector2f(10, 600));
	leftPath.setFillColor(leftPathColor);
	sf::ConvexShape middlePath;
	middlePath.setPointCount(4);
	middlePath.setPoint(0, sf::Vector2f(290, 0));
	middlePath.setPoint(1, sf::Vector2f(310, 0));
	middlePath.setPoint(2, sf::Vector2f(345, 600));
	middlePath.setPoint(3, sf::Vector2f(255, 600));
	middlePath.setFillColor(middlePathColor);
	sf::ConvexShape rightPath;
	rightPath.setPointCount(4);
	rightPath.setPoint(0, sf::Vector2f(570, 0));
	rightPath.setPoint(1, sf::Vector2f(590, 0));
	rightPath.setPoint(2, sf::Vector2f(590, 600));
	rightPath.setPoint(3, sf::Vector2f(500, 600));
	rightPath.setFillColor(rightPathColor);

	//three bottom buttons
	sf::CircleShape leftCircle(30);
	leftCircle.setFillColor(sf::Color(102, 1, 46, 128));
	leftCircle.setOutlineThickness(5);
	leftCircle.setOutlineColor(sf::Color(205, 54, 128));
	sf::CircleShape middleTriangle(30, 3);
	middleTriangle.setFillColor(sf::Color(25, 80, 70, 128));
	middleTriangle.setOutlineThickness(5);
	middleTriangle.setOutlineColor(sf::Color(5, 203, 156));
	sf::CircleShape rightSquare(30, 4);
	rightSquare.setFillColor(sf::Color(18, 40, 76, 128));
	rightSquare.setOutlineThickness(5);
	rightSquare.setOutlineColor(sf::Color(3, 181, 170));

	leftCircle.setPosition(20, 500);
	middleTriangle.setPosition(270, 500);
	rightSquare.setPosition(520, 500);

	//score
	int score = 0; //starting game score

				   //text that appears on the screen telling how accurate the hit was
	sf::Text hitText;
	hitText.setFont(gameFont);
	hitText.setCharacterSize(50);
	//for text that appears on the side of the song battle
	sf::Text sideText;
	sideText.setFont(gameFont);

	//initialize character texture/sprite
	std::deque<sf::Texture> charTextures;
	std::deque<Character> * activeTeam = (*(*profile).getTeam()).getActiveTeam();

	for (int i = 0; i < (*activeTeam).size(); i++) {
		sf::Texture charTexture;
		if (!charTexture.loadFromFile("characters/team_" + (*(*profile).getTeam()).getTeamName() + "/" + (*activeTeam)[i].getImagePath())) {
			std::cout << "ERROR: Cannot load image for character " << (*activeTeam)[i].getInfoPath() << "\n";
		}
		charTextures.push_back(charTexture);
	}
	sf::Sprite charSprite;

	//load beats
	std::deque<Beat> beatList;
	std::ifstream file(filePath + ".txt");
	std::string line;
	const std::string delimiter = "@";
	if (file.is_open()) {
		while (std::getline(file, line)) {
			std::string key = line.substr(0, line.find(delimiter));
			float time = stof(line.substr(line.find(delimiter) + 1, line.length()));
			sf::CircleShape shapeGraphics(30);
			if (key == "Left") {
				//shapeGraphics.setFillColor(sf::Color(102, 1, 46, 128));
				//shapeGraphics.setFillColor(sf::Color(205, 54, 128));
				shapeGraphics.setFillColor(sf::Color(250, 127, 191));
				shapeGraphics.setOutlineThickness(5);
				shapeGraphics.setOutlineColor(sf::Color(250, 127, 191));
				shapeGraphics.setPosition(20, 0);
			}
			else if (key == "Up") {
				shapeGraphics.setPointCount(3);
				//shapeGraphics.setFillColor(sf::Color(25, 80, 70, 128));
				shapeGraphics.setFillColor(sf::Color(4, 240, 186));
				shapeGraphics.setOutlineThickness(5);
				shapeGraphics.setOutlineColor(sf::Color(4, 240, 186));
				shapeGraphics.setPosition(270, 0);
			}
			else if (key == "Right") {
				shapeGraphics.setPointCount(4);
				//shapeGraphics.setFillColor(sf::Color(18, 40, 76, 128));
				shapeGraphics.setFillColor(sf::Color(5, 220, 238));
				shapeGraphics.setOutlineThickness(5);
				shapeGraphics.setOutlineColor(sf::Color(5, 220, 238));
				shapeGraphics.setPosition(520, 0);
			}

			beatList.push_back(Beat(key, time, shapeGraphics));
		}
	}

	Beat beat = beatList.front();
	bool finished = false; //status of empty beatlist

						   //containers for beats drawn on screen
	const float pixelsPerMillisecond = .3; //ideal is .25, but when making the song, I lag a bit after hearing the beat
	const float dropDistance = 500; //how far the beat travels
	const float distanceTolerance = 50; //how far off the beat is from the marker we are willing to accept
	const float scoreMultiplier = 100; //scoring scale
	std::deque<Beat> leftBeats;
	std::deque<Beat> upBeats;
	std::deque<Beat> rightBeats;

	sf::Music music;

	bool movieMode = false;
	std::unordered_map<std::string, bool> movieList;
	movieList["Majisuka Gakuen 5 Theme"] = true;
	movieList["Escape"] = true;
	movieList["Sailor Zombie"] = true;
	if (movieList.find(filePath) != movieList.end()) {
		movieMode = true;
	}

	sfe::Movie movie;
	if (movieMode) {
		if (!movie.openFromFile(filePath + ".mp4")) {
			//error loading
		}
		music.setVolume(0); //mute the music
		movie.setPosition(sf::Vector2f(0, (600 - movie.getSize().y) / 2));
		sf::Vector2f movieSize = movie.getSize();
		float dominantAxis = std::max(movieSize.x, movieSize.y); //we intend to resize the video such that the larger axis is 600 pixels
		float scale = 600 / dominantAxis;
		movie.setScale(sf::Vector2f(scale, scale));
		movie.play();
	}
	else {
		if (!music.openFromFile(filePath + fileExtension)) {
			return -1; // error
		}

		music.play();
	}

	std::deque<Effect> effects;

	sf::Clock clock;
	bool paused = false; //keeps track of the game state, paused or active
	float totalTimeElapsed = 0.0; //keeps track of the time elapsed
								  //used for when player pauses the game, we don't keep track of the time when the game is paused
								  //since our game depends on the current time of the clock since the start
								  //and due to how sf::Clock operates (there's no way to "pause" time, only restart it)
								  //we use this variable to accumulate how long the clock has been running for before it restarts due to pausing/resuming
	music.setPlayingOffset(sf::milliseconds(clock.restart().asMilliseconds())); //sync start time of music with clock

	while ((*w).isOpen()) {
		float elapsed = clock.getElapsedTime().asMilliseconds() + totalTimeElapsed;
		//TODO replace all the "clock.getElapsedTime().asMilliseconds() + totalTimeElapsed" with elapsed
		//check if still working afterwards

		//if we finished the song
		if (((movieMode && movie.getStatus() == 0) || (!movieMode && music.getStatus() == 0)) && !paused) {
			int highScore = 0;
			int contestedScore = (*stage).getHighScore();
			if (score > contestedScore) {
				highScore = score;
			}
			else {
				highScore = contestedScore;
			}

			if (score > 0) { //requirement to pass stage, may change later
				(*stage).setProfile(highScore, (*stage).getTimesPlayed() + 1, (*stage).getUnlocked(), (*stage).getHidden());
				(*mappedStage).setProfile(highScore, (*stage).getTimesPlayed() + 1, (*stage).getUnlocked(), (*stage).getHidden());

				//std::cout << "stage high score: " << (*stage).getHighScore() << "\n";

				//do some after game stats display first before returning (manual click)
				std::ofstream file;
				file.open(filePath + ".dat");
				file << "title:" << (*stage).getTitle() << "\n";
				file << "artist:" << (*stage).getArtist() << "\n";
				file << "album:" << (*stage).getAlbum() << "\n";
				file << "year:" << (*stage).getYear() << "\n";
				file << "highest_score:" << highScore << "\n";
				file << "times_played:" << (*stage).getTimesPlayed() << "\n";
				if ((*stage).getUnlocked()) {
					file << "unlocked:" << "true" << "\n";
				}
				else {
					file << "unlocked:" << "false" << "\n";
				}
				if ((*stage).getHidden()) {
					file << "hidden:" << "true" << "\n";
				}
				else {
					file << "hidden:" << "false";
				}
				file.close();

				//update profile
				//money

				//update character data
				std::deque<Character> * aTeam = (*(*profile).getTeam()).getActiveTeam();
				for (int i = 0; i < (*aTeam).size(); i++) {
					Character * c = &(*aTeam)[i];

					//calculate exp based off of score
					(*c).incExp(score / 2); //TODO, write exp system

											//if exp > maxExp for that level, level character

											//write character data to file
					std::ofstream charFile;
					charFile.open("characters/team_" + (*c).getTeam() + "/" + (*aTeam)[i].getInfoPath());
					if (charFile.is_open()) {
						charFile << "firstName:" << (*c).getFirstName() << "\n";
						charFile << "lastName:" << (*c).getLastName() << "\n";
						charFile << "nickname:" << (*c).getNickname() << "\n";
						std::cout << "nickname: " << (*c).getNickname() << "\n";//debug
						charFile << "team:" << (*c).getTeam() << "\n";
						charFile << "rank:" << (*c).getRank() << "\n";
						charFile << "prefix:" << (*c).getPrefix() << "\n";
						charFile << "suffix:" << (*c).getSuffix() << "\n";
						charFile << "level:" << std::to_string((*c).getLevel()) << "\n";
						charFile << "experience:" << std::to_string((*c).getExp()) << "\n";
						if ((*c).getUnlocked()) {
							charFile << "unlocked:true";
						}
						else {
							charFile << "unlocked:false";
						}
					}
					else {
						std::cout << "ERROR: Cannot open character data for saving. Filepath: " << "characters/team_" + (*c).getTeam() + "/" + (*aTeam)[i].getInfoPath() << "\n";
					}
				}
			}
			else {
				//fail stage
			}

			return score; //return score
		}

		//put ready to go beats in beat queue (to appear on the screen)
		//invariant, beats with an earlier time cannot appear before beats with a later time
		//thus, we can simply use a queue to pop a single beat at a time once its ready to put in the ready vectors
		if (!paused && !finished && beat.getTime() - elapsed < 2000) {
			//if beat time is within 2 seconds of the future, start drawing and dropping it on the screen

			std::string beatKey = beat.getKey();
			if (beatKey == "Left") {
				leftBeats.push_back(beat);
			}
			else if (beatKey == "Up") {
				upBeats.push_back(beat);
			}
			else if (beatKey == "Right") {
				rightBeats.push_back(beat);
			}

			if (beatList.size() == 1) {
				//if popped last one, finished
				finished = true;
			}
			else {
				beatList.pop_front();
				beat = beatList.front();
			}
		}

		sf::Event event;

		while ((*w).pollEvent(event)) {
			if (event.type == sf::Event::KeyPressed) {
				//std::cout << event.key.code << "\n"; //debug
				if (!paused) {
					if (event.key.code == 71) { //Left
						std::string baseValues = "";
						sf::Color oC = leftCircle.getOutlineColor();
						baseValues += std::to_string(oC.r);
						baseValues += ",";
						baseValues += std::to_string(oC.g);
						baseValues += ",";
						baseValues += std::to_string(oC.b);
						effects.push_back(Effect(clock.getElapsedTime().asMilliseconds() + totalTimeElapsed, 350.0, &leftCircle, "outline color", "255,76,165", baseValues));

						bool validHit = false;
						for (int i = 0; i < leftBeats.size(); i++) {
							Beat * it = &leftBeats.at(i);
							sf::CircleShape * graphics = (*it).getGraphicsObject();
							float distanceDiff = std::abs((*it).getPos().y - 500.0);
							if (distanceDiff <= distanceTolerance) {
								validHit = true;
								score += (distanceTolerance - distanceDiff) * scoreMultiplier;

								bool effectInProgress = false;
								for (int i = 0; i < effects.size(); i++) {
									Effect * e = &effects.at(i);
									if ((*e).checkEIP(graphics)) {
										effectInProgress = true;
										std::cout << "Effect in progress already!\n"; //debug
										effects.erase(effects.begin() + i);
									}
								}
								effects.push_back(Effect(clock.getElapsedTime().asMilliseconds() + totalTimeElapsed, 250.0, graphics, "outline color", "255,255,255", baseValues));
								effects.push_back(Effect(clock.getElapsedTime().asMilliseconds() + totalTimeElapsed, 250.0, graphics, "fill color", "255,255,255", baseValues));
								effects.push_back(Effect(clock.getElapsedTime().asMilliseconds() + totalTimeElapsed, 250.0, graphics, "radius size", "40",
									std::to_string((*graphics).getRadius()) + ","
									+ std::to_string((*graphics).getPosition().x) + ","
									+ std::to_string((*graphics).getPosition().y)));

								//check if there are any pre-existing effects on hitText
								//if there are, discard them because we want to discard the previous message and start over
								for (int i = 0; i < effects.size(); i++) {
									Effect * e = &effects.at(i);
									if ((*e).checkEIP(&hitText)) {
										std::cout << "Text Effect in progress already!\n"; //debug
										effects.erase(effects.begin() + i);
										break;
									}
								}
								hitText.setColor(sf::Color(255, 255, 255, 224));
								float distDelta = distanceTolerance - distanceDiff;
								if (distDelta < 10) {
									hitText.setString("Spectacular!");
									hitText.setPosition(180, 50);
								}
								else if (distDelta >= 10 && distDelta < 20) {
									hitText.setString("Amazing!");
									hitText.setPosition(220, 50);
								}
								else if (distDelta >= 20 && distDelta < 30) {
									hitText.setString("Awesome");
									hitText.setPosition(220, 50);
								}
								else if (distDelta >= 30 && distDelta < 40) {
									hitText.setString("Great");
									hitText.setPosition(250, 50);
								}
								else if (distDelta >= 40) {
									hitText.setString("Good");
									hitText.setPosition(255, 50);
								}
								effects.push_back(Effect(clock.getElapsedTime().asMilliseconds() + totalTimeElapsed, 500.0, &hitText, "color transparency permanent", "0", "224"));
							}
						}
						if (!validHit) {
							score -= 1000;
							//check if there are any pre-existing effects on hitText
							//if there are, discard them because we want to discard the previous message and start over
							for (int i = 0; i < effects.size(); i++) {
								Effect * e = &effects.at(i);
								if ((*e).checkEIP(&hitText)) {
									std::cout << "Text Effect in progress already!\n"; //debug
									effects.erase(effects.begin() + i);
									break;
								}
							}
							hitText.setColor(sf::Color(255, 255, 255, 224));
							hitText.setString("Miss");
							hitText.setPosition(255, 50);
							effects.push_back(Effect(clock.getElapsedTime().asMilliseconds() + totalTimeElapsed, 500.0, &hitText, "color transparency permanent", "0", "224"));
						}
					}
					else if (event.key.code == 73) { //Up
						std::string baseValues = "";
						sf::Color oC = middleTriangle.getOutlineColor();
						baseValues += std::to_string(oC.r);
						baseValues += ",";
						baseValues += std::to_string(oC.g);
						baseValues += ",";
						baseValues += std::to_string(oC.b);
						effects.push_back(Effect(clock.getElapsedTime().asMilliseconds() + totalTimeElapsed, 350.0, &middleTriangle, "outline color", "55,253,206", baseValues));

						bool validHit = false;
						for (int i = 0; i < upBeats.size(); i++) {
							Beat * it = &upBeats.at(i);
							sf::CircleShape * graphics = (*it).getGraphicsObject();
							float distanceDiff = std::abs((*it).getPos().y - 500.0);
							if (distanceDiff <= distanceTolerance) {
								validHit = true;
								score += (distanceTolerance - distanceDiff) * scoreMultiplier;

								bool effectInProgress = false;
								for (int i = 0; i < effects.size(); i++) {
									Effect * e = &effects.at(i);
									if ((*e).checkEIP(graphics)) {
										effectInProgress = true;
										std::cout << "Effect in progress already!\n"; //debug
										effects.erase(effects.begin() + i);
									}
								}
								effects.push_back(Effect(clock.getElapsedTime().asMilliseconds() + totalTimeElapsed, 250.0, graphics, "outline color", "255,255,255", baseValues));
								effects.push_back(Effect(clock.getElapsedTime().asMilliseconds() + totalTimeElapsed, 250.0, graphics, "fill color", "255,255,255", baseValues));
								effects.push_back(Effect(clock.getElapsedTime().asMilliseconds() + totalTimeElapsed, 250.0, graphics, "radius size", "40",
									std::to_string((*graphics).getRadius()) + ","
									+ std::to_string((*graphics).getPosition().x) + ","
									+ std::to_string((*graphics).getPosition().y)));

								//check if there are any pre-existing effects on hitText
								//if there are, discard them because we want to discard the previous message and start over
								for (int i = 0; i < effects.size(); i++) {
									Effect * e = &effects.at(i);
									if ((*e).checkEIP(&hitText)) {
										std::cout << "Text Effect in progress already!\n"; //debug
										effects.erase(effects.begin() + i);
										break;
									}
								}
								hitText.setColor(sf::Color(255, 255, 255, 224));
								float distDelta = distanceTolerance - distanceDiff;
								if (distDelta < 10) {
									hitText.setString("Spectacular!");
									hitText.setPosition(180, 50);
								}
								else if (distDelta >= 10 && distDelta < 20) {
									hitText.setString("Amazing!");
									hitText.setPosition(220, 50);
								}
								else if (distDelta >= 20 && distDelta < 30) {
									hitText.setString("Awesome");
									hitText.setPosition(220, 50);
								}
								else if (distDelta >= 30 && distDelta < 40) {
									hitText.setString("Great");
									hitText.setPosition(250, 50);
								}
								else if (distDelta >= 40) {
									hitText.setString("Good");
									hitText.setPosition(255, 50);
								}
								effects.push_back(Effect(clock.getElapsedTime().asMilliseconds() + totalTimeElapsed, 500.0, &hitText, "color transparency permanent", "0", "224"));
							}
						}
						if (!validHit) {
							score -= 1000;
							//check if there are any pre-existing effects on hitText
							//if there are, discard them because we want to discard the previous message and start over
							for (int i = 0; i < effects.size(); i++) {
								Effect * e = &effects.at(i);
								if ((*e).checkEIP(&hitText)) {
									std::cout << "Text Effect in progress already!\n"; //debug
									effects.erase(effects.begin() + i);
									break;
								}
							}
							hitText.setColor(sf::Color(255, 255, 255, 224));
							hitText.setString("Miss");
							hitText.setPosition(255, 50);
							effects.push_back(Effect(clock.getElapsedTime().asMilliseconds() + totalTimeElapsed, 500.0, &hitText, "color transparency permanent", "0", "224"));
						}
					}
					else if (event.key.code == 72) { //Right
						std::string baseValues = "";
						sf::Color oC = rightSquare.getOutlineColor();
						baseValues += std::to_string(oC.r);
						baseValues += ",";
						baseValues += std::to_string(oC.g);
						baseValues += ",";
						baseValues += std::to_string(oC.b);
						effects.push_back(Effect(clock.getElapsedTime().asMilliseconds() + totalTimeElapsed, 350.0, &rightSquare, "outline color", "53,231,220", baseValues));

						bool validHit = false;
						for (int i = 0; i < rightBeats.size(); i++) {
							Beat * it = &rightBeats.at(i);
							sf::CircleShape * graphics = (*it).getGraphicsObject();
							float distanceDiff = std::abs((*it).getPos().y - 500.0);
							if (distanceDiff <= distanceTolerance) {
								validHit = true;
								score += (distanceTolerance - distanceDiff) * scoreMultiplier;

								bool effectInProgress = false;
								for (int i = 0; i < effects.size(); i++) {
									Effect * e = &effects.at(i);
									if ((*e).checkEIP(graphics)) {
										effectInProgress = true;
										std::cout << "Effect in progress already!\n"; //debug
										effects.erase(effects.begin() + i);
									}
								}
								//if (!effectInProgress) { //if graphics doesn't have any pre-existing effects
								effects.push_back(Effect(clock.getElapsedTime().asMilliseconds() + totalTimeElapsed, 250.0, graphics, "outline color", "255,255,255", baseValues));
								effects.push_back(Effect(clock.getElapsedTime().asMilliseconds() + totalTimeElapsed, 250.0, graphics, "fill color", "255,255,255", baseValues));
								effects.push_back(Effect(clock.getElapsedTime().asMilliseconds() + totalTimeElapsed, 250.0, graphics, "radius size", "40",
									std::to_string((*graphics).getRadius()) + ","
									+ std::to_string((*graphics).getPosition().x) + ","
									+ std::to_string((*graphics).getPosition().y)));
								//}

								//check if there are any pre-existing effects on hitText
								//if there are, discard them because we want to discard the previous message and start over
								for (int i = 0; i < effects.size(); i++) {
									Effect * e = &effects.at(i);
									if ((*e).checkEIP(&hitText)) {
										std::cout << "Text Effect in progress already!\n"; //debug
										effects.erase(effects.begin() + i);
										break;
									}
								}
								hitText.setColor(sf::Color(255, 255, 255, 224));
								float distDelta = distanceTolerance - distanceDiff;
								if (distDelta < 10) {
									hitText.setString("Spectacular!");
									hitText.setPosition(180, 50);
								}
								else if (distDelta >= 10 && distDelta < 20) {
									hitText.setString("Amazing!");
									hitText.setPosition(220, 50);
								}
								else if (distDelta >= 20 && distDelta < 30) {
									hitText.setString("Awesome");
									hitText.setPosition(220, 50);
								}
								else if (distDelta >= 30 && distDelta < 40) {
									hitText.setString("Great");
									hitText.setPosition(250, 50);
								}
								else if (distDelta >= 40) {
									hitText.setString("Good");
									hitText.setPosition(255, 50);
								}
								effects.push_back(Effect(clock.getElapsedTime().asMilliseconds() + totalTimeElapsed, 500.0, &hitText, "color transparency permanent", "0", "224"));
							}
						}
						if (!validHit) {
							score -= 1000;
							//check if there are any pre-existing effects on hitText
							//if there are, discard them because we want to discard the previous message and start over
							for (int i = 0; i < effects.size(); i++) {
								Effect * e = &effects.at(i);
								if ((*e).checkEIP(&hitText)) {
									std::cout << "Text Effect in progress already!\n"; //debug
									effects.erase(effects.begin() + i);
									break;
								}
							}
							hitText.setColor(sf::Color(255, 255, 255, 224));
							hitText.setString("Miss");
							hitText.setPosition(255, 50);
							effects.push_back(Effect(clock.getElapsedTime().asMilliseconds() + totalTimeElapsed, 500.0, &hitText, "color transparency permanent", "0", "224"));
						}
					}
				}
				if (event.key.code == 11) { //L - List beats
					for (auto it : beatList) {
						std::cout << it.toString();
					}
				}
				else if (event.key.code == 15 || event.key.code == 36) { //P - Pause/Unpause game, Esc - pauses and unpauses the game
					if (paused) {
						paused = false;
						clock.restart();
						music.play();
						music.setPlayingOffset(sf::milliseconds(clock.getElapsedTime().asMilliseconds() + totalTimeElapsed)); //resume from where we left off
					}
					else {
						paused = true;
						totalTimeElapsed += clock.restart().asMilliseconds();
						music.stop();
					}
				}
				else if (event.key.code == 5) { //F - Finish song
					music.stop();
				}
				else if (event.key.code == 2) { //C - Clear console
					system("cls");
				}
			}
			if (event.type == sf::Event::MouseMoved) {
				sf::Vector2i localPos = sf::Mouse::getPosition((*w));

				if (paused) {
					if (localPos.x >= 275 && localPos.x <= 525
						&& localPos.y >= 250 && localPos.y <= 300) {
						//resume button
						returnButton.setFillColor(sf::Color(0, 0, 0, 160));
						resumeButton.setFillColor(sf::Color(96, 96, 96, 160));
					}
					else if (localPos.x >= 275 && localPos.x <= 525
						&& localPos.y >= 300 && localPos.y <= 350) {
						//return button
						resumeButton.setFillColor(sf::Color(0, 0, 0, 160));
						returnButton.setFillColor(sf::Color(96, 96, 96, 160));
					}
					else {
						resumeButton.setFillColor(sf::Color(0, 0, 0, 160));
						returnButton.setFillColor(sf::Color(0, 0, 0, 160));
					}
				}
			}
			if (event.type == sf::Event::MouseButtonPressed && event.mouseButton.button == sf::Mouse::Left) {
				sf::Vector2i localPos = sf::Mouse::getPosition((*w));

				if (paused) {
					if (localPos.x >= 275 && localPos.x <= 525
						&& localPos.y >= 250 && localPos.y <= 300) {
						//resume button was clicked, unpause
						paused = false;
						clock.restart();
						music.play();
						music.setPlayingOffset(sf::milliseconds(clock.getElapsedTime().asMilliseconds() + totalTimeElapsed)); //resume from where we left off
					}
					else if (localPos.x >= 275 && localPos.x <= 525
						&& localPos.y >= 300 && localPos.y <= 350) {
						//return button was clicked
						return 0;
					}
				}
			}
			if (event.type == sf::Event::Closed) {
				(*w).close();
			}
		}

		if (!paused) {
			//handle effects in queue
			float nowTime = clock.getElapsedTime().asMilliseconds() + totalTimeElapsed;
			for (int i = 0; i < effects.size(); i++) {
				Effect * it = &effects.at(i);
				if ((*it).getTimeDelta(nowTime) <= (*it).getDuration()) {
					(*it).transition(nowTime);
				}
				else {
					(*it).expire(); //marks the effect as done so that removal can clean up
				}
			}
			//remove beats that already passed
			leftBeats.erase(std::remove_if(leftBeats.begin(), leftBeats.end(), [](Beat b) {
				return b.getPos().y > 600;
			}), leftBeats.end());
			upBeats.erase(std::remove_if(upBeats.begin(), upBeats.end(), [](Beat b) {
				return b.getPos().y > 600;
			}), upBeats.end());
			rightBeats.erase(std::remove_if(rightBeats.begin(), rightBeats.end(), [](Beat b) {
				return b.getPos().y > 600;
			}), rightBeats.end());

			//remove effects that expired
			effects.erase(std::remove_if(effects.begin(), effects.end(), [](Effect e) {
				return e.getExpired();
			}), effects.end());
		}


		//drawing stage
		//set default background black
		(*w).clear(sf::Color::Black);
		//draw movie if movie stage
		if (movieMode) {
			movie.update();
			(*w).draw(movie);
		}
		else {
			(*w).draw(backSprite); //background
		}

		//score text
		std::string scoreStr = std::to_string(score);
		sideText.setString(scoreStr); //update score
		int scoreXPos = 775 - 28 * scoreStr.length(); //calculate x position so that score shifts accordingly if increased
		sideText.setPosition(scoreXPos, 10);
		sideText.setCharacterSize(50);
		(*w).draw(sideText);

		for (int i = 0; i < 5; i++) {
			charSprite.setTexture(charTextures[i]);
			if (i == 0) {
				Character * captain = (*(*profile).getTeam()).getCaptain();

				charSprite.setScale(sf::Vector2f(.5, .5));
				charSprite.setPosition(625, 100);

				sideText.setCharacterSize(15);
				//team captain's level
				sideText.setString("Level " + std::to_string((*captain).getLevel()));
				sideText.setPosition(625, 300);
				(*w).draw(sideText);
				//team captain's name
				sideText.setString((*captain).getName());
				sideText.setPosition(625, 320);
				(*w).draw(sideText);
			}
			else {
				charSprite.setScale(sf::Vector2f(.23, .23));
				if (i == 1 || i == 2) {
					charSprite.setPosition(625 + 80 * (i % 2), 100 + 250);
				}
				else {
					charSprite.setPosition(625 + 80 * (i % 2), 100 + 250 + 100);
				}
			}
			(*w).draw(charSprite);
		}

		//pathways
		int colorTime = int(elapsed) % 8000;
		const int colorAdder = 70;
		float colorMultiplier = ((colorTime % 2000) * 1.0) / 2000.0;
		float colorAdderResult = colorAdder;
		if (colorTime < 2000) {
			colorAdderResult *= colorMultiplier;
		}
		else if (colorTime >= 2000 && colorTime < 4000) {
			colorAdderResult *= (1 - colorMultiplier);
		}
		else if (colorTime >= 4000 && colorTime < 6000) {
			colorAdderResult *= -1;
			colorAdderResult *= colorMultiplier;
		}
		else if (colorTime >= 6000) {
			colorAdderResult *= -1;
			colorAdderResult *= (1 - colorMultiplier);
		}
		//std::cout << "time: " << colorTime << ", cm: " << colorMultiplier << ", result: " << colorAdderResult << "\n"; //debug
		leftPath.setFillColor(sf::Color(std::max(leftPathColor.r + colorAdderResult, 0.0f),
			std::max(leftPathColor.g + colorAdderResult / 2, 0.0f),
			std::max(leftPathColor.b + colorAdderResult / 2, 0.0f), leftPathColor.a));
		middlePath.setFillColor(sf::Color(std::max(middlePathColor.r + colorAdderResult, 0.0f),
			std::max(middlePathColor.g + colorAdderResult / 2, 0.0f),
			std::max(middlePathColor.b + colorAdderResult / 2, 0.0f), middlePathColor.a));
		rightPath.setFillColor(sf::Color(std::max(rightPathColor.r + colorAdderResult, 0.0f),
			std::max(rightPathColor.g + colorAdderResult / 2, 0.0f),
			std::max(rightPathColor.b + colorAdderResult / 2, 0.0f), rightPathColor.a));
		(*w).draw(leftPath);
		(*w).draw(middlePath);
		(*w).draw(rightPath);
		//lower 3 buttons
		(*w).draw(leftCircle);
		(*w).draw(middleTriangle);
		(*w).draw(rightSquare);
		//active beats
		for (int i = 0; i < leftBeats.size(); i++) {
			Beat * it = &leftBeats.at(i);
			//cycle through active beats and reposition them
			float expectedTime = (*it).getTime();
			float curTime = clock.getElapsedTime().asMilliseconds() + totalTimeElapsed;
			float result = dropDistance - pixelsPerMillisecond * (expectedTime - curTime);

			sf::CircleShape * graphics = (*it).getGraphicsObject();
			const float beatSize = 30;

			if (!paused) {
				bool effectInProgress = false;
				for (int i = 0; i < effects.size(); i++) {
					Effect * e = &effects.at(i);
					if ((*e).checkEIP(graphics)) {
						effectInProgress = true;
					}
				}
				//make the beat grow as it travels downward
				if (!effectInProgress) {
					(*graphics).setRadius(std::min(result / dropDistance * beatSize, beatSize));
				}
				(*graphics).setPosition((*graphics).getPosition().x, result);
				(*it).setY(result);
			}

			(*w).draw(*graphics);
		}
		for (int i = 0; i < upBeats.size(); i++) {
			Beat * it = &upBeats.at(i);
			//cycle through active beats and reposition them
			float expectedTime = (*it).getTime();
			float curTime = clock.getElapsedTime().asMilliseconds() + totalTimeElapsed;
			float result = dropDistance - pixelsPerMillisecond * (expectedTime - curTime);

			sf::CircleShape * graphics = (*it).getGraphicsObject();
			const float beatSize = 30;

			if (!paused) {
				bool effectInProgress = false;
				for (int i = 0; i < effects.size(); i++) {
					Effect * e = &effects.at(i);
					if ((*e).checkEIP(graphics)) {
						effectInProgress = true;
					}
				}
				//make the beat grow as it travels downward
				if (!effectInProgress) {
					float sizeDelta = beatSize - (result / dropDistance * beatSize); //centers the enlarging beat
					(*graphics).setRadius(std::min(result / dropDistance * beatSize, beatSize));
					(*graphics).setPosition(middleTriangle.getPosition().x + sizeDelta, result);
				}
				else {
					(*graphics).setPosition((*graphics).getPosition().x, result);
				}
				(*it).setY(result);
			}

			(*w).draw(*graphics);
		}
		for (int i = 0; i < rightBeats.size(); i++) {
			Beat * it = &rightBeats.at(i);
			//cycle through active beats and reposition them
			float expectedTime = (*it).getTime();
			float curTime = clock.getElapsedTime().asMilliseconds() + totalTimeElapsed;
			float result = dropDistance - pixelsPerMillisecond * (expectedTime - curTime);

			sf::CircleShape * graphics = (*it).getGraphicsObject();
			const float beatSize = 30;

			if (!paused) {
				bool effectInProgress = false;
				for (int i = 0; i < effects.size(); i++) {
					Effect * e = &effects.at(i);
					if ((*e).checkEIP(graphics)) {
						effectInProgress = true;
					}
				}
				//make the beat grow as it travels downward
				if (!effectInProgress) {
					float sizeDelta = beatSize - (result / dropDistance * beatSize); //centers the enlarging beat
					(*graphics).setRadius(std::min(result / dropDistance * beatSize, beatSize));
					(*graphics).setPosition(rightSquare.getPosition().x + sizeDelta * 2, result);
				}
				else {
					(*graphics).setPosition((*graphics).getPosition().x, result);
				}
				(*it).setY(result);
			}

			(*w).draw(*graphics);
		}
		(*w).draw(hitText);
		if (paused) {
			(*w).draw(pauseOverlay); //darkens the entire screen when paused
			(*w).draw(resumeButton); //resume button
			(*w).draw(resumeText); //resume text
			(*w).draw(returnButton); //return button
			(*w).draw(returnText); //return text
		}

		//end current frame
		(*w).display();
	}

	return 0;
}
Ejemplo n.º 25
0
Archivo: Design.hpp Proyecto: cran/Boom
 void remove_intercept() { remove_effect(Effect()); }