Scroll wheel to change speed

master
MitchellHansen 9 years ago
parent 43083c3aaa
commit 5792723392

@ -7,16 +7,22 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Flappy", "Flappy\Flappy.vcx
EndProject EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Debug|x64 = Debug|x64 Debug|x64 = Debug|x64
Debug|x86 = Debug|x86 Debug|x86 = Debug|x86
Release|Win32 = Release|Win32
Release|x64 = Release|x64 Release|x64 = Release|x64
Release|x86 = Release|x86 Release|x86 = Release|x86
EndGlobalSection EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution GlobalSection(ProjectConfigurationPlatforms) = postSolution
{9035B83C-F117-480E-9DEB-435AA0EBEA3F}.Debug|Win32.ActiveCfg = Debug|Win32
{9035B83C-F117-480E-9DEB-435AA0EBEA3F}.Debug|Win32.Build.0 = Debug|Win32
{9035B83C-F117-480E-9DEB-435AA0EBEA3F}.Debug|x64.ActiveCfg = Debug|x64 {9035B83C-F117-480E-9DEB-435AA0EBEA3F}.Debug|x64.ActiveCfg = Debug|x64
{9035B83C-F117-480E-9DEB-435AA0EBEA3F}.Debug|x64.Build.0 = Debug|x64 {9035B83C-F117-480E-9DEB-435AA0EBEA3F}.Debug|x64.Build.0 = Debug|x64
{9035B83C-F117-480E-9DEB-435AA0EBEA3F}.Debug|x86.ActiveCfg = Debug|Win32 {9035B83C-F117-480E-9DEB-435AA0EBEA3F}.Debug|x86.ActiveCfg = Debug|Win32
{9035B83C-F117-480E-9DEB-435AA0EBEA3F}.Debug|x86.Build.0 = Debug|Win32 {9035B83C-F117-480E-9DEB-435AA0EBEA3F}.Debug|x86.Build.0 = Debug|Win32
{9035B83C-F117-480E-9DEB-435AA0EBEA3F}.Release|Win32.ActiveCfg = Release|Win32
{9035B83C-F117-480E-9DEB-435AA0EBEA3F}.Release|Win32.Build.0 = Release|Win32
{9035B83C-F117-480E-9DEB-435AA0EBEA3F}.Release|x64.ActiveCfg = Release|x64 {9035B83C-F117-480E-9DEB-435AA0EBEA3F}.Release|x64.ActiveCfg = Release|x64
{9035B83C-F117-480E-9DEB-435AA0EBEA3F}.Release|x64.Build.0 = Release|x64 {9035B83C-F117-480E-9DEB-435AA0EBEA3F}.Release|x64.Build.0 = Release|x64
{9035B83C-F117-480E-9DEB-435AA0EBEA3F}.Release|x86.ActiveCfg = Release|Win32 {9035B83C-F117-480E-9DEB-435AA0EBEA3F}.Release|x86.ActiveCfg = Release|Win32

@ -79,6 +79,8 @@
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental> <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>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental> <LinkIncremental>false</LinkIncremental>
@ -125,12 +127,14 @@
<IntrinsicFunctions>true</IntrinsicFunctions> <IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck> <SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>Z:\Cpp_Libs\SFML-Visual_Studio2015RCx32\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile> </ClCompile>
<Link> <Link>
<SubSystem>Console</SubSystem> <SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation> <GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding> <EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences> <OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>sfml-graphics.lib;sfml-audio.lib;sfml-network.lib;sfml-system.lib;sfml-window.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link> </Link>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">

@ -55,6 +55,7 @@ int main()
float step_size = 0.005f; 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; 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; int render_frame_count = 0, physics_frame_count = 0;
float speed = 250;
while (window.isOpen()) while (window.isOpen())
{ {
@ -63,6 +64,11 @@ int main()
if (event.type == sf::Event::Closed) { if (event.type == sf::Event::Closed) {
window.close(); window.close();
} }
if (event.type == sf::Event::MouseWheelScrolled) {
if (event.mouseWheelScroll.wheel == sf::Mouse::VerticalWheel) {
speed += event.mouseWheelScroll.delta * 20;
}
}
} }
elapsed_time = elap_time(); elapsed_time = elap_time();
@ -83,22 +89,22 @@ int main()
pipe_up_sprite.setPosition(WINDOW_X, pipe_down_sprite.getPosition().y + pipe_dist); pipe_up_sprite.setPosition(WINDOW_X, pipe_down_sprite.getPosition().y + pipe_dist);
} }
else { else {
pipe_up_sprite.setPosition(pipe_up_sprite.getPosition().x - step_size * 250, pipe_up_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 * 250, pipe_down_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) { if (background_sprite.getPosition().x + background_sprite.getGlobalBounds().width < WINDOW_X) {
background_sprite.setPosition(0, 0); background_sprite.setPosition(0, 0);
} }
else { 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) { if (land_sprite.getPosition().x + 10 + land_sprite.getGlobalBounds().width < WINDOW_X) {
land_sprite.setPosition(14, land_sprite.getPosition().y); land_sprite.setPosition(14, land_sprite.getPosition().y);
} }
else { 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 // Check collisions

Loading…
Cancel
Save