Changeset 4437 for 2013/27/JoonasM/RnGPlatformShooter/RnGPlatformShooter
- Timestamp:
- 2013-07-04 15:01:23 (10 years ago)
- Location:
- 2013/27/JoonasM/RnGPlatformShooter/RnGPlatformShooter
- Files:
-
- 3 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
2013/27/JoonasM/RnGPlatformShooter/RnGPlatformShooter/RnGPlatformShooter/RnGPlatformShooter.cs
r4409 r4437 23 23 Image HeliChapter = LoadImage("Helipad"); 24 24 Image FireLava = LoadImage("Fireball"); 25 Image Solar = LoadImage("Sun"); 26 Image Sydan = LoadImage("Heart"); 27 Image Lintu = LoadImage("Pigeon"); 25 28 26 29 IntMeter pisteLaskuri; 30 IntMeter Enu; 31 IntMeter Wumpat; 27 32 28 33 SoundEffect maaliAani = LoadSoundEffect("maali"); … … 32 37 public override void Begin() 33 38 { 39 Label tekstikentta = new Label("RnGPlatformShooter"); 40 tekstikentta.Font = Font.DefaultLarge; 41 tekstikentta.X = 0; 42 tekstikentta.Y = Level.Top - 50; 43 Add(tekstikentta); 44 34 45 MultiSelectWindow alkuValikko = new MultiSelectWindow("Pelin alkuvalikko", "Aloita peli", "High Score", "Lopeta"); 35 46 alkuValikko.AddItemHandler(0, StartGame); … … 41 52 void StartGame() 42 53 { 54 ClearAll(); 43 55 Gravity = new Vector(0, -1500); 44 56 … … 53 65 void LuoKentta() 54 66 { 67 PhysicsObject SolarS = PhysicsObject.CreateStaticObject(64, 64); 68 SolarS.X = 790; 69 SolarS.Y = 300; 70 SolarS.Image = Solar; 71 SolarS.IgnoresCollisionResponse = true; 72 SolarS.Velocity = new Vector(CameraSpeed, 0); 73 Add(SolarS); 55 74 VanhaTaso = 0; 56 75 PhysicsObject StartingPlatform = PhysicsObject.CreateStaticObject(80, 20); … … 59 78 Add(StartingPlatform); 60 79 pisteLaskuri = new IntMeter(0); 80 Enu = new IntMeter(1); 81 Wumpat = new IntMeter(0); 82 61 83 LisaaPelaaja(); 62 84 … … 69 91 pisteLaskuri.Value += 1; 70 92 71 if (Camera.Velocity.X < 210)93 if (Camera.Velocity.X < 190) 72 94 { 73 95 Camera.Velocity *= 1.05; 96 SolarS.Velocity *= 1.05; 74 97 } 75 98 … … 83 106 HighScore(); 84 107 } 108 if (Wumpat > 10) 109 { 110 Wumpat.Value -= 10; 111 Enu.Value += 2; 112 } 85 113 86 114 }; 87 115 Ajastin.Start(); 88 116 89 90 91 117 Label pisteNaytto = new Label(); 92 pisteNaytto.X = Screen. Right -100;118 pisteNaytto.X = Screen.Left + 100; 93 119 pisteNaytto.Y = Screen.Top - 100; 94 120 pisteNaytto.TextColor = Color.Black; 95 121 pisteNaytto.Color = Color.White; 96 122 pisteNaytto.Title = "Pisteet"; 97 98 123 pisteNaytto.BindTo(pisteLaskuri); 99 124 Add(pisteNaytto); 125 126 Label ElamaMeter = new Label(); 127 ElamaMeter.X = Screen.Left + 100; 128 ElamaMeter.Y = Screen.Top - 150; 129 ElamaMeter.TextColor = Color.Black; 130 ElamaMeter.Color = Color.White; 131 ElamaMeter.Title = "Elämät"; 132 ElamaMeter.BindTo(Enu); 133 Add(ElamaMeter); 134 135 Label WumpaMeter = new Label(); 136 WumpaMeter.X = Screen.Left + 100; 137 WumpaMeter.Y = Screen.Top - 200; 138 WumpaMeter.TextColor = Color.Black; 139 WumpaMeter.Color = Color.White; 140 WumpaMeter.Title = "Wumpat"; 141 WumpaMeter.BindTo(Wumpat); 142 Add(WumpaMeter); 100 143 } 101 144 … … 104 147 if (RandomGen.NextInt(1, 10) != 1) 105 148 { 106 PhysicsObject taso = PhysicsObject.CreateStaticObject( 64, 20);107 taso.X = RandomGen.NextInt(150, 325) + VanhaTaso;149 PhysicsObject taso = PhysicsObject.CreateStaticObject(RandomGen.NextInt(62, 82), 20); 150 taso.X = RandomGen.NextInt(150, 280) + VanhaTaso; 108 151 taso.Y = RandomGen.NextInt(-200, 75); 109 152 taso.Color = RandomGen.NextColor(); 110 taso.Oscillate(Vector.UnitY, RandomGen.NextInt( 75, 250), 0.5);153 taso.Oscillate(Vector.UnitY, RandomGen.NextInt(85, 250), 0.5); 111 154 VanhaTaso = taso.X; 155 taso.MakeOneWay(); 112 156 Add(taso); 113 157 114 158 if (ensimmainenKerta == false) 115 159 { 116 if (RandomGen.NextInt(1, 7) == 1)160 if (RandomGen.NextInt(1, 6) == 1) 117 161 { 118 162 PhysicsObject vihu = PhysicsObject.CreateStaticObject(32, 32); … … 159 203 LaavaPallo.IgnoresCollisionResponse = true; 160 204 Add(LaavaPallo); 161 LaavaPallo.Hit(new Vector(RandomGen.NextInt(-100, 300), RandomGen.NextInt(800,1800)));205 LaavaPallo.Hit(new Vector(RandomGen.NextInt(-100,400), RandomGen.NextInt(800,1600))); 162 206 } 163 } 164 165 if (RandomGen.NextInt(1, 10) == 1) 207 208 if (RandomGen.NextInt(1, 15) == 1) 209 { 210 PhysicsObject Pigeon = PhysicsObject.CreateStaticObject(49, 35); 211 Pigeon.X = Camera.ScreenToWorld(new Vector(Screen.Left, 0)).X; 212 Pigeon.Y = pelaaja1.Y + 50; 213 Pigeon.LifetimeLeft = TimeSpan.FromSeconds(5); 214 Pigeon.Image = Lintu; 215 Pigeon.IgnoresCollisionResponse = true; 216 Pigeon.Tag = "vihu"; 217 Pigeon.Velocity = new Vector(500, 0); 218 Add(Pigeon); 219 } 220 } 221 222 if (RandomGen.NextInt(1, 3) == 1) 166 223 { 167 224 PhysicsObject wumpaf = PhysicsObject.CreateStaticObject(32, 32); … … 172 229 wumpaf.IgnoresCollisionResponse = true; 173 230 Add(wumpaf); 231 } 232 233 if (RandomGen.NextInt(1, 25) == 1) 234 { 235 PhysicsObject Health = PhysicsObject.CreateStaticObject(32, 32); 236 Health.X = (taso.X + RandomGen.NextInt(50, 100)); 237 Health.Y = taso.Y + RandomGen.NextInt(50, 200); 238 Health.IgnoresCollisionResponse = true; 239 Health.Image = Sydan; 240 Health.Tag = "Heal"; 241 Add(Health); 174 242 } 175 243 … … 198 266 pelaaja1.Add(pelaajan1Ase); 199 267 AddCollisionHandler(pelaaja1, "wumpa", CollisionHandler.DestroyTarget); 200 AddCollisionHandler(pelaaja1, "wumpa", CollisionHandler.AddMeterValue(pisteLaskuri, 50)); 268 AddCollisionHandler(pelaaja1, "Heal", CollisionHandler.DestroyTarget); 269 AddCollisionHandler(pelaaja1, "Heal", CollisionHandler.AddMeterValue(Enu, 1)); 270 AddCollisionHandler(pelaaja1, "wumpa", CollisionHandler.AddMeterValue(pisteLaskuri, 10)); 271 AddCollisionHandler(pelaaja1, "wumpa", CollisionHandler.AddMeterValue(Wumpat, 1)); 201 272 AddCollisionHandler(pelaaja1, "vihu", TormaysHighScore); 202 273 AddCollisionHandler(pelaaja1, "TTaso", TuhoaTaso); … … 206 277 void TuhoaTaso(PhysicsObject tormaaja, PhysicsObject objekti) 207 278 { 208 //Timer TasoAjastin = new Timer();209 279 Timer.SingleShot(1.5, delegate { 210 280 if (!objekti.IsDestroyed) … … 216 286 } 217 287 }); 218 //TasoAjastin.Start();219 288 } 220 289 … … 267 336 void TormaysHighScore(PhysicsObject Tormaaja, PhysicsObject Kohde) 268 337 { 269 HighScore(); 338 if (Enu < 1) 339 { 340 HighScore(); 341 } 342 else 343 { 344 Enu.Value -= 1; 345 CollisionHandler.DestroyTarget(Tormaaja, Kohde); 346 } 270 347 } 271 348 -
2013/27/JoonasM/RnGPlatformShooter/RnGPlatformShooter/RnGPlatformShooterContent/RnGPlatformShooterContent.contentproj
r4409 r4437 83 83 </Compile> 84 84 </ItemGroup> 85 <ItemGroup> 86 <Compile Include="Sun.png"> 87 <Name>Sun</Name> 88 <Importer>TextureImporter</Importer> 89 <Processor>TextureProcessor</Processor> 90 </Compile> 91 </ItemGroup> 92 <ItemGroup> 93 <Compile Include="Heart.png"> 94 <Name>Heart</Name> 95 <Importer>TextureImporter</Importer> 96 <Processor>TextureProcessor</Processor> 97 </Compile> 98 </ItemGroup> 99 <ItemGroup> 100 <Compile Include="Pigeon.png"> 101 <Name>Pigeon</Name> 102 <Importer>TextureImporter</Importer> 103 <Processor>TextureProcessor</Processor> 104 </Compile> 105 </ItemGroup> 85 106 <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 86 107 <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Note: See TracChangeset
for help on using the changeset viewer.