From a7b6da7851ea85366860d12ed93c5e1fdde39807 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Snellman=20V=C3=A4in=C3=B6=20Juhani?=
 <vaino.j.snellman@student.jyu.fi>
Date: Tue, 11 Oct 2022 00:50:22 +0300
Subject: [PATCH] =?UTF-8?q?Solution=20lis=C3=A4tty.?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 Sammakkopeli/Sammakkopeli.sln                 | 25 ++++++++
 Sammakkopeli/Sammakkopeli/Ohjelma.cs          | 25 ++++++++
 Sammakkopeli/Sammakkopeli/Sammakkopeli.cs     | 64 +++++++++++++++++++
 Sammakkopeli/Sammakkopeli/Sammakkopeli.csproj | 16 +++++
 4 files changed, 130 insertions(+)
 create mode 100644 Sammakkopeli/Sammakkopeli.sln
 create mode 100644 Sammakkopeli/Sammakkopeli/Ohjelma.cs
 create mode 100644 Sammakkopeli/Sammakkopeli/Sammakkopeli.cs
 create mode 100644 Sammakkopeli/Sammakkopeli/Sammakkopeli.csproj

diff --git a/Sammakkopeli/Sammakkopeli.sln b/Sammakkopeli/Sammakkopeli.sln
new file mode 100644
index 0000000..383c0ba
--- /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 0000000..2dab1d3
--- /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 0000000..75dcf83
--- /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 0000000..e62ffe8
--- /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>
+
-- 
GitLab