Changeset 2381 for 2011/26/JoelH/THPeli/THPeli/Peli.cs
- Timestamp:
- 2011-06-30 15:00:28 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
2011/26/JoelH/THPeli/THPeli/Peli.cs
r2310 r2381 9 9 public class Peli : PhysicsGame 10 10 { 11 int pMaxMaara = 200; 12 ExplosionSystem rajahdys = new ExplosionSystem(LoadImage("explosio"), 500); 13 14 List<Label> valikonKohdat; 11 15 const double nopeus = 300; 12 const double hyppyNopeus = 900;16 const double hyppyNopeus = 1000; 13 17 const int RUUDUN_KOKO = 40; 14 18 PlatformCharacter pelaaja1; … … 17 21 Image tahtiKuva = LoadImage("tahti"); 18 22 Image piikkikuva = LoadImage("piikit"); 23 Image norsuleft = LoadImage("norsuwalkingleft"); 24 Image norsuIdle = LoadImage("norsuidle"); 25 Image norsuRight = LoadImage("anothernorsu"); 19 26 Image splashscreen = LoadImage("Knife's Edge"); 27 Image exploosio = LoadImage("explosio"); 20 28 21 29 public override void Begin() 22 30 { 23 PhysicsObject splash = new PhysicsObject( 400.0, 400.0 ); 24 splash.Shape = Shape.Rectangle; 25 splash.Image = splashscreen; 26 31 Valikko(); 32 ExplosionSystem rajahdys = new ExplosionSystem(LoadImage("explosio"), 50); 33 27 34 MediaPlayer.Play("Game Theme"); 28 35 MediaPlayer.IsRepeating = true; 36 } 37 38 private void alotapeli() 39 { 40 ClearAll(); 41 Keyboard.Listen(Key.Escape, ButtonState.Pressed, Valikko, "Palaa valikkoon"); 42 29 43 Gravity = new Vector(0, -800); 30 44 … … 35 49 Camera.ZoomFactor = 3.0; 36 50 Camera.StayInLevel = true; 51 } 52 53 54 void Valikko() 55 { 56 ClearAll(); 57 valikonKohdat = new List<Label>(); 58 Level.Background.Image = splashscreen; 59 Level.BackgroundColor = Color.Black; 60 Label kohta1 = new Label("New Game"); 61 kohta1.Position = new Vector(0, 40); 62 valikonKohdat.Add(kohta1); 63 64 Label kohta2 = new Label("Exit"); 65 kohta2.Position = new Vector(0, -40); 66 valikonKohdat.Add(kohta2); 67 68 foreach (Label valikonKohta in valikonKohdat) 69 { 70 Add(valikonKohta); 71 } 72 73 Mouse.ListenOn(kohta1, MouseButton.Left, ButtonState.Pressed, alotapeli, null); 74 Mouse.ListenOn(kohta2, MouseButton.Left, ButtonState.Pressed, Exit, null); 75 76 Mouse.IsCursorVisible = true; 77 Mouse.ListenMovement(1.0, ValikossaLiikkuminen, null); 78 Keyboard.Listen(Key.Escape, ButtonState.Pressed, Exit, ""); 79 } 80 81 void ValikossaLiikkuminen(AnalogState hiirenTila) 82 { 83 foreach (Label kohta in valikonKohdat) 84 { 85 if (Mouse.IsCursorOn(kohta)) 86 { 87 kohta.TextColor = Color.Green; 88 } 89 else 90 { 91 kohta.TextColor = Color.White; 92 } 93 94 } 37 95 } 38 96 … … 47 105 Level.CreateBorders(); 48 106 Level.Background.CreateGradient(Color.Black, Color.Pink); 107 IsMouseVisible = false; 49 108 50 109 } … … 69 128 pelaaja1 = new PlatformCharacter(30, 40); 70 129 pelaaja1.Mass = 10.0; 71 pelaaja1.Image = pelaajanKuva; 130 pelaaja1.LeftWalkingAnimation = norsuleft; 131 pelaaja1.RightWalkingAnimation = norsuRight; 72 132 AddCollisionHandler(pelaaja1, osuTahteen); 73 133 return pelaaja1; … … 76 136 77 137 78 79 138 void lisaaNappaimet() 80 139 { 81 Keyboard.Listen(Key.Escape, ButtonState.Pressed, Exit, "Poistu pelistä");82 140 83 141 Keyboard.Listen(Key.Left, ButtonState.Down, liikuta, "Liikkuu vasemmalle", pelaaja1, -nopeus); … … 103 161 if (kohde.Tag.ToString() == "tahti") 104 162 { 105 MessageDisplay.Add("Kristalli kerätty!"); 163 Add(rajahdys); 164 //double X = 0; 165 //double Y = 0; 166 int pMaara = 600; 167 rajahdys.MaxScale = 6; 168 rajahdys.MinScale = 1; 169 rajahdys.MinLifetime = 0.1; 170 rajahdys.MaxLifetime = 0.5; 171 rajahdys.AddEffect( kohde.Position, pMaara ); 172 106 173 kohde.Destroy(); 107 174 MessageDisplay.Add("Keräsit kristallin!!"); 175 MessageDisplay.TextColor = Color.White; 108 176 } 109 177 }
Note: See TracChangeset
for help on using the changeset viewer.