Changeset 1194
- Timestamp:
- 2010-07-08 14:56:36 (13 years ago)
- Location:
- 2010/27/akrauhan
- Files:
-
- 14 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
2010/27/akrauhan/Wooden Warfare/Content/Content.contentproj
r1144 r1194 39 39 <Importer>TextureImporter</Importer> 40 40 <Processor>TextureProcessor</Processor> 41 <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> 42 </Compile> 43 </ItemGroup> 44 <ItemGroup> 45 <Compile Include="jousi1.png"> 46 <Name>jousi1</Name> 47 <Importer>TextureImporter</Importer> 48 <Processor>TextureProcessor</Processor> 49 <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> 50 </Compile> 51 </ItemGroup> 52 <ItemGroup> 53 <Compile Include="pommi.png"> 54 <Name>pommi</Name> 55 <Importer>TextureImporter</Importer> 56 <Processor>TextureProcessor</Processor> 57 </Compile> 58 </ItemGroup> 59 <ItemGroup> 60 <Compile Include="pommi2.png"> 61 <Name>pommi2</Name> 62 <Importer>TextureImporter</Importer> 63 <Processor>TextureProcessor</Processor> 64 </Compile> 65 </ItemGroup> 66 <ItemGroup> 67 <Compile Include="pommi3.png"> 68 <Name>pommi3</Name> 69 <Importer>TextureImporter</Importer> 70 <Processor>TextureProcessor</Processor> 71 </Compile> 72 </ItemGroup> 73 <ItemGroup> 74 <Compile Include="Red.png"> 75 <Name>Red</Name> 76 <Importer>TextureImporter</Importer> 77 <Processor>TextureProcessor</Processor> 78 </Compile> 79 </ItemGroup> 80 <ItemGroup> 81 <Compile Include="nuoli.png"> 82 <Name>nuoli</Name> 83 <Importer>TextureImporter</Importer> 84 <Processor>TextureProcessor</Processor> 41 85 </Compile> 42 86 </ItemGroup> -
2010/27/akrauhan/Wooden Warfare/Peli.cs
r1144 r1194 2 2 using Jypeli; 3 3 using Jypeli.Widgets; 4 using Physics2DDotNet.Ignorers; 4 5 using Jypeli.Assets; 6 using Jypeli.Effects; 5 7 using System.Collections.Generic; 6 8 … … 12 14 const int ruudunLeveys = 50; 13 15 const int ruudunKorkeus = 50; 14 16 IntMeter pisteLaskuri; 17 ExplosionSystem rajahdys; 18 PhysicsObject PistePalikka; 19 Timer powerup; 15 20 Timer pomminPudotusAjastin; 21 ObjectIgnorer ignorer = new ObjectIgnorer(); 22 16 23 17 24 protected override void Begin() 18 { 19 pomminPudotusAjastin = new Timer(); 20 25 { 21 26 LuoKentta(); 27 pomminPudotusAjastin = new Timer(); 22 28 KaynnistaPomminpudotusAjastin(); 23 29 Ohjaimet(); 30 // aikaLaskuri.Start(); 31 LataaRajahdykset(); 32 LuoAikaLaskuri(); 33 LuoPisteLaskuri(); 34 35 } 36 37 private void LataaRajahdykset() 38 { 39 Image expl = LoadImage("Red"); 40 rajahdys = new ExplosionSystem(expl, 1000); 41 Add(rajahdys); 24 42 } 25 43 26 44 void KaynnistaPomminpudotusAjastin() 27 { 28 pomminPudotusAjastin.Interval = 3;45 { 46 pomminPudotusAjastin.Interval = 2; 29 47 pomminPudotusAjastin.Trigger += Pommeja; 30 48 Add(pomminPudotusAjastin); 49 pomminPudotusAjastin.Start(); 31 50 } 32 51 33 52 void NopeutaPommienPutoamista() 34 53 { 35 pomminPudotusAjastin.Interval /= 2; 36 } 37 38 void HidastaPommienPutoamista() 39 { 40 // Jaa intervalli ykköstä pienemmällä 41 } 42 54 pomminPudotusAjastin.Interval /= 1.5; 55 } 43 56 44 57 void Pommeja(Timer ajastin) 45 58 { 46 47 // Arvotan luku väliltä [Level.Left, Level.Right] 48 double x = RandomGen.NextDouble(Level.Left, Level.Right); 49 double y = 600.0; 50 51 // Pommit putoilevat.. Tee uusi fysiikkaolio ja lisää sille törmäyksenkäsittelijä 52 } 59 Add(LuoPommi(20, 40, new Vector(0, -200), "pommi")); 60 Add(LuoPommi(30, 50, new Vector(0, -100), "pommi2")); 61 Add(LuoPommi(50, 70, new Vector(0, -50), "pommi3")); 62 } 63 void PowerUp(Timer powerup) 64 { 65 //Add(KerattavaEsine); 66 } 67 68 69 53 70 54 71 void LuoKentta() 55 72 { 56 varsijousi = new Automobile(75, 30); 73 varsijousi = new PhysicsObject(75, 30); 74 varsijousi.CollisionIgnorer = ignorer; 57 75 varsijousi.Shape = Shapes.Rectangle; 58 76 varsijousi.X = 0; 59 77 varsijousi.Y = -200; 60 varsijousi.IgnoresCollisionResponse = true; 78 varsijousi.IgnoresCollisionResponse = true; 79 varsijousi.Image = LoadImage("jousi1"); 61 80 Add(varsijousi); 81 82 PhysicsObject KerattavaEsine = new PhysicsObject(40,40); 83 84 pyssy = new LaserGun(20, 5); 62 85 63 86 varsijousi.Add(pyssy); 87 88 powerup = new Timer(); 89 powerup.Interval = 30; 90 powerup.Trigger += PowerUp; 64 91 kuormaauto = new PhysicsObject(200.0, 100.0); 65 92 kuormaauto.X = -550.0; 66 kuormaauto.Y = -250.0; 93 kuormaauto.Y = -250.0; 67 94 Add(kuormaauto); 68 pyssy = new LaserGun(20, 5);69 varsijousi.Add(pyssy);70 95 PathFollowerBrain tietaseuraavatAivot = new PathFollowerBrain(); 71 96 kuormaauto.Brain = tietaseuraavatAivot; 72 97 List<Vector> polku = new List<Vector>(); 73 polku.Add( new Vector(-800.0,-250.0));74 polku.Add( new Vector(800.0,-250.0));98 polku.Add(new Vector(-800.0, -250.0)); 99 polku.Add(new Vector(800.0, -250.0)); 75 100 tietaseuraavatAivot.Path = polku; 76 101 tietaseuraavatAivot.Speed = 100; … … 79 104 ruudut['-'] = LuoPalikKaksi; 80 105 ruudut['='] = LuoPalikka; 81 varsijousi.Image = LoadImage 82 106 PistePalikka = new PhysicsObject(30, 30); 107 PistePalikka.X = -800.0; 108 PistePalikka.Y = -250.0; 109 Add(PistePalikka); 83 110 ruudut.Insert(40.0, 40.0); 84 111 Level.Background.Image = LoadImage("Winter"); 85 112 Level.Background.FitToLevel(); 86 87 88 89 90 } 113 AddCollisionHandler(kuormaauto, KasitteleTormays4); 114 AddCollisionHandler(varsijousi, KasitteleTormays5); 115 116 } 117 void KasitteleTormays5(PhysicsObject varsijousi, PhysicsObject kohde) 118 { 119 // if (kohde == //KerattavaEsine) 120 121 122 123 } 124 void KasitteleTormays4(PhysicsObject kuormaauto, PhysicsObject kohde) 125 { 126 if (kohde == PistePalikka) 127 { 128 pisteLaskuri.Value += 100; 129 } 130 } 131 91 132 void Ohjaimet() 92 133 { 93 134 Keyboard.Listen(Key.Up, ButtonState.Down, LiikuEteen, "Liiku eteenpäin"); 94 Keyboard.Listen(Key.Up, ButtonState. Released, Pysahdy, "Pysayta");135 Keyboard.Listen(Key.Up, ButtonState.Up, Pysahdy, "Pysayta"); 95 136 Keyboard.Listen(Key.Down, ButtonState.Pressed, LiikuTaakse, "Liiku taaksepäin"); 96 137 Keyboard.Listen(Key.Down, ButtonState.Released, Pysahdy, "Pysayta"); … … 99 140 Keyboard.Listen(Key.Right, ButtonState.Down, KaannyVastapaivaan, "Käänny Vasemmalle"); 100 141 Keyboard.Listen(Key.Right, ButtonState.Released, Pysahdy2, "Käänny Vasemmalle"); 101 Keyboard.Listen(Key.Space, ButtonState.Down, pyssy.Use, "Käytä"); 102 } 103 104 void LiikuEteen() 142 Keyboard.Listen(Key.Space, ButtonState.Down, Ammu, "Käytä asetta"); 143 } 144 145 void Ammu() 146 { 147 PhysicsObject ammus = pyssy.Shoot(); 148 if (ammus != null) 149 { 150 ammus.Color = Color.Brown; 151 ammus.Width *= 4; 152 ammus.Height *= 4; 153 ammus.CollisionIgnorer = new ObjectIgnorer(); 154 ammus.Image = LoadImage("nuoli"); 155 } 156 } 157 158 void LiikuEteen() 105 159 { 106 160 Vector suunta = Vector.FromLengthAndAngle(1.0, varsijousi.Angle); … … 135 189 136 190 void Pysahdy2() 137 { 191 { 138 192 } 139 193 … … 155 209 } 156 210 157 158 211 PhysicsObject LuoPommi(double leveys, double korkeus, Vector tippumisvoima, String kuva) 212 { 213 PhysicsObject pommi = new PhysicsObject(leveys, korkeus); 214 pommi.CollisionIgnorer = ignorer; 215 AddCollisionHandler(pommi, KasitteleTormays); 216 pommi.Image = LoadImage(kuva); 217 double x = RandomGen.NextDouble(Level.Left, Level.Right); 218 double y = 600.0; 219 pommi.X = x; 220 pommi.Y = y; 221 pommi.Hit(tippumisvoima); 222 return pommi; 223 } 224 225 226 227 void Rajayta(double x, double y) 228 { 229 rajahdys.AddEffect(x, y, 30); 230 } 231 232 233 void KasitteleTormays(PhysicsObject heikkopommi, PhysicsObject kohde) 234 { 235 Rajayta(heikkopommi.X, heikkopommi.Y); 236 heikkopommi.Destroy(); 237 } 238 239 240 241 void KasitteleTormays2(PhysicsObject normaalipommi, PhysicsObject kohde) 242 { 243 normaalipommi.Destroy(); 244 Explosion rajahdys = new Explosion(70); 245 rajahdys.Position = normaalipommi.Position; 246 Add(rajahdys); 247 } 248 249 250 void KasitteleTormays3(PhysicsObject vahvapommi, PhysicsObject kohde) 251 { 252 vahvapommi.Destroy(); 253 Explosion rajahdys = new Explosion(100); 254 rajahdys.Position = vahvapommi.Position; 255 Add(rajahdys); 256 } 257 258 Timer aikaLaskuri; 259 260 void LuoAikaLaskuri() 261 { 262 aikaLaskuri = new Timer(); 263 Add(aikaLaskuri); 264 aikaLaskuri.Start(); 265 266 Label aikaNaytto = new Label("Aikaa kulunut:"); 267 aikaNaytto.TextColor = Color.Red; 268 aikaNaytto.DecimalPlaces = 1; 269 aikaNaytto.BindTo(aikaLaskuri.SecondCounter); 270 aikaNaytto.X = 400; 271 aikaNaytto.Y = 400; 272 273 Add(aikaNaytto); 274 } 275 276 277 278 void LuoPisteLaskuri() 279 { 280 pisteLaskuri = new IntMeter(0); 281 282 Label pisteNaytto = new Label(); 283 pisteNaytto.X = Screen.Left + 100; 284 pisteNaytto.Y = Screen.Top - 100; 285 pisteNaytto.TextColor = Color.Red; 286 287 pisteNaytto.BindTo(pisteLaskuri); 288 Add(pisteNaytto); 289 290 Label pisteTeksti = new Label("Pisteitä:"); 291 pisteTeksti.X = Screen.Left + 50; 292 pisteTeksti.Y = Screen.Top - 100; 293 pisteTeksti.TextColor = Color.Red; 294 Add(pisteTeksti); 295 296 if (pisteLaskuri.Value >= 300) 297 { 298 NopeutaPommienPutoamista(); 299 } 300 if (pisteLaskuri.Value >= 600) 301 { 302 NopeutaPommienPutoamista(); 303 } 304 if (pisteLaskuri.Value >= 1000) 305 { 306 NopeutaPommienPutoamista(); 307 } 308 } 309 310 311 void LuoEnergia() 312 { 313 Energiamittari = new IntMeter(100); 314 315 Label EnergiaNaytto = new Label(); 316 EnergiaNaytto.X = 0.0; 317 EnergiaNaytto.Y = Screen.Bottom + 100; 318 EnergiaNaytto.TextColor = Color.Green; 319 320 EnergiaNaytto.BindTo(Energiamittari); 321 Add(EnergiaNaytto); 322 323 if (LuoEnergia.Value <= 1) 324 { 325 kuormaauto.Destroy; 326 } 327 } 328 329 330 331 332 159 333 } 160 334 161 -
2010/27/akrauhan/Wooden Warfare/Wooden Warfare.csproj
r1144 r1194 91 91 <Content Include="Game.ico" /> 92 92 <Content Include="GameThumbnail.png" /> 93 <Content Include="pommi.png" /> 93 94 <None Include="kenttä"> 94 95 <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
Note: See TracChangeset
for help on using the changeset viewer.