diff --git "a/peli/harkkaty\303\266/pomppu possu/pomppu possu.cs" "b/peli/harkkaty\303\266/pomppu possu/pomppu possu.cs" index 9b008bcf2e3bdfb32d800de8de30a22f3c011e51..2981654015800a0061508c9a90af868c0de22a89 100644 --- "a/peli/harkkaty\303\266/pomppu possu/pomppu possu.cs" +++ "b/peli/harkkaty\303\266/pomppu possu/pomppu possu.cs" @@ -1,31 +1,30 @@ -using System; -using System.Collections.Generic; + using Jypeli; -using Jypeli.Assets; -using Jypeli.Controls; -using Jypeli.Widgets; namespace pomppu_possu; +// TODO: Taulukko, silmukka ja funktio, Leo, ks: https://tim.jyu.fi/answers/kurssit/tie/ohj1/v/2025/kevat/demot/demo6?answerNumber=1&task=TeeTaulukko&user=leosaksa +// TODO: Taulukko, silmukka ja funktio, Suvi, ks: https://tim.jyu.fi/answers/kurssit/tie/ohj1/v/2025/kevat/demot/demo6?answerNumber=2&task=TeeTaulukko&user=suvleean + /// @author suvitoivanen, leosaksa /// @version 02.04.2025 /// <summary> /// Eeppinen tasohyppely peli, jossa pelaajan tehtävä on kerätä kaikki -/// kartalta löytyvät megaporkkanat (13kpl) +/// kartalta löytyvät megaporkkanat /// </summary> public class PomppuPossu : PhysicsGame { - private const double NOPEUS = 200; - private const double HYPPYNOPEUS = 750; - private const int RUUDUN_KOKO = 60; + private const double Nopeus = 200; + private const double Hyppynopeus = 750; + private const int RuudunKoko = 60; - private PlatformCharacter pomppuPossu; + private PlatformCharacter _pomppuPossu; private Image _pomppuPossunKuva = LoadImage("pomppupossu.png"); private Image _porkkanaKuva = LoadImage("porkkananKuva3.png"); private SoundEffect _pisteAani = LoadSoundEffect("maali.wav"); - private IntMeter pelaajanPisteet; + private IntMeter _pelaajanPisteet; /// <summary> @@ -37,16 +36,16 @@ public class PomppuPossu : PhysicsGame LuoKentta(); LisaaLaskuri(); - Camera.Follow(pomppuPossu); + Camera.Follow(_pomppuPossu); Camera.ZoomFactor = 1.2; Camera.StayInLevel = true; MasterVolume = 0.5; Level.CreateBorders(); - Keyboard.Listen(Key.Up, ButtonState.Pressed, Hyppaa, "Pelaaja hyppää", pomppuPossu, HYPPYNOPEUS); - Keyboard.Listen(Key.Left, ButtonState.Down, Liikuta, "Liikuttaa pelaajaa vasemmalle", pomppuPossu, -NOPEUS); - Keyboard.Listen(Key.Right, ButtonState.Down, Liikuta, "Liikuttaa pelaajaa oikealle", pomppuPossu, NOPEUS); + Keyboard.Listen(Key.Up, ButtonState.Pressed, Hyppaa, "Pelaaja hyppää", _pomppuPossu, Hyppynopeus); + Keyboard.Listen(Key.Left, ButtonState.Down, Liikuta, "Liikuttaa pelaajaa vasemmalle", _pomppuPossu, -Nopeus); + Keyboard.Listen(Key.Right, ButtonState.Down, Liikuta, "Liikuttaa pelaajaa oikealle", _pomppuPossu, Nopeus); Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli"); } @@ -62,7 +61,7 @@ public class PomppuPossu : PhysicsGame kentta.SetTileMethod('#', LisaaTaso); kentta.SetTileMethod('N', LisaaPelaaja); kentta.SetTileMethod('*', LisaaPorkkana); - kentta.Execute(RUUDUN_KOKO, RUUDUN_KOKO); + kentta.Execute(RuudunKoko, RuudunKoko); Level.Background.CreateGradient(Color.White, Color.SkyBlue); } @@ -107,12 +106,12 @@ public class PomppuPossu : PhysicsGame /// <param name="korkeus">korkeus</param> private void LisaaPelaaja(Vector paikka, double leveys, double korkeus) { - pomppuPossu = new PlatformCharacter(80, 100); - pomppuPossu.Position = paikka; - pomppuPossu.Mass = 4.0; - pomppuPossu.Image = _pomppuPossunKuva; - AddCollisionHandler<PhysicsObject, Megaporkkanat>(pomppuPossu, TormattiinEsineeseen); - Add(pomppuPossu); + _pomppuPossu = new PlatformCharacter(80, 100); + _pomppuPossu.Position = paikka; + _pomppuPossu.Mass = 4.0; + _pomppuPossu.Image = _pomppuPossunKuva; + AddCollisionHandler<PhysicsObject, Megaporkkanat>(_pomppuPossu, TormattiinEsineeseen); + Add(_pomppuPossu); } @@ -151,7 +150,7 @@ public class PomppuPossu : PhysicsGame kohde.OtaVastaanOsuma(); _pisteAani.Play(); MessageDisplay.Add("Megaporkkana kerätty!"); - pelaajanPisteet.Value += 1; + _pelaajanPisteet.Value += 1; } @@ -196,7 +195,7 @@ public class PomppuPossu : PhysicsGame /// </summary> void LisaaLaskuri() { - pelaajanPisteet = LuoPisteLaskuri(Screen.Right - 100.0, Screen.Top - 100.0); + _pelaajanPisteet = LuoPisteLaskuri(Screen.Right - 100.0, Screen.Top - 100.0); }