- Timestamp:
- 2011-06-09 13:43:16 (10 years ago)
- Location:
- 2011/23/hejumunt/RunRunRun/RunRunRun
- Files:
-
- 21 added
- 1 deleted
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
2011/23/hejumunt/RunRunRun/RunRunRun/RunRunRun/Peli.cs
r1789 r1814 27 27 Image kellonKuva = LoadImage("kello"); 28 28 Image kodinKuva = LoadImage("koti"); 29 Image tausta nKuva = LoadImage("tausta");29 Image taustaKuva = LoadImage("tausta1"); 30 30 Shape hahmonMuoto; 31 31 … … 34 34 DoubleMeter alaspainLaskuri; 35 35 int elämät = 3; 36 Timer ajastin; 37 PhysicsObject kello; 36 Timer ajastin = new Timer(); 37 int kenttäNro = 1; 38 int kenttäMäärä = 2; 38 39 39 40 List<Label> valikonKohdat; … … 51 52 valikonKohdat = new List<Label>(); 52 53 54 ajastin.Stop(); 55 56 // Miksi taustakuva ei näy kun pelistä tullaan pois escillä?? 57 Level.Width = Screen.Width; 58 Level.Height = Screen.Height; 59 60 Camera.Reset(); 61 62 //Level.Background.Size = new Vector(Screen.Width, Screen.Height); 63 Level.Background.Image = taustaKuva; 64 //Level.Background.Size = new Vector(Screen.Width, Screen.Height); 65 //Level.Background.FitToLevel(); 66 Level.Background.Width = Screen.Width; 67 Level.Background.Height = Screen.Height; 68 53 69 Label kohta1 = new Label("Aloita uusi peli"); 54 kohta1.Position = new Vector(0, 40);70 kohta1.Position = new Vector(0, 300); 55 71 valikonKohdat.Add(kohta1); 56 72 57 73 Label kohta2 = new Label("Lopeta"); 58 kohta2.Position = new Vector(0, - 40);74 kohta2.Position = new Vector(0, -300); 59 75 valikonKohdat.Add(kohta2); 60 76 … … 124 140 { 125 141 ClearAll(); 126 Valikko(); 142 Valikko(); // Taustakuva ei näy? ks. r53 127 143 } 128 144 void Uudestaan() … … 130 146 ClearGameObjects(); 131 147 LuoKenttä(); 132 alaspainLaskuri.Value = 700;148 alaspainLaskuri.Value = 15; 133 149 ajastin.Start(); 134 150 } 135 151 152 136 153 void LuoKenttä() 137 154 { 138 TileMap kentta = TileMap.FromFile("kentta .txt");155 TileMap kentta = TileMap.FromFile("kentta" + kenttäNro + ".txt"); 139 156 kentta['%'] = lisaaTanko; 140 157 kentta['#'] = lisaaSeina; … … 183 200 alaspainLaskuri.Value = alaspainLaskuri.Value + 10; 184 201 } 185 } 202 if (kohde.Tag.ToString() == "koti") 203 { 204 ajastin.Stop(); 205 kenttaloppui(); 206 } 207 208 } 209 210 void kenttaloppui() 211 { 212 kenttäNro++; 213 ClearAll(); 214 if (kenttäNro > kenttäMäärä) 215 { 216 ClearAll(); 217 SeuraavaKentta(); 218 } 219 else 220 { 221 ClearAll(); 222 Label teksti = new Label("Wuuhuu!! Voitit tason! Paina ENTER päästaksesi seuraavaan tai ESC poistuaksesi alkuvalikkoon"); 223 teksti.TextColor = Color.Yellow; 224 Add(teksti); 225 Keyboard.Listen(Key.Enter, ButtonState.Pressed, SeuraavaKentta, null); 226 Keyboard.Listen(Key.Escape, ButtonState.Pressed, Palaaminen, null); 227 // voittoteksti 228 // 3 sekunnin paasta SeuraavaKentta(); 229 // Timer.SingleShot... 230 } 231 } 232 void SeuraavaKentta() 233 { 234 235 ClearAll(); 236 237 if (kenttäNro > kenttäMäärä) 238 { 239 ClearAll(); 240 Label teksti = new Label("Onneksi olkoon! Olet voittanut pelin! Paina ESC palataksesi valikkoon"); 241 teksti.TextColor = Color.Yellow; 242 Add(teksti); 243 Keyboard.Listen(Key.Escape, ButtonState.Pressed, Valikko, null); 244 return; 245 246 } 247 LuoKenttä(); 248 AsetaOhjaimet(); 249 250 alaspainLaskuri = new DoubleMeter(15); 251 252 ajastin = new Timer(); 253 ajastin.Interval = 0.1; 254 ajastin.Trigger += aikaloppui; 255 ajastin.Start(); 256 257 Label aikaNaytto = new Label(); 258 aikaNaytto.TextColor = Color.Black; 259 aikaNaytto.BindTo(alaspainLaskuri); 260 Add(aikaNaytto); 261 262 Mouse.IsCursorVisible = false; 263 264 } 265 186 266 PhysicsObject lisaaKoti() 187 267 { 188 268 PhysicsObject koti = PhysicsObject.CreateStaticObject(80, 200); 189 269 koti.Image = kodinKuva; 270 koti.Tag = "koti"; 190 271 return koti; 191 272 } … … 281 362 hahmonMuoto = Shape.FromImage(hahmonKuva); 282 363 364 kenttäNro = 1; 365 283 366 LuoKenttä(); 284 367 AsetaOhjaimet(); 285 368 elämät = 3; 286 alaspainLaskuri = new DoubleMeter( 700);287 288 ajastin = new Timer();369 alaspainLaskuri = new DoubleMeter(15); 370 371 289 372 ajastin.Interval = 0.1; 290 373 ajastin.Trigger += aikaloppui; … … 336 419 } 337 420 338 339 //void liikutaHahmoa(Timer Sender)340 //{341 //hahmo.Velocity = new Vector(100.0, hahmo.Velocity.Y);342 //}343 344 421 } -
2011/23/hejumunt/RunRunRun/RunRunRun/RunRunRun/RunRunRun.csproj
r1739 r1814 119 119 <Content Include="Game.ico" /> 120 120 <Content Include="GameThumbnail.png" /> 121 <Content Include="kentta.txt"> 122 <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> 121 <Content Include="kentta1.txt"> 122 <CopyToOutputDirectory>Always</CopyToOutputDirectory> 123 </Content> 124 <Content Include="kentta2.txt"> 125 <CopyToOutputDirectory>Always</CopyToOutputDirectory> 123 126 </Content> 124 127 </ItemGroup> -
2011/23/hejumunt/RunRunRun/RunRunRun/RunRunRunContent/RunRunRunContent.contentproj
r1789 r1814 175 175 </Compile> 176 176 </ItemGroup> 177 <ItemGroup> 178 <Compile Include="tausta1.png"> 179 <Name>tausta1</Name> 180 <Importer>TextureImporter</Importer> 181 <Processor>TextureProcessor</Processor> 182 </Compile> 183 </ItemGroup> 177 184 <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 178 185 <!-- 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.