Fix bug when Space pressed...
This commit is contained in:
parent
f9fd68befe
commit
a245066b3c
|
@ -1,8 +1,10 @@
|
|||
# include "game.hpp"
|
||||
# include "states.hpp"
|
||||
|
||||
|
||||
PlayState PlayState::m_PlayState;
|
||||
|
||||
|
||||
void PlayState::Init()
|
||||
{
|
||||
Map = map();
|
||||
|
@ -64,6 +66,7 @@ void PlayState::HandleEvents ( game* Game )
|
|||
if ( event.type == SDL_QUIT)
|
||||
Game->Quit();
|
||||
|
||||
/* Game Over - Write name for score */
|
||||
if( nameEntering == true && nameEntered == false )
|
||||
{
|
||||
//Get user input
|
||||
|
@ -88,13 +91,16 @@ void PlayState::HandleEvents ( game* Game )
|
|||
|
||||
name.show_centered(Game);
|
||||
}
|
||||
/* Game key logic... */
|
||||
else
|
||||
{
|
||||
switch ( event.type )
|
||||
{
|
||||
/* key pressed.... */
|
||||
case SDL_KEYDOWN:
|
||||
switch ( event.key.keysym.sym )
|
||||
{
|
||||
/* ESCAPE - Pause game (run PauseState) */
|
||||
case SDLK_ESCAPE:
|
||||
{
|
||||
//Game->SetRunning(false);
|
||||
|
@ -102,8 +108,10 @@ void PlayState::HandleEvents ( game* Game )
|
|||
}
|
||||
break;
|
||||
|
||||
/* move part to the right */
|
||||
case SDLK_RIGHT:
|
||||
{
|
||||
/* */
|
||||
part p = Part;
|
||||
|
||||
# ifdef DEBUG
|
||||
|
@ -191,7 +199,7 @@ void PlayState::HandleEvents ( game* Game )
|
|||
{
|
||||
Part.move ( 0, 1 );
|
||||
|
||||
tick = FPS - 1;
|
||||
tick = ( FPS / ( ( level > 30 ) ? 30 : level ) ) - 1;
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -213,8 +221,10 @@ void PlayState::HandleEvents ( game* Game )
|
|||
|
||||
void PlayState::Update ( game* Game )
|
||||
{
|
||||
/* kontrola či je plné hracie pole... */
|
||||
if ( Map.isFull() )
|
||||
{
|
||||
/* Start enter name */
|
||||
nameEntering = true;
|
||||
|
||||
if (nameEntered)
|
||||
|
@ -246,8 +256,12 @@ void PlayState::Update ( game* Game )
|
|||
Part.move ( 0, 1 );
|
||||
}
|
||||
|
||||
/*
|
||||
if ( tick % ( FPS / ( ( level > 30 ) ? 30 : level ) ) != 0 && Map.isCollision ( Part ) && tick != ( FPS / ( ( level > 30 ) ? 30 : level ) ) -1 )
|
||||
std::cout << "DEBUG" << std::endl;
|
||||
*/
|
||||
|
||||
if ( Map.isCollision ( Part ) && tick + 1 == ( FPS / ( ( level > 30 ) ? 30 : level ) ) )
|
||||
if ( Map.isCollision ( Part ) && ( tick ) == ( FPS / ( ( level > 30 ) ? 30 : level ) ) -1 )
|
||||
{
|
||||
int count;
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user