//The Jump Function
void Player::jump()
{
set_velocities(0, -30);
set_auto_move(40);
set_y_acceleration(9.8);
set_auto_accelerate(40);
}
//Which is stopped by this to stop the
if(player->get_y() > 300)
{
player->set_y_velocity(0);
player->set_y_acceleration(0);
player->set_world_position_y(300);
isJumping = false;
}
//The screen collision code is just put in with the SDK_KEYDOWN stuff
case SDLK_LEFT:
if(player->get_x() >= 10)
player->moveHorizontally(-10); break;
case SDLK_RIGHT:
if(player->get_x() + player->get_width() <= 630)
player->moveHorizontally(10); break;
[size=4]//And the moveHorizontally function
void Player::moveHorizontally(float speed)
{
set_velocities(speed, 0);
move();
}
Show differencesHistory of post edits
#ActualMrChrisnis
Posted 30 September 2012 - 01:39 PM
#4MrChrisnis
Posted 30 September 2012 - 01:39 PM
//The Jump Function
void Player::jump()
{
set_velocities(0, -30);
set_auto_move(40);
set_y_acceleration(9.8);
set_auto_accelerate(40);
}
//Which is stopped by this to stop the
if(player->get_y() > 300)
{
player->set_y_velocity(0);
player->set_y_acceleration(0);
player->set_world_position_y(300);
isJumping = false;
}
//The screen collision code is just put in with the SDK_KEYDOWN stuff
case SDLK_LEFT:
if(player->get_x() >= 10)
[/size] player->moveHorizontally(-10); break;
[size=4]case SDLK_RIGHT:
if(player->get_x() + player->get_width() <= 630)
[/size] player->moveHorizontally(10); break;
[size=4]//And the moveHorizontally function
void Player::moveHorizontally(float speed)
{
set_velocities(speed, 0);
move();
}
#3MrChrisnis
Posted 30 September 2012 - 01:38 PM
//The Jump Function
void Player::jump()
{
set_velocities(0, -30);
set_auto_move(40);
set_y_acceleration(9.8);
set_auto_accelerate(40);
}
//Which is stopped by this to stop the
if(player->get_y() > 300)
{
player->set_y_velocity(0);
player->set_y_acceleration(0);
player->set_world_position_y(300);
isJumping = false;
}
//The screen collision code is just put in with the SDK_KEYDOWN stuff
case SDLK_LEFT:
if(player->get_x() >= 10)
player->moveHorizontally(-10); break;
case SDLK_RIGHT:
if(player->get_x() + player->get_width() <= 630)
player->moveHorizontally(10); break;
//And the moveHorizontally function
void Player::moveHorizontally(float speed)
{
set_velocities(speed, 0);
move();
}
#2MrChrisnis
Posted 30 September 2012 - 01:37 PM
//The Jump Function
void Player::jump()
{
set_velocities(0, -30);
set_auto_move(40);
set_y_acceleration(9.8);
set_auto_accelerate(40);
}
//Which is stopped by this to stop the
if(player->get_y() > 300)
{
player->set_y_velocity(0);
player->set_y_acceleration(0);
player->set_world_position_y(300);
isJumping = false;
}
//The screen collision code is just put in with the SDK_KEYDOWN stuff
case SDLK_LEFT:
if(player->get_x() >= 10)
player->moveHorizontally(-10); break;
case SDLK_RIGHT:
if(player->get_x() + player->get_width() <= 630)
player->moveHorizontally(10); break;
//And the moveHorizontally function
void Player::moveHorizontally(float speed)
{
set_velocities(speed, 0);
move();
}
#1MrChrisnis
Posted 30 September 2012 - 01:37 PM
[source lang="cpp"]//The Jump Functionvoid Player::jump(){ set_velocities(0, -30); set_auto_move(40); set_y_acceleration(9.8); set_auto_accelerate(40);}//Which is stopped by this to stop the if(player->get_y() > 300) { player->set_y_velocity(0); player->set_y_acceleration(0); player->set_world_position_y(300); isJumping = false; }//The screen collision code is just put in with the SDK_KEYDOWN stuffcase SDLK_LEFT: if(player->get_x() >= 10) player->moveHorizontally(-10); break; case SDLK_RIGHT: if(player->get_x() + player->get_width() <= 630) player->moveHorizontally(10); break;//And the moveHorizontally functionvoid Player::moveHorizontally(float speed){ set_velocities(speed, 0); move();}[/source]