Scroll wheel to change speed
This commit is contained in:
@@ -79,6 +79,8 @@
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<IncludePath>Z:\Cpp_Libs\SFML-Visual_Studio2015RCx32\include;$(IncludePath)</IncludePath>
|
||||
<LibraryPath>Z:\Cpp_Libs\SFML-Visual_Studio2015RCx32\lib;$(LibraryPath)</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
@@ -125,12 +127,14 @@
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<AdditionalIncludeDirectories>Z:\Cpp_Libs\SFML-Visual_Studio2015RCx32\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalDependencies>sfml-graphics.lib;sfml-audio.lib;sfml-network.lib;sfml-system.lib;sfml-window.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
|
||||
@@ -55,6 +55,7 @@ int main()
|
||||
float step_size = 0.005f;
|
||||
double frame_time = 0.0, instant_fps = 0.0, render_fps = 0.0, physics_fps = 0.0, elapsed_time = 0.0, delta_time = 0.0, accumulator_time = 0.0, current_time = 0.0;
|
||||
int render_frame_count = 0, physics_frame_count = 0;
|
||||
float speed = 250;
|
||||
|
||||
while (window.isOpen())
|
||||
{
|
||||
@@ -63,6 +64,11 @@ int main()
|
||||
if (event.type == sf::Event::Closed) {
|
||||
window.close();
|
||||
}
|
||||
if (event.type == sf::Event::MouseWheelScrolled) {
|
||||
if (event.mouseWheelScroll.wheel == sf::Mouse::VerticalWheel) {
|
||||
speed += event.mouseWheelScroll.delta * 20;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
elapsed_time = elap_time();
|
||||
@@ -83,22 +89,22 @@ int main()
|
||||
pipe_up_sprite.setPosition(WINDOW_X, pipe_down_sprite.getPosition().y + pipe_dist);
|
||||
}
|
||||
else {
|
||||
pipe_up_sprite.setPosition(pipe_up_sprite.getPosition().x - step_size * 250, pipe_up_sprite.getPosition().y);
|
||||
pipe_down_sprite.setPosition(pipe_down_sprite.getPosition().x - step_size * 250, pipe_down_sprite.getPosition().y);
|
||||
pipe_up_sprite.setPosition(pipe_up_sprite.getPosition().x - step_size * speed, pipe_up_sprite.getPosition().y);
|
||||
pipe_down_sprite.setPosition(pipe_down_sprite.getPosition().x - step_size * speed, pipe_down_sprite.getPosition().y);
|
||||
}
|
||||
|
||||
if (background_sprite.getPosition().x + background_sprite.getGlobalBounds().width < WINDOW_X) {
|
||||
background_sprite.setPosition(0, 0);
|
||||
}
|
||||
else {
|
||||
background_sprite.setPosition(background_sprite.getPosition().x - step_size * 150, background_sprite.getPosition().y);
|
||||
background_sprite.setPosition(background_sprite.getPosition().x - step_size * (speed - 100), background_sprite.getPosition().y);
|
||||
}
|
||||
|
||||
if (land_sprite.getPosition().x + 10 + land_sprite.getGlobalBounds().width < WINDOW_X) {
|
||||
land_sprite.setPosition(14, land_sprite.getPosition().y);
|
||||
}
|
||||
else {
|
||||
land_sprite.setPosition(land_sprite.getPosition().x - step_size * 250, land_sprite.getPosition().y);
|
||||
land_sprite.setPosition(land_sprite.getPosition().x - step_size * speed, land_sprite.getPosition().y);
|
||||
}
|
||||
|
||||
// Check collisions
|
||||
|
||||
Reference in New Issue
Block a user