Files
itgmania212121/stepmania/src/ArrowEffects.cpp
T

151 lines
4.6 KiB
C++
Raw Normal View History

2002-02-24 10:31:20 +00:00
#include "stdafx.h"
/*
-----------------------------------------------------------------------------
File: ArrowEffects.cpp
Desc: Functions that return properties of arrows based on StyleDef and PlayerOptions
2002-02-24 10:31:20 +00:00
2002-05-19 01:59:48 +00:00
Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved.
2002-02-24 10:31:20 +00:00
Chris Danford
-----------------------------------------------------------------------------
*/
2002-02-24 10:31:20 +00:00
#include "ArrowEffects.h"
2002-05-19 01:59:48 +00:00
#include "Notes.h"
2002-05-01 19:14:55 +00:00
#include "GameConstantsAndTypes.h"
2002-04-16 17:31:00 +00:00
#include "GameManager.h"
2002-07-23 01:41:40 +00:00
#include "GameState.h"
2002-07-27 19:29:51 +00:00
#include "RageException.h"
#include "RageTimer.h"
#include "NoteDisplay.h"
#include <math.h>
2002-02-24 10:31:20 +00:00
float ArrowGetYOffset( PlayerNumber pn, float fNoteBeat )
2002-02-24 10:31:20 +00:00
{
2002-07-29 03:06:55 +00:00
float fSongBeat = GAMESTATE->m_fSongBeat;
float fBeatsUntilStep = fNoteBeat - fSongBeat;
2002-02-24 10:31:20 +00:00
float fYOffset = fBeatsUntilStep * ARROW_GAP;
/* With both boost and wave enabled, the effect is that the
2002-09-30 02:19:02 +00:00
* notes "buffer" at the bottom of the screen and shoot out
* at high speed.
*
* With wave first, the boost appears halfway down the screen.
* With boost first, it appears about 1/4 down the screen.
*
* I'm not sure which is better. - glenn
*/
2002-09-30 02:19:02 +00:00
if( GAMESTATE->m_PlayerOptions[pn].m_bBoost )
2002-02-24 10:31:20 +00:00
fYOffset *= 1.4f / ((fYOffset+SCREEN_HEIGHT/1.6f)/SCREEN_HEIGHT);
2002-09-30 02:19:02 +00:00
if( GAMESTATE->m_PlayerOptions[pn].m_bEffects[PlayerOptions::EFFECT_WAVE] )
2002-02-24 10:31:20 +00:00
fYOffset += 15.0f*sinf( fYOffset/38.0f );
2002-02-24 10:31:20 +00:00
return fYOffset;
}
float ArrowGetXPos( PlayerNumber pn, int iColNum, float fYPos )
2002-02-24 10:31:20 +00:00
{
float fPixelOffsetFromCenter = GAMESTATE->GetCurrentStyleDef()->m_ColumnInfo[pn][iColNum].fXOffset;
2002-02-24 10:31:20 +00:00
2002-09-30 02:19:02 +00:00
if( GAMESTATE->m_PlayerOptions[pn].m_bEffects[PlayerOptions::EFFECT_DRUNK] )
fPixelOffsetFromCenter += cosf( TIMER->GetTimeSinceStart() + iColNum*0.2f + fYPos*6/SCREEN_HEIGHT) * ARROW_SIZE*0.5f;
2002-09-30 02:19:02 +00:00
if( GAMESTATE->m_PlayerOptions[pn].m_bEffects[PlayerOptions::EFFECT_FLIP] )
fPixelOffsetFromCenter = -fPixelOffsetFromCenter;
2002-09-30 02:19:02 +00:00
if( GAMESTATE->m_PlayerOptions[pn].m_bEffects[PlayerOptions::EFFECT_TORNADO] )
{
const StyleDef* pStyleDef = GAMESTATE->GetCurrentStyleDef();
float fMaxX = -100000, fMinX = +100000;
for( int i=0; i<pStyleDef->m_iColsPerPlayer; i++ )
{
fMaxX = max( fMaxX, pStyleDef->m_ColumnInfo[pn][i].fXOffset );
fMinX = min( fMinX, pStyleDef->m_ColumnInfo[pn][i].fXOffset );
}
float fPositionBetween = SCALE( fPixelOffsetFromCenter, fMinX, fMaxX, -1, 1 );
float fRads = acosf( fPositionBetween );
fRads += fYPos * 6 / SCREEN_HEIGHT;
fPixelOffsetFromCenter = SCALE( cosf(fRads), -1, 1, fMinX, fMaxX );
}
2002-02-24 10:31:20 +00:00
return fPixelOffsetFromCenter;
}
float ArrowGetRotation( PlayerNumber pn, int iColNum, float fYOffset )
2002-02-24 10:31:20 +00:00
{
2002-04-01 02:04:43 +00:00
float fRotation = 0; //StyleDef.m_ColumnToRotation[iColNum];
2002-02-25 23:29:39 +00:00
2002-09-30 02:19:02 +00:00
if( GAMESTATE->m_PlayerOptions[pn].m_bEffects[PlayerOptions::EFFECT_DIZZY] )
2002-02-24 10:31:20 +00:00
fRotation += fYOffset/SCREEN_HEIGHT*6;
return fRotation;
}
float ArrowGetYPos( PlayerNumber pn, float fYOffset )
2002-02-24 10:31:20 +00:00
{
2002-07-29 03:06:55 +00:00
return fYOffset * GAMESTATE->m_PlayerOptions[pn].m_fArrowScrollSpeed * (GAMESTATE->m_PlayerOptions[pn].m_bReverseScroll ? -1 : 1 );
2002-02-24 10:31:20 +00:00
}
const float fCenterLine = 160; // from fYPos == 0
const float fFadeDist = 100;
// used by ArrowGetAlpha and ArrowGetGlow below
float ArrowGetPercentVisible( PlayerNumber pn, float fYPos )
2002-02-24 10:31:20 +00:00
{
2002-08-01 03:15:27 +00:00
const bool bReverse = GAMESTATE->m_PlayerOptions[pn].m_bReverseScroll;
const float fCorrectedYPos = bReverse ? -fYPos : fYPos;
const float fDistFromCenterLine = fCorrectedYPos - fCenterLine;
float fAlpha;
2002-08-01 03:15:27 +00:00
2002-07-29 03:06:55 +00:00
switch( GAMESTATE->m_PlayerOptions[pn].m_AppearanceType )
2002-02-24 10:31:20 +00:00
{
case PlayerOptions::APPEARANCE_VISIBLE:
fAlpha = 1;
break;
case PlayerOptions::APPEARANCE_HIDDEN:
fAlpha = SCALE( fDistFromCenterLine, 0, fFadeDist, 0, 1 );
2002-02-24 10:31:20 +00:00
break;
case PlayerOptions::APPEARANCE_SUDDEN:
fAlpha = SCALE( fDistFromCenterLine, 0, -fFadeDist, 0, 1 );
2002-02-24 10:31:20 +00:00
break;
case PlayerOptions::APPEARANCE_STEALTH:
fAlpha = 0;
break;
case PlayerOptions::APPEARANCE_BLINK: // this is an Ez2dancer Appearance Mode
fAlpha = sinf( TIMER->GetTimeSinceStart()*12 );
fAlpha = froundf( fAlpha, 0.3333f );
2002-02-24 10:31:20 +00:00
break;
default:
ASSERT(0);
2002-08-01 03:15:27 +00:00
fAlpha = 1;
}
if( fCorrectedYPos < 0 ) // past Gray Arrows
2002-02-24 10:31:20 +00:00
fAlpha = 1;
return clamp( fAlpha, 0, 1 );
}
2002-02-24 10:31:20 +00:00
2002-09-05 03:45:07 +00:00
float ArrowGetAlpha( PlayerNumber pn, float fYPos, float fPercentFadeToFail )
{
2002-09-05 03:45:07 +00:00
float fPercentVisible = ArrowGetPercentVisible(pn,fYPos);
if( fPercentFadeToFail != -1 )
fPercentVisible = 1 - fPercentFadeToFail;
return (fPercentVisible>0.5f) ? 1.0f : 0.0f;
}
2002-02-24 10:31:20 +00:00
2002-09-05 03:45:07 +00:00
float ArrowGetGlow( PlayerNumber pn, float fYPos, float fPercentFadeToFail )
{
2002-09-05 03:45:07 +00:00
float fPercentVisible = ArrowGetPercentVisible(pn,fYPos);
if( fPercentFadeToFail != -1 )
fPercentVisible = 1 - fPercentFadeToFail;
const float fDistFromHalf = fabsf( fPercentVisible - 0.5f );
return SCALE( fDistFromHalf, 0, 0.5f, 1.3f, 0 );
}