- Timestamp:
- 2013-06-27 14:50:22 (10 years ago)
- Location:
- 2013/26/ChristianS/Testi/Testi
- Files:
-
- 5 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
2013/26/ChristianS/Testi/Testi/Testi/Testi.cs
r4234 r4264 11 11 AssaultRifle rambonAse; 12 12 13 const double nopeus = 300;13 const double perusNopeus = 150; 14 14 const double hyppyNopeus = 850; 15 15 const int RUUDUN_KOKO = 50; 16 16 17 18 19 EasyHighScore topLista = new EasyHighScore(); 20 21 22 Vector nopeusX = new Vector(perusNopeus, 0); 23 Vector nopeusYlos = new Vector(0, perusNopeus); 24 Vector nopeusAlas = new Vector(0, -perusNopeus+15); 25 17 26 Pelaaja pelaaja; 27 28 IntMeter pistelaskuri; 29 30 Image pelaajanKuva = LoadImage("steve"); 31 Image tahtiKuva = LoadImage("tahti"); 32 Image seinaKuva = LoadImage("glass"); 33 Image zombi = LoadImage("zombi"); 18 34 19 35 20 Image pelaajanKuva = LoadImage("rambo");21 Image tahtiKuva = LoadImage("tahti");22 23 36 public override void Begin() 24 37 { 38 MediaPlayer.Play("taustamusa2"); 39 MediaPlayer.IsRepeating = true; 40 41 ClearAll(); 25 42 Mouse.IsCursorVisible = true; 26 43 LuoKentta(); 27 44 LisaaNappaimet(); 45 LisaaLaskurit(); 46 PhysicsObject randomOlio = new PhysicsObject(20.0, 20.0); 28 47 29 48 Camera.Follow(pelaaja); … … 33 52 int laskuri = 0; 34 53 35 while (laskuri < 25)54 while (laskuri < 100) 36 55 { 37 LuoSatunnainen Pallo(Color.Green, "pahis");56 LuoSatunnainenOlio(); 38 57 laskuri++; 39 58 } 59 40 60 Timer ajastin = new Timer(); 41 ajastin.Interval = 2;42 ajastin.Timeout += delegate { LuoSatunnainen Pallo(Color.Green, "pahis"); };61 ajastin.Interval = 1; 62 ajastin.Timeout += delegate { LuoSatunnainenOlio(); }; 43 63 ajastin.Start(); 44 64 } … … 56 76 } 57 77 58 private void LuoSatunnainen Pallo(Color vari, String tagi)78 private void LuoSatunnainenOlio() 59 79 { 60 80 double x = RandomGen.NextDouble(Level.Left, Level.Right); … … 62 82 double r = RandomGen.NextDouble(10, 50); 63 83 // Color vari = RandomGen.NextColor(); 64 LuoMuoto( Shape.Circle, x, y, r, vari, tagi);84 LuoMuoto(x, y, r); 65 85 } 66 86 … … 70 90 taso.Position = paikka; 71 91 taso.CollisionIgnoreGroup = 1; 72 taso. Color = Color.Green;92 taso.Image = seinaKuva; 73 93 Add(taso); 74 94 } … … 92 112 pelaaja.Image = pelaajanKuva; 93 113 pelaaja.CollisionIgnoreGroup = 2; 94 // pelaaja.LinearDamping = 0.95;114 pelaaja.LinearDamping = 0.6; 95 115 pelaaja.Tag = "rambo"; 96 116 AddCollisionHandler(pelaaja, "tahti", TormaaTahteen); 97 117 AddCollisionHandler(pelaaja, "tahti", CollisionHandler.AddMeterValue(pelaaja.ElamaLaskuri, 2)); 98 118 rambonAse = new AssaultRifle(30, 10); 99 rambonAse.Ammo.Value = 1250;100 rambonAse.FireRate = 8;119 rambonAse.Ammo.Value = int.MaxValue; 120 rambonAse.FireRate = 10; 101 121 rambonAse.ProjectileCollision = AmmusOsui; 102 122 pelaaja.Add(rambonAse); 103 AddCollisionHandler(pelaaja, "pahis", delegate(PhysicsObject tormaaja, PhysicsObject kohde) { LuoSatunnainen Pallo(Color.Green, "pahis"); });123 AddCollisionHandler(pelaaja, "pahis", delegate(PhysicsObject tormaaja, PhysicsObject kohde) { LuoSatunnainenOlio(); }); 104 124 AddCollisionHandler(pelaaja, PelaajaTormasi); 105 125 Add(pelaaja); … … 112 132 elamaPalkki.BindTo(pelaaja.ElamaLaskuri); 113 133 Add(elamaPalkki); 114 } 134 135 LuoAmmusLaskuri(0, 0); 136 } 137 138 void JatketaankoValinta() 139 { 140 MultiSelectWindow valikko = new MultiSelectWindow("Game Over", "Uusi peli", "Lopeta peli"); 141 valikko.AddItemHandler(0, Begin); 142 valikko.AddItemHandler(1, Exit); 143 Add(valikko); 144 } 145 115 146 116 147 void Kuolit() … … 118 149 MessageDisplay.Add("Zombi söi sinut!"); 119 150 pelaaja.Destroy(); 151 topLista.EnterAndShow(pistelaskuri.Value); 152 topLista.HighScoreWindow.Closed += delegate { JatketaankoValinta(); }; 120 153 } 121 154 … … 124 157 Keyboard.Listen(Key.F1, ButtonState.Pressed, ShowControlHelp, "Näytä ohjeet"); 125 158 Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli"); 126 Vector nopeusX = new Vector(150, 0); 127 Vector nopeusYlos = new Vector(0, 150); 128 Vector nopeusAlas = new Vector(0, -135); 159 129 160 130 161 Mouse.ListenMovement(0.1, KuunteleHiirenLiiketta, null); 131 162 163 Keyboard.Listen(Key.D, ButtonState.Down, LiikutaOikealle, "Liikkuu oikealle", pelaaja); 164 Keyboard.Listen(Key.A, ButtonState.Down, LiikutaVasemmalle, "Liikkuu vasemmalle", pelaaja); 165 Keyboard.Listen(Key.W, ButtonState.Down, LiikutaYlos, "Liikkuu eteen", pelaaja); 166 Keyboard.Listen(Key.S, ButtonState.Down, LiikutaAlas, "Liikkuu taakse", pelaaja); 167 168 /* 132 169 Keyboard.Listen(Key.D, ButtonState.Pressed, Liikuta, "Liikkuu oikealle", pelaaja, nopeusX); 133 170 Keyboard.Listen(Key.D, ButtonState.Released, Liikuta, "Liikkuu oikealle", pelaaja, new Vector(-nopeusX.X, pelaaja.Velocity.Y)); … … 138 175 Keyboard.Listen(Key.S, ButtonState.Pressed, Liikuta, "Liikkuu taakse", pelaaja, nopeusAlas); 139 176 Keyboard.Listen(Key.S, ButtonState.Released, Liikuta, "Liikkuu taakse", pelaaja, new Vector(pelaaja.Velocity.X, -nopeusAlas.Y)); 140 Mouse.Listen(MouseButton.Left, ButtonState.Down, AmmuAseella, "Ammu", rambonAse); 141 177 */ 178 Mouse.Listen(MouseButton.Left, ButtonState.Down, AmmuAseella, "Ammu", rambonAse); 179 142 180 } 143 181 … … 148 186 } 149 187 150 151 void Liikuta(PhysicsObject hahmo, Vector nopeus) 152 { 153 hahmo.Velocity += nopeus; 188 void LiikutaYlos(PhysicsObject hahmo) 189 { 190 hahmo.Push(nopeusYlos * 30); 191 } 192 193 void LiikutaAlas(PhysicsObject hahmo) 194 { 195 hahmo.Push(nopeusAlas * 30); 196 } 197 198 199 void LiikutaVasemmalle(PhysicsObject hahmo) 200 { 201 //hahmo.Velocity += nopeus; 202 hahmo.Push(-nopeusX * 30); 203 } 204 205 206 void LiikutaOikealle(PhysicsObject hahmo) 207 { 208 //hahmo.Velocity += nopeus; 209 hahmo.Push(nopeusX * 30); 154 210 } 155 211 … … 157 213 { 158 214 MessageDisplay.Add("Keräsit tähden!"); 215 216 nopeusAlas *= 1.5; 217 nopeusX *= 1.5; 218 nopeusYlos *= 1.5; 219 220 Timer ajastin = new Timer(); 221 ajastin.Interval = 15; 222 ajastin.Timeout += delegate { 223 nopeusAlas /= 1.5; 224 nopeusX /= 1.5; 225 nopeusYlos /= 1.5; 226 //nopeusYlos.Y = perusNopeus; nopeusX.X = perusNopeus; nopeusAlas.Y = -perusNopeus + 15; 227 }; 228 ajastin.Start(1); 229 230 159 231 tahti.Destroy(); 160 232 } … … 162 234 { 163 235 ammus.Destroy(); 164 if (kohde.Tag.Equals("pahis")) 236 if (kohde.Image == null) return; 237 if (kohde.Image.Equals(zombi)) 165 238 { 239 //if(kohde.Color.Equals(zombi)) 240 pistelaskuri.Value++; 166 241 kohde.Destroy(); 167 242 } … … 179 254 } 180 255 } 181 void LuoMuoto( Shape muoto, double x, double y, double sade, Color vari, String tagi)256 void LuoMuoto(double x, double y, double sade) 182 257 { 183 258 PhysicsObject olio = new PhysicsObject(sade, sade); 184 olio.Shape = muoto;185 olio.Color = vari;259 //olio.Shape = muoto; 260 //olio.Color = vari; 186 261 olio.Restitution = 1.0; 187 262 olio.Y = y; 188 263 olio.X = x; 189 olio.Tag = tagi; 264 olio.CanRotate = false; 265 //olio.Tag = tagi; 266 olio.Image = zombi; 190 267 olio.Hit(RandomGen.NextVector(10, 100)); 268 FollowerBrain seuraajanAivot = new FollowerBrain(pelaaja); 269 seuraajanAivot.Speed = 100; 270 seuraajanAivot.DistanceFar = 600; 271 seuraajanAivot.DistanceClose = 2; 272 seuraajanAivot.StopWhenTargetClose = false; 273 olio.Brain = seuraajanAivot; 191 274 Add(olio); 275 192 276 } 193 277 void PelaajaTormasi(PhysicsObject tormaaja, PhysicsObject kohde) 194 278 { 195 if (kohde.Tag.Equals("pahis")) 279 if (kohde.Image == null) return; 280 if (kohde.Image.Equals(zombi)) 196 281 { 197 282 //Tässä vähennetään elämää esim elamat.Value -= 5; … … 203 288 204 289 } 290 291 void LisaaLaskurit() 292 { 293 pistelaskuri = LuoPisteLaskuri(Screen.Left + 100.0, Screen.Top - 100.0); 294 } 295 IntMeter LuoPisteLaskuri(double x, double y) 296 { 297 IntMeter laskuri = new IntMeter(0); 298 laskuri.MaxValue = int.MaxValue; 299 300 Label naytto = new Label(); 301 naytto.BindTo(laskuri); 302 naytto.X = x; 303 naytto.Y = y; 304 naytto.TextColor = Color.White; 305 naytto.BorderColor = Level.BackgroundColor; 306 naytto.Color = Level.BackgroundColor; 307 Add(naytto); 308 309 return laskuri; 310 } 311 void LuoAmmusLaskuri(double x, double y) 312 { 313 Label naytto = new Label(); 314 naytto.BindTo(rambonAse.Ammo); 315 naytto.X = x; 316 naytto.Y = y; 317 naytto.TextColor = Color.White; 318 naytto.BorderColor = Level.BackgroundColor; 319 naytto.Color = Level.BackgroundColor; 320 Add(naytto); 321 } 322 void KasitteleammusOsui(PhysicsObject pallo, PhysicsObject kohde) 323 { 324 325 } 205 326 } 206 327 … … 213 334 : base(leveys, korkeus) 214 335 { 215 216 } 336 337 } 338 339 217 340 } -
2013/26/ChristianS/Testi/Testi/TestiContent/TestiContent.contentproj
r4234 r4264 65 65 </ItemGroup> 66 66 <ItemGroup> 67 <Compile Include=" rambo.png">68 <Name> rambo</Name>67 <Compile Include="glass.png"> 68 <Name>glass</Name> 69 69 <Importer>TextureImporter</Importer> 70 70 <Processor>TextureProcessor</Processor> 71 </Compile> 72 </ItemGroup> 73 <ItemGroup> 74 <Compile Include="steve.png"> 75 <Name>steve</Name> 76 <Importer>TextureImporter</Importer> 77 <Processor>TextureProcessor</Processor> 78 </Compile> 79 </ItemGroup> 80 <ItemGroup> 81 <Compile Include="zombi.png"> 82 <Name>zombi</Name> 83 <Importer>TextureImporter</Importer> 84 <Processor>TextureProcessor</Processor> 85 </Compile> 86 </ItemGroup> 87 <ItemGroup> 88 <Compile Include="taustamusa.mp3"> 89 <Name>taustamusa</Name> 90 <Importer>Mp3Importer</Importer> 91 <Processor>SongProcessor</Processor> 92 </Compile> 93 </ItemGroup> 94 <ItemGroup> 95 <Compile Include="taustamusa2.mp3"> 96 <Name>taustamusa2</Name> 97 <Importer>Mp3Importer</Importer> 98 <Processor>SongProcessor</Processor> 71 99 </Compile> 72 100 </ItemGroup>
Note: See TracChangeset
for help on using the changeset viewer.