Changeset 2407
- Timestamp:
- 2011-07-01 11:54:06 (12 years ago)
- Location:
- 2011/26/JouniM/MatoPeli/MatoPeli
- Files:
-
- 2 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
2011/26/JouniM/MatoPeli/MatoPeli/MatoPeli/Peli.cs
r2370 r2407 18 18 Timer aikaLaskuri; 19 19 IntMeter pisteLaskuri; 20 20 int SaaliidenMaara = 0; 21 21 Image MadonKuva = LoadImage("Mato"); 22 22 Image SaaliinKuva = LoadImage("Saalis"); 23 23 Image GameOver = LoadImage("game over"); 24 Image taustaKuva = LoadImage("taustakuva"); 25 26 ScoreList topLista = new ScoreList(10, false, 0); 27 28 24 29 25 30 bool kuolematon = false; … … 40 45 aikaLaskuri.Interval = 0.1; 41 46 aikaLaskuri.Trigger += LaskeAlaspain; 47 48 MediaPlayer.Play("duck hunt"); 49 50 if (DataStorage.Exists("pisteet.xml")) 51 topLista = DataStorage.Load<ScoreList>(topLista, "pisteet.xml"); 52 42 53 43 54 Aloitapeli(); … … 51 62 LuoMato(); 52 63 AsetaOhjaimet(); 64 SaaliidenMaara = 0; 53 65 LuoSaalis(20, 30); 54 66 LuoLaskuri(); … … 59 71 60 72 73 61 74 } 62 75 … … 65 78 Level.CreateBorders(); 66 79 Camera.ZoomToLevel(); 67 68 80 Level.Background.Image = taustaKuva; 81 Level.Background.FitToLevel(); 82 Level.Background.FitToLevel(); 69 83 } 70 84 … … 88 102 kohde.Destroy(); 89 103 SaalisDestroyed(); 104 90 105 } 91 106 … … 136 151 Saalis.Tag = "saalis"; 137 152 Saalis.Image = SaaliinKuva; 153 SaaliidenMaara++; 138 154 Add(Saalis); 139 155 Saalis.Shape = Shape.Star; … … 155 171 void SaalisDestroyed() 156 172 { 157 LuoSaalis(RandomGen.NextDouble(Level.Left, Level.Right), RandomGen.NextDouble(Level.Bottom, Level.Top)); 158 LuoSaalis(RandomGen.NextDouble(Level.Left, Level.Right), RandomGen.NextDouble(Level.Bottom, Level.Top)); 173 SaaliidenMaara--; 174 if (SaaliidenMaara < 10) 175 { 176 LuoSaalis(RandomGen.NextDouble(Level.Left, Level.Right), RandomGen.NextDouble(Level.Bottom, Level.Top)); 177 LuoSaalis(RandomGen.NextDouble(Level.Left, Level.Right), RandomGen.NextDouble(Level.Bottom, Level.Top)); 178 } 159 179 pisteLaskuri.Value = pisteLaskuri.Value + 1 ; 160 180 // KasvataMatoa(); … … 214 234 PhysicsObject Vihollinen = new PhysicsObject(new RaySegment(position, suunta, 2000)); 215 235 Vihollinen.MaximumLifetime = TimeSpan.FromSeconds(2.0); 216 Vihollinen.Color = Color. Red;236 Vihollinen.Color = Color.Yellow; 217 237 AddCollisionHandler(Vihollinen, KasitteleVihollisenTormays); 218 238 Add(Vihollinen); … … 225 245 { 226 246 kohde.Destroy(); 247 PeliLoppui(); 227 248 } 228 249 } … … 247 268 if (alaspainLaskuri.Value <= 0) 248 269 { 249 MessageDisplay.Add("Peli Loppui");250 270 timer.Stop(); 271 PeliLoppui(); 272 273 // täydennä mitä tapahtuu, kun aika loppuu 274 } 275 } 276 277 278 void uudestaan() 279 { 280 ClearAll(); 281 282 Aloitapeli(); 283 } 284 285 286 void PeliLoppui() 287 { 288 MessageDisplay.Add("Peli Loppui"); 289 ajastin.Stop(); 251 290 ClearAll(); 291 Keyboard.Listen(Key.R, ButtonState.Released, uudestaan, "aloitus"); 252 292 Widget lopputeksti = new Widget(Screen.Width, Screen.Height); 253 293 lopputeksti.Image = GameOver; 254 294 Add(lopputeksti); 255 295 256 // täydennä mitä tapahtuu, kun aika loppuu 257 } 258 } 259 260 261 void uudestaan() 262 { 263 ClearAll(); 264 265 Aloitapeli(); 296 HighScoreWindow topIkkuna = new HighScoreWindow("Pelin nimi tai jotain", 297 "Parhaat pisteet", 298 "Onneksi olkoon, pääsit listalle pisteillä %p! Syötä nimesi:", 299 topLista, pisteLaskuri.Value); 300 topIkkuna.Closed += TallennaPisteet; 301 Add(topIkkuna); 302 303 } 304 305 void TallennaPisteet(Window sender) 306 { 307 DataStorage.Save<ScoreList>(topLista, "pisteet.xml"); 266 308 } 267 309 -
2011/26/JouniM/MatoPeli/MatoPeli/MatoPeliContent/MatoPeliContent.contentproj
r2370 r2407 63 63 </Compile> 64 64 </ItemGroup> 65 <ItemGroup> 66 <Compile Include="taustakuva.jpg"> 67 <Name>taustakuva</Name> 68 <Importer>TextureImporter</Importer> 69 <Processor>TextureProcessor</Processor> 70 </Compile> 71 </ItemGroup> 72 <ItemGroup> 73 <Compile Include="duck hunt.mp3"> 74 <Name>duck hunt</Name> 75 <Importer>Mp3Importer</Importer> 76 <Processor>SongProcessor</Processor> 77 </Compile> 78 </ItemGroup> 65 79 <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 66 80 <!-- 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.