From 61de43f27f584b067e0b2aad4ebe9765932261bb Mon Sep 17 00:00:00 2001 From: Miettinen Miklas <miklas.miettinen@gmail.com> Date: Wed, 19 Mar 2025 13:51:12 +0200 Subject: [PATCH] =?UTF-8?q?ruletti=20py=C3=B6r=C3=A4ys=20ja=20muuta=20haus?= =?UTF-8?q?kaa?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Financial_Freedom/Data/toplistsave.txt | 2 +- .../Financial_Freedom/Financial_Freedom.cs | 112 +++++++++++++++++- .../Financial_Freedom.csproj | 3 + 3 files changed, 114 insertions(+), 3 deletions(-) diff --git a/Financial_Freedom/Financial_Freedom/Data/toplistsave.txt b/Financial_Freedom/Financial_Freedom/Data/toplistsave.txt index 22e5108..d68a3e6 100644 --- a/Financial_Freedom/Financial_Freedom/Data/toplistsave.txt +++ b/Financial_Freedom/Financial_Freedom/Data/toplistsave.txt @@ -29,7 +29,7 @@ </Item> <Item Index="3" Type="Jypeli.ScoreItem, Jypeli, Version=11.3.7.0, Culture=neutral, PublicKeyToken=null"> <Field Name="Name" Type="System.String, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e"> - <Value>miku</Value> + <Value>jonttu</Value> </Field> <Field Name="Score" Type="System.Double, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e"> <Value>24999749975</Value> diff --git a/Financial_Freedom/Financial_Freedom/Financial_Freedom.cs b/Financial_Freedom/Financial_Freedom/Financial_Freedom.cs index 7fbf982..18c1fb3 100644 --- a/Financial_Freedom/Financial_Freedom/Financial_Freedom.cs +++ b/Financial_Freedom/Financial_Freedom/Financial_Freedom.cs @@ -145,7 +145,11 @@ public class Financial_Freedom : PhysicsGame IsFullScreen = true; Level.Size = Screen.Size; Camera.ZoomToLevel(); + + tavoiteSaavutettu = false; + Valikko(); + } public void Valikko() // lore @@ -174,6 +178,7 @@ public class Financial_Freedom : PhysicsGame pistelaskuri.Value += 1000; AloitusRaha = true; + topLista.EnterText = "Onnittelut, olet päässyt kymmenen parhaimman uhkapelaajan joukkoon! Syötä nimesi niin jäät historian kirjoihin."; topLista.Text = "Parhaat uhkapelaajat"; topLista.HighScoreWindow.Size = new Vector(300,400); @@ -1383,6 +1388,8 @@ public class Financial_Freedom : PhysicsGame ohjeet.Position = new Vector(Screen.Right-575, Screen.Top-25); Add(ohjeet); + + // Tausta panostusalueelle GameObject panostusAlue = new GameObject(Screen.Width / 4, Screen.Height / 2, Shape.Rectangle); panostusAlue.Color = Color.DarkGreen; @@ -1620,14 +1627,114 @@ public class Financial_Freedom : PhysicsGame MessageDisplay.Add($"Panokset on jaettu kohtiin:{string.Join(", ", Betit)}"); Console.WriteLine($"Panokset on jaettu kohtiin:{string.Join(", ", Betit)}"); Console.WriteLine($"Panos per kohde on {panos} jaettuna {clickLog.Count} on {panos/clickLog.Count}"); - RulettiAnimaatio(); + RulettiLauta(this, 850, 25, 40, 0, 0); TakaisinPV(); } - void RulettiAnimaatio() + + /// <summary> + /// + /// </summary> + /// <param name="peli">peli johon "animaatio" luodaan</param> + /// <param name="ph">halkaisian pituus jolla pallo pyörii</param> + /// <param name="betpalloH">näkyvän pyörivän pallon koko</param> + /// <param name="pn">pyörimis nopeus</param> + public async Task RulettiLauta(Game peli, double ph,double betpalloH , double pn, double x, double y ) + { + bool pyorii = false; + + PhysicsObject pelilauta = new PhysicsObject(ph + 2 * betpalloH, ph + 2 * betpalloH, Shape.Circle, x, y); + pelilauta.AddCollisionIgnoreGroup(1); + pelilauta.Image = LoadImage("rulettipöytä.png"); + peli.Add(pelilauta); + + PhysicsObject transpallo = new PhysicsObject(ph, ph, Shape.Circle, x, y); + transpallo.Color = Color.Transparent; + transpallo.AddCollisionIgnoreGroup(1); + peli.Add(transpallo); + + + PhysicsObject betpallo = new PhysicsObject(betpalloH, betpalloH,Shape.Circle, ph/2 - ph/10 , y); + betpallo.Color = Color.Gold; + transpallo.Add(betpallo); + + + PhysicsObject pistePallo = new PhysicsObject(10,10,Shape.Circle, x-10, y+10); + pistePallo.AddCollisionIgnoreGroup(1); + pelilauta.Add(pistePallo); + + List<Angle> checkAngles = new List<Angle>(); + + + Keyboard.Listen(Key.Space, ButtonState.Pressed, async () => await pyorautalauta(transpallo, pelilauta, pn, pyorii, checkAngles),"pyöräyttää laudan ja pallon"); + } + + public async Task pyorautalauta(PhysicsObject transpallo, PhysicsObject pelilauta, double pn, bool pyorii, List<Angle> checkAngles) + { + transpallo.AngularDamping = RandomGen.NextDouble(0.7,2);// molemmat hidastuu eri nopeuksilla + pelilauta.AngularDamping = RandomGen.NextDouble(0.3,0.5); + transpallo.AngularVelocity = pn + RandomGen.NextDouble(4, 10); + pelilauta.AngularVelocity = -pn + RandomGen.NextDouble(-10, -5); + pyorii = true; + peliKesken += 1; + bool samaNopeus = false; + + while (pyorii) + { + if (transpallo.AngularVelocity <= 1 && !samaNopeus) + { + transpallo.AngularDamping += 2; + if (transpallo.AngularVelocity == 0) + { + transpallo.AngularVelocity = pelilauta.AngularVelocity; + transpallo.AngularDamping = pelilauta.AngularDamping; + samaNopeus = true; + } + + } + + if (pelilauta.AngularVelocity == 0) + { + pyorii = false; + rulepisteenlasku(transpallo, pelilauta, checkAngles); + } + await Task.Delay(100); + } + } + public async Task rulepisteenlasku(PhysicsObject transpallo, PhysicsObject pelilauta, List<Angle> checkAngles) + { + double realangle = (transpallo.Angle.Degrees - pelilauta.Angle.Degrees) % 360; + Console.WriteLine(transpallo.Angle.GetPositiveDegrees()); + Console.WriteLine(pelilauta.Angle.GetPositiveDegrees()); + if (realangle < 0) { realangle += 360; } + Console.WriteLine(realangle); + MessageDisplay.Add("aloitetaan tarkistus"); + Console.WriteLine("aloitetaan tarkistus"); + + palloangle(realangle); + + peliKesken -= 1; + } + + public static double palloangle(double realangle) { + bool tarkastettu = false; + while (tarkastettu == false) + { + foreach (var angle in rulettitaskut) + { + if (realangle > angle.kulmat) + { + Console.WriteLine(angle.arvo); + tarkastettu = true; + return angle.numerot; + } + } + } + return -1; } + public async Task Slots() { @@ -2262,6 +2369,7 @@ public class Financial_Freedom : PhysicsGame peliKesken = 0; peliOhi = false; pistelaskuri = null; + highScore = 0; Begin(); }, "uus kiesi"); } diff --git a/Financial_Freedom/Financial_Freedom/Financial_Freedom.csproj b/Financial_Freedom/Financial_Freedom/Financial_Freedom.csproj index be0bc21..b9e7be8 100644 --- a/Financial_Freedom/Financial_Freedom/Financial_Freedom.csproj +++ b/Financial_Freedom/Financial_Freedom/Financial_Freedom.csproj @@ -335,6 +335,9 @@ <None Update="Content\RouletteBG.png"> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> </None> + <None Update="Content\rulettipöytä.png"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </None> </ItemGroup> <ItemGroup> -- GitLab