diff --git a/Sammakkopeli/Sammakkopeli.sln b/Sammakkopeli/Sammakkopeli.sln new file mode 100644 index 0000000000000000000000000000000000000000..383c0bad9e0bd362523b45bb72494358e999101b --- /dev/null +++ b/Sammakkopeli/Sammakkopeli.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.3.32825.248 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sammakkopeli", "Sammakkopeli\Sammakkopeli.csproj", "{089E442E-4A40-4DBF-8D92-AE510482B764}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {089E442E-4A40-4DBF-8D92-AE510482B764}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {089E442E-4A40-4DBF-8D92-AE510482B764}.Debug|Any CPU.Build.0 = Debug|Any CPU + {089E442E-4A40-4DBF-8D92-AE510482B764}.Release|Any CPU.ActiveCfg = Release|Any CPU + {089E442E-4A40-4DBF-8D92-AE510482B764}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {B9577520-187E-4D34-BB7D-9968BDEDBBEE} + EndGlobalSection +EndGlobal diff --git a/Sammakkopeli/Sammakkopeli/Ohjelma.cs b/Sammakkopeli/Sammakkopeli/Ohjelma.cs new file mode 100644 index 0000000000000000000000000000000000000000..2dab1d36952b4d422898b9d64db95bdb99fc22a4 --- /dev/null +++ b/Sammakkopeli/Sammakkopeli/Ohjelma.cs @@ -0,0 +1,25 @@ +#region Using Statements +using System; +using System.Collections.Generic; +using System.Linq; + +#endregion + +namespace Sammakkopeli +{ + /// <summary> + /// The main class. + /// </summary> + public static class Program + { + /// <summary> + /// The main entry point for the application. + /// </summary> + [STAThread] + static void Main() + { + using var game = new Sammakkopeli(); + game.Run(); + } + } +} diff --git a/Sammakkopeli/Sammakkopeli/Sammakkopeli.cs b/Sammakkopeli/Sammakkopeli/Sammakkopeli.cs new file mode 100644 index 0000000000000000000000000000000000000000..75dcf836c911164afc10cf4cb43a89a8e892c5c6 --- /dev/null +++ b/Sammakkopeli/Sammakkopeli/Sammakkopeli.cs @@ -0,0 +1,64 @@ +using Jypeli; +using Jypeli.Assets; +using Jypeli.Controls; +using Jypeli.Widgets; +using System; +using System.Collections.Generic; + +namespace Sammakkopeli +{ + public class Sammakkopeli : PhysicsGame + { + Vector sammakkoVasen = new Vector(-500, -400); + Vector sammakkoOikea = new Vector(500, -400); + Vector sammakkoPainovoima = new Vector(0, -400); + + PhysicsObject sammakko; + + + public override void Begin() + { + AlustaKentta(); + AsetaOhjaimet(); + Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli"); + } + + + public void AsetaOhjaimet() + { + Keyboard.Listen(Key.Left, ButtonState.Down, LiikutaPelihahmoa, null, sammakkoVasen); + Keyboard.Listen(Key.Left, ButtonState.Released, LiikutaPelihahmoa, null, sammakkoPainovoima); + + Keyboard.Listen(Key.Right, ButtonState.Down, LiikutaPelihahmoa, null, sammakkoOikea); + Keyboard.Listen(Key.Right, ButtonState.Released, LiikutaPelihahmoa, null, sammakkoPainovoima); + } + + + public void AlustaKentta() + { + Level.BackgroundColor = Color.Black; + LuoPelihahmo(0, 0); + + Level.CreateBottomBorder(0.0, true); + } + + + public void LuoPelihahmo(double x, double y) + { + sammakko = new PhysicsObject(40.0, 26.0); + sammakko.Shape = Shape.Rectangle; + sammakko.X = x; + sammakko.Y = y; + sammakko.Color = Color.Green; + sammakko.Velocity = sammakkoPainovoima; + Add(sammakko); + } + + + + public void LiikutaPelihahmoa(Vector suunta) + { + sammakko.Velocity = suunta; + } + } +} \ No newline at end of file diff --git a/Sammakkopeli/Sammakkopeli/Sammakkopeli.csproj b/Sammakkopeli/Sammakkopeli/Sammakkopeli.csproj new file mode 100644 index 0000000000000000000000000000000000000000..e62ffe87ec132b3e82a1ffa39e7a53a1907bbc52 --- /dev/null +++ b/Sammakkopeli/Sammakkopeli/Sammakkopeli.csproj @@ -0,0 +1,16 @@ +<Project Sdk="Microsoft.NET.Sdk"> + + <PropertyGroup> + <OutputType>WinExe</OutputType> + <TargetFramework>net6.0</TargetFramework> + <PublishReadyToRun>false</PublishReadyToRun> + <TieredCompilation>false</TieredCompilation> + </PropertyGroup> + + <ItemGroup> + <PackageReference Include="Jypeli.NET" Version="11.*" /> + <PackageReference Include="Jypeli.FarseerPhysics.NET" Version="2.*" /> + </ItemGroup> + +</Project> +