本文整理汇总了C++中TimeStep::delta方法的典型用法代码示例。如果您正苦于以下问题:C++ TimeStep::delta方法的具体用法?C++ TimeStep::delta怎么用?C++ TimeStep::delta使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TimeStep
的用法示例。
在下文中一共展示了TimeStep::delta方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
void main()
{
assetConfig.append(MainSlot, BetterflowAssets);
loader.init();
for (CubeID cube : CubeSet::connected())
{
onConnect(NULL, cube);
}
Events::cubeConnect.set(&onConnect);
gVideo[0].setMode(BG0);
MainMenu gameMenu(&gVideo[0]);
int colour;
Colormap colourList;
colourList.setEGA();
while(1)
{
colour = gameMenu.runMenu();
gVideo[0].setMode(SOLID_MODE);
gVideo[0].colormap[0].set(colourList[colour].get());
System::paint();
TimeStep ts;
TimeTicker ticker = TimeTicker(1);
int tickIncr;
int tickCount = 0;
do
{
tickIncr = ticker.tick( ts.delta() );
ts.next();
tickCount += tickIncr;
} while (tickCount < 3);
gVideo[0].setMode(BG0);
gVideo[0].bg0.erase(StripeTile);
}
}
示例2: main
void main()
{
GameState state = StateResults;
Random randomGen;
randomGen.seed();
for (unsigned i = 0; i < arraysize(cubeVideo); i++)
{
InitCube(i, i);
}
EventHandler handler;
handler.init();
TimeStep ts;
float Delay;
bool isDone;
while (1)
{
switch (state)
{
case StateInit:
CurrentGame->init();
Delay = 3;
playSfx (CountSound);
LOG ("Init\n");
state = StateStart;
break;
case StateStart:
Delay -= float(ts.delta());
if (Delay <= 0)
{
CurrentGame->start();
for (unsigned i = 0; i < gNumCubes; i++)
{
CurrentGameCube[i]->start();
}
LOG ("Start Done\n");
state = StatePlay;
}
break;
case StatePlay:
isDone = CurrentGame->update(ts.delta());
if (isDone)
{
LOG ("Game Done\n");
state = StateResults;
Delay = 3;
playSfx (CheersSound);
}
else
{
for (unsigned i = 0; i < gNumCubes; i++)
{
CurrentGameCube[i]->update(ts.delta());
}
}
break;
case StateResults:
Delay -= float(ts.delta());
if (Delay <= 0)
{
state = StateInit;
LOG ("Results Done\n");
int rand = randomGen.randint(0, 3);
switch (rand)
{
case 0:
case 2:
case 3:
LOG ("Playing Flip It\n");
CurrentGame = &flipItGame;
break;
case 1:
LOG ("Playing Shake\n");
CurrentGame = &shakeGame;
break;
}
}
break;
}
System::paint();
ts.next();
}
}
示例3: main
void main()
{
//Create our audio channels
AudioChannel a1(0);
AudioChannel a2(1);
AudioChannel a3(2);
AudioChannel a4(3);
AudioChannel a5(4);
AudioChannel a6(5);
channels[0] = &a1;
channels[1] = &a2;
channels[2] = &a3;
channels[3] = &a4;
channels[4] = &a5;
channels[5] = &a6;
r.seed();
channels[BALL_ROLL_CHANNEL]->play(sRollLoop, REPEAT); //Start playing rolling marble noise
channels[BALL_ROLL_CHANNEL]->setVolume(0);
for(int i = 0; i < NUM_CUBES; i++)
g_starsCollected[i] = 0;
for(int i = 0; i < NUM_COLORS; i++)
g_bColorsUsed[i] = false;
g_iBoardReset = -1;
g_iScore = -1;
TimeStep ts;
float fTapPromptDelay = 0.0;
int iBoardDied;
//Initialize our boards
for(int i = 0; i < NUM_CUBES; i++)
boards[i].init(i);
Events::neighborAdd.set(onNeighborAdd); //Function for when two cubes touch each other
Events::cubeTouch.set(onTouch); //Function for when a cube is tapped
//Add the marble to one of them
Float2 fVel;
fVel.set(0,0);
Float2 fPos = LCD_center;
fPos.x += TILE_WIDTH/2.0;
fPos.y += TILE_HEIGHT/2.0;
boards[0].addMarble(fPos, fVel);
TextDraw td;
bool bFirstSound = true;
//Main loop
while (1)
{
ts.next();
for(int i = 0; i < NUM_CUBES; i++)
{
int iMode;
switch(g_iCurMode)
{
case BOARD_NOTHING:
iMode = boards[i].update(float(ts.delta()));
//Update our rolling sound to the right volume
if(boards[i].hasMarble())
{
float fVol = boards[i].getMarbleVelocity() * 0.9;
if(fVol > MAX_VOLUME)
fVol = MAX_VOLUME;
channels[BALL_ROLL_CHANNEL]->setVolume(fVol);
}
if(iMode & BOARD_GOTPOINT)
{
iMode ^= BOARD_GOTPOINT;
g_iScore++;
if(++g_starsCollected[i] == NUM_STARS_CUBE)
g_iBoardReset = i;
//Play sound for getting a star, but not right on reset
if(bFirstSound)
bFirstSound = false;
else
channels[BALL_SFX_CHANNEL]->play(sGetStar);
}
if(iMode & BOARD_DIED)
{
//Show game over screen
iMode ^= BOARD_DIED;
iMode |= MODE_GAMEOVER;
td.draw(boards[i].getVid(), "Game over", 6);
String<64> s;
s << "Score: " << g_iScore;
td.draw(boards[i].getVid(), s.c_str(), 8);
fTapPromptDelay = 0.0;
iBoardDied = i;
bFirstSound = true;
channels[BALL_ROLL_CHANNEL]->setVolume(0);
channels[BALL_SFX_CHANNEL]->play(sDie);
}
if(iMode & BOARD_LEFT)
{
iMode ^= BOARD_LEFT;
if(g_iBoardReset == i)
{
boards[i].reset(g_bColorsUsed);
g_starsCollected[i] = 0;
g_iBoardReset = -1;
//.........这里部分代码省略.........