Files
itgmania212121/stepmania/src/GrayArrow.cpp
T

73 lines
1.6 KiB
C++
Raw Normal View History

2001-12-01 23:46:09 +00:00
#include "stdafx.h"
2002-02-28 19:40:40 +00:00
/*
-----------------------------------------------------------------------------
Class: GrayArrow
2002-04-28 20:42:32 +00:00
Desc: A gray arrow that "receives" ColorNotes.
2002-02-28 19:40:40 +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-28 19:40:40 +00:00
Ben Nordstrom
Chris Danford
-----------------------------------------------------------------------------
*/
2001-12-01 23:46:09 +00:00
#include "GrayArrow.h"
2002-07-23 01:41:40 +00:00
#include "PrefsManager.h"
2002-07-28 20:28:37 +00:00
#include "GameState.h"
#include <math.h>
#include "ThemeManager.h"
2001-12-01 23:46:09 +00:00
2002-12-29 23:38:56 +00:00
#include "RageLog.h"
2002-07-28 20:28:37 +00:00
2002-08-28 22:42:40 +00:00
#define STEP_SECONDS THEME->GetMetricF("GrayArrow","StepSeconds")
#define STEP_ZOOM THEME->GetMetricF("GrayArrow","StepZoom")
float g_fStepSeconds, g_fStepZoom;
2001-12-01 23:46:09 +00:00
GrayArrow::GrayArrow()
{
2002-08-28 22:42:40 +00:00
g_fStepSeconds = STEP_SECONDS;
g_fStepZoom = STEP_ZOOM;
2001-12-01 23:46:09 +00:00
StopAnimating();
}
2002-07-28 20:28:37 +00:00
void GrayArrow::Update( float fDeltaTime )
2001-12-01 23:46:09 +00:00
{
2002-08-28 22:42:40 +00:00
ASSERT( Sprite::GetNumStates() > 0 ); // you forgot to call Load()
2002-07-28 20:28:37 +00:00
Sprite::Update( fDeltaTime );
2002-12-29 23:38:56 +00:00
/* These could be metrics or configurable. I'd prefer the flash to
* start on the beat, I think ... -glenn */
/* Start flashing 10% of a beat before the beat starts. */
const float flash_offset = -0.1f;
/* Flash for 20% of a beat. */
const float flash_length = 0.2f;
float cur_beat = GAMESTATE->m_fSongBeat;
/* Make sure that the first flash (when cur_beat is passing 0) is just as
* long as others. */
cur_beat += 1.0f;
cur_beat -= flash_offset;
float fPercentIntoBeat = fmodf(cur_beat, 1);
int iNewState = (fPercentIntoBeat < flash_length)? 0:1;
2002-07-29 03:06:55 +00:00
CLAMP( iNewState, 0, Sprite::GetNumStates() );
2002-04-16 17:31:00 +00:00
SetState( iNewState );
2001-12-01 23:46:09 +00:00
}
2002-02-24 01:43:11 +00:00
void GrayArrow::Step()
2001-12-01 23:46:09 +00:00
{
2002-08-28 22:42:40 +00:00
SetZoom( g_fStepZoom );
StopTweening();
2002-08-28 22:42:40 +00:00
BeginTweening( g_fStepSeconds );
SetTweenZoom( 1 );
2001-12-01 23:46:09 +00:00
}