- Timestamp:
- 2011-06-30 14:59:50 (12 years ago)
- Location:
- 2011/26/RistoR/ding/ding
- Files:
-
- 8 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
2011/26/RistoR/ding/ding/ding/Peli.cs
r2318 r2377 6 6 using Jypeli.Effects; 7 7 using Jypeli.Widgets; 8 class PeliHahmo : PhysicsObject 8 9 class zombi : PhysicsObject 9 10 { 10 public int Elamat = 3; 11 public bool OnHidas = false; 12 public int KenganNumero = 42; 13 public int Rahat = 1000; 14 public Vector RespausKoordinaatit = Vector.Zero; 15 16 public PeliHahmo(double leveys, double korkeus) 11 public int elamat = 3; 12 public zombi(double leveys, double korkeus) 17 13 : base(leveys, korkeus) 18 14 { 19 15 } 16 20 17 } 21 22 18 public class Peli : PhysicsGame 23 19 { … … 25 21 const double hyppyNopeus = 1000; 26 22 const int RUUDUN_KOKO = 40; 27 28 23 PlatformCharacter pelaaja1; 29 24 List<Label> valikonKohdat; 30 25 31 Image pelaajanKuva = LoadImage("norsu"); 26 Image paavalikko = LoadImage("paavalikko"); 27 Image pelaajanKuva = LoadImage("pelaaja"); 32 28 Image tahtiKuva = LoadImage("tahti"); 29 Image zombikuva = LoadImage("zombikuva"); 30 Image pistooli = LoadImage("pistooli"); 31 Image maalinkuva = LoadImage("maalinkuva"); 33 32 34 33 SoundEffect maaliAani = LoadSoundEffect("maali"); … … 42 41 lisaaNappaimet(); 43 42 luopallo(); 44 zombi();45 43 ase(); 46 44 valikko(); … … 49 47 Camera.StayInLevel = true; 50 48 } 51 52 49 void luoKentta() 53 50 { … … 57 54 kentta['N'] = lisaaPelaaja; 58 55 kentta['D'] = lisaavaara; 56 kentta['Z'] = lisaazombi; 57 kentta['M'] = lisaamaali; 59 58 kentta.Insert(RUUDUN_KOKO, RUUDUN_KOKO); 60 59 Level.CreateBorders(); 61 Level.Background.Create Gradient(Color.Black, Color.OrangeRed);60 Level.Background.CreateStars(500); 62 61 } 63 62 PhysicsObject lisaaTaso() … … 76 75 PlatformCharacter lisaaPelaaja() 77 76 { 78 pelaaja1 = new PlatformCharacter( 35, 35);77 pelaaja1 = new PlatformCharacter(40, 40); 79 78 pelaaja1.Mass = 4.0; 80 79 pelaaja1.Image = pelaajanKuva; … … 90 89 return vaara; 91 90 } 91 PhysicsObject lisaamaali() 92 { 93 PhysicsObject maali = PhysicsObject.CreateStaticObject(RUUDUN_KOKO, RUUDUN_KOKO); 94 maali.Image = maalinkuva; 95 maali.Mass = 4.0; 96 AddCollisionHandler(maali, MaaliinOsuma); 97 return maali; 98 99 } 100 void MaaliinOsuma(PhysicsObject maali, PhysicsObject kohde) 101 { 102 if (kohde == pelaaja1) 103 { 104 ClearAll(); 105 Voitto(); 106 107 } 108 } 109 zombi lisaazombi() 110 { 111 zombi zombi = new zombi(40.0, 40.0); 112 FollowerBrain zombiaivot = new FollowerBrain(); 113 zombi.Brain = zombiaivot; 114 zombiaivot.Active = true; 115 zombi.Image = zombikuva; 116 zombi.Mass = 4.0; 117 zombi.Color = Color.DarkGreen; 118 zombiaivot.Target = pelaaja1; 119 zombiaivot.Speed = 150; 120 zombi.Tag = "zombi"; 121 return zombi; 122 { 123 124 } 125 126 } 92 127 void lisaaNappaimet() 93 128 { … … 99 134 Keyboard.Listen(Key.Space, ButtonState.Down, hyppaa, "Pelaaja hyppää", pelaaja1, hyppyNopeus); 100 135 Keyboard.Listen(Key.Down, ButtonState.Down, AmmuAseella, "Ammu"); 101 Keyboard.Listen(Key.W, ButtonState.Down, kaannaasetta ,"Käännä asetta ylös");102 Keyboard.Listen(Key.S, ButtonState.Down, kaannaasetta 2, "Käännä asetta alas");136 Keyboard.Listen(Key.W, ButtonState.Down, kaannaasettaylos, "Käännä asetta ylös"); 137 Keyboard.Listen(Key.S, ButtonState.Down, kaannaasettaalas, "Käännä asetta alas"); 103 138 Keyboard.Listen(Key.Up, ButtonState.Pressed, HeitaKranaatti, "Heitä kranaatti"); 104 105 106 139 ControllerOne.Listen(Button.Back, ButtonState.Pressed, Exit, "Poistu pelistä"); 107 140 … … 135 168 136 169 } 170 if (kohde.Tag.ToString() == "zombi") 171 { 172 pelaaja1.Destroy(); 173 pistelaskuri.Reset(); 174 MessageDisplay.Add("Kuolit, aloita alusta."); 175 MessageDisplay.TextColor = Color.Yellow; 176 MessageDisplay.MessageTime = new TimeSpan(0, 0, 10); 177 } 178 137 179 } 138 180 void luopallo() … … 147 189 Add(pallo); 148 190 } 149 void zombi()150 {151 PhysicsObject zombi = new PhysicsObject(40.0,40.0);152 FollowerBrain zombiaivot = new FollowerBrain();153 zombi.Brain = zombiaivot;154 zombiaivot.Active = true;155 zombi.Color = Color.DarkGreen;156 zombiaivot.Target = pelaaja1;157 zombiaivot.Speed = 150;158 int i = RandomGen.NextInt(1, 100);159 Add(zombi);160 }161 191 void ase() 162 192 { 163 pelaaja1.Weapon = new AssaultRifle(35, 20); 164 AssaultRifle pyssy = new AssaultRifle(35, 20); 193 pelaaja1.Weapon = new AssaultRifle(25, 25); 194 AssaultRifle pyssy = new AssaultRifle(25, 25); 195 pyssy.Image = pistooli; 165 196 pyssy.ProjectileCollision = AmmusOsui; 197 pyssy.X = pelaaja1.X += 50; 166 198 pyssy.Ammo.Value = 500; 167 199 pelaaja1.Weapon.ProjectileCollision = AmmusOsui; … … 170 202 { 171 203 PhysicsObject ammus = pelaaja1.Weapon.Shoot(); 172 173 204 if (ammus != null) 174 205 { … … 176 207 } 177 208 } 178 void AmmusOsui(PhysicsObject ammus, PhysicsObject taso)209 void AmmusOsui(PhysicsObject ammus, PhysicsObject kohde) 179 210 { 180 211 ammus.Destroy(); … … 182 213 rajahdys.Position = ammus.Position; 183 214 Add(rajahdys); 184 } 185 void kaannaasetta() 186 { 187 pelaaja1.Weapon.Angle += Angle.FromDegrees(4); 188 } 189 void kaannaasetta2() 190 { 191 pelaaja1.Weapon.Angle += Angle.FromDegrees(-4); 215 if (kohde.Tag.ToString() == "zombi") 216 { 217 zombi vihu = kohde as zombi; 218 vihu.elamat -= 1; 219 if (vihu.elamat == 0) 220 { 221 vihu.Destroy(); 222 pistelaskuri.Value += 1; 223 } 224 } 225 226 } 227 void kaannaasettaylos() 228 { 229 if (pelaaja1.FacingDirection == Direction.Right) 230 { 231 pelaaja1.Weapon.Angle += Angle.FromDegrees(5); 232 } 233 if (pelaaja1.FacingDirection == Direction.Left) 234 { 235 pelaaja1.Weapon.Angle += Angle.FromDegrees(-5); 236 } 237 } 238 void kaannaasettaalas() 239 { 240 if (pelaaja1.FacingDirection == Direction.Right) 241 { 242 pelaaja1.Weapon.Angle += Angle.FromDegrees(-5); 243 } 244 if (pelaaja1.FacingDirection == Direction.Left) 245 { 246 pelaaja1.Weapon.Angle += Angle.FromDegrees(5); 247 } 248 192 249 } 193 250 void HeitaKranaatti() 194 251 { 195 252 196 253 Grenade kranaatti = new Grenade(4.0); 197 254 kranaatti.X = pelaaja1.X + 10; 198 255 kranaatti.Y = pelaaja1.Y + 10; 199 256 Add(kranaatti); 200 Vector heittoVoima = Vector.FromLengthAndAngle(4000, Angle.FromDegrees(45));257 Vector heittoVoima = Vector.FromLengthAndAngle(4000, pelaaja1.Weapon.Angle); 201 258 kranaatti.Hit(heittoVoima); 202 }203 void valo()204 {205 Level.AmbientLight = 0.3;206 207 Light lamppu = new Light();208 lamppu.Intensity = 0.8;209 lamppu.Distance = 300;210 lamppu.Position = lamppu.Position;211 Add(lamppu);212 213 }214 void ajastin()215 {216 Timer ajastin = new Timer();217 ajastin.Interval = 5.5;218 ajastin.Trigger += tippuvapalikka;219 ajastin.Start();220 221 }222 void tippuvapalikka(Timer ajastin)223 {224 PhysicsObject palikka = new PhysicsObject(20.0, 80.0);225 palikka.Shape = Shape.Rectangle;226 palikka.Color = Color.Purple;227 palikka.X = pelaaja1.X + 120;228 palikka.Y = pelaaja1.Y + 900;229 Add(palikka);230 231 259 } 232 260 IntMeter pistelaskuri; 233 261 void luolaskuri() 234 { 235 pistelaskuri = new IntMeter(0); 236 237 Label pisteNaytto = new Label(); 238 pisteNaytto.X = Screen.Left + 100; 239 pisteNaytto.Y = Screen.Top - 100; 240 pisteNaytto.TextColor = Color.Turquoise; 241 242 pisteNaytto.BindTo(pistelaskuri); 243 Add(pisteNaytto); 244 245 Label pisteTeksti = new Label("Pisteitä: "); 246 pisteTeksti.X = Screen.Left + 50; 247 pisteTeksti.Y = Screen.Top - 100; 248 pisteTeksti.TextColor = Color.SkyBlue; 249 Add(pisteTeksti); 250 pistelaskuri.Value++; 251 pistelaskuri.Value += 1; 252 pistelaskuri.Value = pistelaskuri.Value + 1; 253 pistelaskuri.Reset(); 254 IntMeter laskuri = new IntMeter(0); 255 laskuri.MaxValue = 5; 256 laskuri.UpperLimit += laskuriYlarajassa; } 262 { 263 pistelaskuri = new IntMeter(0); 264 265 Label pisteNaytto = new Label(); 266 pisteNaytto.X = Screen.Left + 100; 267 pisteNaytto.Y = Screen.Top - 100; 268 pisteNaytto.TextColor = Color.Turquoise; 269 270 pisteNaytto.BindTo(pistelaskuri); 271 Add(pisteNaytto); 272 273 Label pisteTeksti = new Label("Pisteitä: "); 274 pisteTeksti.X = Screen.Left + 50; 275 pisteTeksti.Y = Screen.Top - 100; 276 pisteTeksti.TextColor = Color.SkyBlue; 277 Add(pisteTeksti); 278 pistelaskuri.Value++; 279 pistelaskuri.Value += 1; 280 pistelaskuri.Value = pistelaskuri.Value + 1; 281 pistelaskuri.Reset(); 282 IntMeter laskuri = new IntMeter(0); 283 laskuri.MaxValue = 5; 284 laskuri.UpperLimit += laskuriYlarajassa; 285 } 257 286 void laskuriYlarajassa(int arvo) 258 259 260 261 287 { 288 MessageDisplay.TextColor = Color.White; 289 MessageDisplay.Add("Pelaaja 1 voitti pelin."); 290 } 262 291 void valikko() 263 292 { 264 293 ClearAll(); 294 Level.Background.Image ("paavalikko"); 265 295 valikonKohdat = new List<Label>(); 266 296 … … 280 310 Mouse.ListenOn(kohta1, MouseButton.Left, ButtonState.Pressed, AloitaPeli, null); 281 311 Mouse.ListenOn(kohta2, MouseButton.Left, ButtonState.Pressed, Exit, null); 282 312 283 313 Mouse.IsCursorVisible = true; 284 314 Mouse.ListenMovement(1.0, ValikossaLiikkuminen, null); … … 301 331 } 302 332 } 303 304 333 void AloitaPeli() 305 334 { … … 310 339 lisaaNappaimet(); 311 340 luopallo(); 312 zombi();313 341 ase(); 314 ajastin();315 342 Camera.Follow(pelaaja1); 316 343 Camera.ZoomFactor = 1.2; … … 318 345 Keyboard.Listen(Key.Escape, ButtonState.Pressed, valikko, "Palaa valikkoon"); 319 346 } 320 321 322 347 void Voitto() 348 { 349 Label nappi = new Label("Aloita uusi peli"); 350 nappi.Position = new Vector(0, 40); 351 valikonKohdat.Add(nappi); 352 353 Label nappi2 = new Label("Lopeta"); 354 nappi2.Position = new Vector(0, -40); 355 valikonKohdat.Add(nappi2); 356 foreach (Label valikonKohta in valikonKohdat) 357 { 358 Add(valikonKohta); 359 } 360 361 Mouse.ListenOn(nappi, MouseButton.Left, ButtonState.Pressed, AloitaPeli, null); 362 Mouse.ListenOn(nappi2, MouseButton.Left, ButtonState.Pressed, Exit, null); 363 364 Mouse.IsCursorVisible = true; 365 Mouse.ListenMovement(1.0, ValikossaLiikkuminen, null); 366 Keyboard.Listen(Key.Escape, ButtonState.Pressed, Exit, ""); 367 368 } 323 369 } -
2011/26/RistoR/ding/ding/ding/kentta1.txt
r2318 r2377 10 10 ########## 11 11 # # 12 # *** 12 # *** Z 13 13 # *** # # 14 14 # # *** # … … 19 19 # * # 20 20 # # # # # 21 # # # # 21 # # # # # 22 22 # 23 # N ## D24 ########################## ######################DD##################################################################################25 #################################################################################################################################### *** 26 #################################################################################################################################### * ##################### 27 #################################################################################################################################### * # ######################### ** 28 #################################################################################################################################### * ### ############################## 29 #################################################################################################################################### * ##### * ################################ * ###########30 #################################################################################################################################### * ######### * ########################################## ###### * ####31 #################################################################################################################################### * ############# ############################################################### * ####32 #################################################################################################################################### * ################# ################################################################## ######## *** 33 ###################################################################################################################################### ##################### ######################################################################## ###################34 ######################################################################################################################################################################################################################################################################################################DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD 23 # N ## # Z Z Z Z 24 ##########################D#####################DD######################DDD#DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD##### # 25 #################################################################################################################################### *** # 26 #################################################################################################################################### * ##################### # 27 #################################################################################################################################### * # ######################### ** # 28 #################################################################################################################################### * ### ############################## # 29 #################################################################################################################################### * ##### Z * ################################ * ########### # 30 #################################################################################################################################### * D######## * ########################################## ###### * #### # 31 #################################################################################################################################### * ############# Z ############################################################### * #### Z M # 32 #################################################################################################################################### * ################# ################################################################## ######## *** ########################### 33 ###################################################################################################################################### Z ##################### ######################################################################## ################### # 34 ######################################################################################################################################################################################################################################################################################################DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD# -
2011/26/RistoR/ding/ding/dingContent/dingContent.contentproj
r2318 r2377 48 48 <Processor>SoundEffectProcessor</Processor> 49 49 </Compile> 50 <Compile Include=" norsu.png">51 <Name> norsu</Name>50 <Compile Include="tahti.png"> 51 <Name>tahti</Name> 52 52 <Importer>TextureImporter</Importer> 53 53 <Processor>TextureProcessor</Processor> 54 54 </Compile> 55 <Compile Include="tahti.png"> 56 <Name>tahti</Name> 55 </ItemGroup> 56 <ItemGroup> 57 <Compile Include="pelaaja.png"> 58 <Name>pelaaja</Name> 59 <Importer>TextureImporter</Importer> 60 <Processor>TextureProcessor</Processor> 61 </Compile> 62 </ItemGroup> 63 <ItemGroup> 64 <Compile Include="zombikuva.png"> 65 <Name>zombikuva</Name> 66 <Importer>TextureImporter</Importer> 67 <Processor>TextureProcessor</Processor> 68 </Compile> 69 </ItemGroup> 70 <ItemGroup> 71 <Compile Include="pistooli.png"> 72 <Name>pistooli</Name> 73 <Importer>TextureImporter</Importer> 74 <Processor>TextureProcessor</Processor> 75 </Compile> 76 </ItemGroup> 77 <ItemGroup> 78 <Compile Include="kaupunki.png"> 79 <Name>kaupunki</Name> 80 <Importer>TextureImporter</Importer> 81 <Processor>TextureProcessor</Processor> 82 </Compile> 83 </ItemGroup> 84 <ItemGroup> 85 <Compile Include="pelaajahyppy.png"> 86 <Name>pelaajahyppy</Name> 87 <Importer>TextureImporter</Importer> 88 <Processor>TextureProcessor</Processor> 89 </Compile> 90 <Compile Include="pelaajalaskeutuu.png"> 91 <Name>pelaajalaskeutuu</Name> 92 <Importer>TextureImporter</Importer> 93 <Processor>TextureProcessor</Processor> 94 </Compile> 95 </ItemGroup> 96 <ItemGroup> 97 <Compile Include="maalinkuva.png"> 98 <Name>maalinkuva</Name> 99 <Importer>TextureImporter</Importer> 100 <Processor>TextureProcessor</Processor> 101 </Compile> 102 </ItemGroup> 103 <ItemGroup> 104 <Compile Include="paavalikko.png"> 105 <Name>paavalikko</Name> 57 106 <Importer>TextureImporter</Importer> 58 107 <Processor>TextureProcessor</Processor>
Note: See TracChangeset
for help on using the changeset viewer.