- Timestamp:
- 2015-06-12 11:40:00 (7 years ago)
- Location:
- 2015/24/JustusL
- Files:
-
- 2 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
2015/24/JustusL/1D peli/1D peli/_1D_peli.cs
r6027 r6058 10 10 { 11 11 EasyHighScore topLista = new EasyHighScore(); 12 Timer ajastin;13 12 IntMeter elamaLaskuri; 14 13 IntMeter pisteLaskuri; … … 17 16 const double ACTIVE_AREA_HEIGHT = 30.0; 18 17 const double KORKEUS = 350.0; 18 19 Vector alkunopeus = new Vector(0, 110); 19 20 Vector nopeus = new Vector(0, 110); 20 double kerroin = 1.25; 21 //double kerroin = 1.25; 22 Boolean peliKaynnissa = false; 21 23 22 24 public override void Begin() … … 27 29 Level.Height = (int)Screen.Height; 28 30 29 PalkinAjastin();31 //PalkinAjastin(); 30 32 LuoPalkki(); 31 33 LuoMaali(); … … 33 35 Ohjaimet(); 34 36 ElamaLaskuri(); 37 NopeusAjastin(); 38 39 peliKaynnissa = true; 35 40 36 41 PhoneBackButton.Listen(ConfirmExit, "Lopeta peli"); 37 42 Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli"); 43 ControllerOne.Listen(Button.Back, ButtonState.Pressed, ConfirmExit, "Lopeta peli"); 38 44 } 39 45 … … 43 49 44 50 PhysicsObject palkki = PhysicsObject.CreateStaticObject(Level.Width, 100.0); 45 palkki.MaximumLifetime = TimeSpan.FromSeconds( 8);51 palkki.MaximumLifetime = TimeSpan.FromSeconds(10); 46 52 Add(palkki); 47 53 palkki.Position = new Vector(0, Level.Bottom); … … 50 56 } 51 57 52 void PalkinAjastin() 53 { 54 ajastin = new Timer(); 55 ajastin.Interval = 1; // ajastimen aika sec. 56 ajastin.Timeout += LuoPalkki; 57 ajastin.Start(); 58 58 //void PalkinAjastin() 59 //{ 60 // ajastin = new Timer(); 61 // ajastin.Interval = 1; // ajastimen aika sec. 62 // ajastin.Timeout += LuoPalkki; 63 // ajastin.Start(); 64 65 // vaikeus = new Timer(); 66 // vaikeus.Interval = 3; 67 // vaikeus.Timeout += delegate 68 // { 69 // nopeus.Y = nopeus.Y * kerroin; 70 // kerroin += 0.14; 71 72 // List<GameObject> fysiikkaOliot = GetObjects(x => x is PhysicsObject); 73 74 // foreach (PhysicsObject olio in fysiikkaOliot) 75 // { 76 // PhysicsObject olioFys = olio as PhysicsObject; 77 // olio.Velocity = nopeus; 78 // } 79 80 // ajastin.Interval = ajastin.Interval - 0.2; 81 82 // }; 83 // vaikeus.Start(3); 84 85 //} 86 void NopeusAjastin() 87 { 59 88 vaikeus = new Timer(); 60 vaikeus.Interval = 3;89 vaikeus.Interval = 10; 61 90 vaikeus.Timeout += delegate 62 91 { 63 nopeus.Y = nopeus.Y * kerroin; 64 kerroin += 0.14; 65 92 //kerroin += 0.14; 93 nopeus.Y = nopeus.Y + 35; 94 }; 95 vaikeus.Start(); 96 } 97 protected override void Update(Microsoft.Xna.Framework.GameTime gameTime) 98 { 99 if (peliKaynnissa) 100 { 101 Boolean test = true; 102 66 103 List<GameObject> fysiikkaOliot = GetObjects(x => x is PhysicsObject); 67 104 … … 70 107 PhysicsObject olioFys = olio as PhysicsObject; 71 108 olio.Velocity = nopeus; 72 } 73 74 ajastin.Interval = ajastin.Interval - 0.2; 75 76 }; 77 vaikeus.Start(3); 78 109 110 if (olio.Position.Y <= Level.Bottom + 100.0) 111 { 112 test = false; 113 } 114 } 115 116 if (test) 117 { 118 LuoPalkki(); 119 } 120 121 } 122 base.Update(gameTime); 79 123 } 80 124 … … 99 143 Keyboard.Listen(Key.Down, ButtonState.Pressed, 100 144 Tarkistin, "valkoien", Color.White); 145 101 146 Keyboard.Listen(Key.F1, ButtonState.Pressed, ShowControlHelp, null); 147 ControllerOne.Listen(Button.LeftTrigger, ButtonState.Pressed, ShowControlHelp, null); 148 149 ControllerOne.Listen(Button.Y, ButtonState.Pressed, Tarkistin, "keltainen", Color.Yellow); 150 ControllerOne.Listen(Button.B, ButtonState.Pressed, Tarkistin, "punainen", Color.Red); 151 ControllerOne.Listen(Button.X, ButtonState.Pressed, Tarkistin, "musta", Color.Black); 152 ControllerOne.Listen(Button.A, ButtonState.Pressed, Tarkistin, "valkoinen", Color.White); 102 153 103 154 … … 161 212 void Havio() 162 213 { 214 peliKaynnissa = false; 163 215 topLista.EnterAndShow(pisteLaskuri.Value); 164 216 topLista.HighScoreWindow.Closed += AloitaPeli; 217 218 219 IGameObject top = topLista as IGameObject; 220 ControllerOne.Listen(Button.A, ButtonState.Pressed, delegate { Remove(top); }, "valkoinen", Color.White); 221 222 nopeus = alkunopeus; 165 223 } 166 224 public void AloitaPeli(Window sender)
Note: See TracChangeset
for help on using the changeset viewer.