- Timestamp:
- 2011-06-08 20:46:32 (10 years ago)
- Location:
- 2011/23/hejumunt/RunRunRun/RunRunRun
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
2011/23/hejumunt/RunRunRun/RunRunRun/RunRunRun/Peli.cs
r1757 r1770 25 25 Image puunKuva = LoadImage("puurunko"); 26 26 Image puun1Kuva = LoadImage("puulehdet"); 27 Image kellonKuva = LoadImage("kello"); 27 28 Shape hahmonMuoto; 28 29 … … 31 32 DoubleMeter alaspainLaskuri; 32 33 int elämät = 3; 34 Timer ajastin; 35 PhysicsObject kello; 36 37 List<Label> valikonKohdat; 33 38 34 39 public override void Begin() 35 40 { 36 41 // TODO: Kirjoita ohjelmakoodisi tähän 37 hahmonMuoto = Shape.FromImage(hahmonKuva); 38 39 LuoKenttä(); 40 AloitaPeli(); 41 AsetaOhjaimet(); 42 43 alaspainLaskuri = new DoubleMeter(2); 44 45 Timer ajastin = new Timer(); 46 ajastin.Interval = 0.1; 47 ajastin.Trigger += aikaloppui; 48 ajastin.Start(); 49 50 Label aikaNaytto = new Label(); 51 aikaNaytto.TextColor = Color.Black; 52 aikaNaytto.BindTo(alaspainLaskuri); 53 Add(aikaNaytto); 54 55 56 } 42 Valikko(); 43 44 45 } 46 void Valikko() 47 { 48 ClearAll(); 49 valikonKohdat = new List<Label>(); 50 51 Label kohta1 = new Label("Aloita uusi peli"); 52 kohta1.Position = new Vector(0, 40); 53 valikonKohdat.Add(kohta1); 54 55 Label kohta2 = new Label("Lopeta"); 56 kohta2.Position = new Vector(0, -40); 57 valikonKohdat.Add(kohta2); 58 59 foreach (Label valikonKohta in valikonKohdat) 60 { 61 Add(valikonKohta); 62 } 63 64 Mouse.ListenOn(kohta1, MouseButton.Left, ButtonState.Pressed, AloitaPeli, null); 65 Mouse.ListenOn(kohta2, MouseButton.Left, ButtonState.Pressed, Lopeta, null); 66 67 Mouse.IsCursorVisible = true; 68 Mouse.ListenMovement(1.0, ValikossaLiikkuminen, null); 69 Keyboard.Listen(Key.Escape, ButtonState.Pressed, Lopeta, ""); 70 } 71 void ValikossaLiikkuminen(AnalogState hiirenTila) 72 { 73 foreach (Label kohta in valikonKohdat) 74 { 75 if (Mouse.IsCursorOn(kohta)) 76 { 77 kohta.TextColor = Color.Red; 78 } 79 else 80 { 81 kohta.TextColor = Color.Black; 82 } 83 84 } 85 } 86 87 57 88 void aikaloppui(Timer Sender) 58 89 { … … 74 105 75 106 } 107 void Lopeta() 108 { 109 Exit(); 110 } 111 76 112 void gameover() 77 113 { 78 114 ClearAll(); 115 Label teksti = new Label("Oho! Hävisit pelin! Paina ESC palataksesi alkuvalikkoon!"); 116 teksti.TextColor = Color.Yellow; 117 Add( teksti ); 118 Keyboard.Listen(Key.Escape, ButtonState.Pressed, Palaaminen, null); 119 120 } 121 void Palaaminen() 122 { 123 ClearAll(); 124 Valikko(); 79 125 } 80 126 void Uudestaan() … … 82 128 ClearGameObjects(); 83 129 LuoKenttä(); 84 ResetElapsedTime(); 85 } 86 void LuoAloitusruutu() 87 { 88 } 130 alaspainLaskuri.Value = 700; 131 ajastin.Start(); 132 } 133 89 134 void LuoKenttä() 90 135 { … … 107 152 kentta['0'] = lisaaPuu; 108 153 kentta['9'] = lisaaPuu1; 154 kentta['E'] = lisaaKello; 109 155 kentta.Insert(40.0, 40.0); 110 156 … … 124 170 //Timer ajastin = new Timer(); 125 171 //ajastin.Interval = 0.01; 126 //ajastin.Trigger += liikutaHahmoa ;172 //ajastin.Trigger += liikutaHahmoa 127 173 //ajastin.Start(); 128 174 } 129 175 void kasittelehahmontormays(PhysicsObject hahmo, PhysicsObject kohde) 130 176 { 131 177 if (kohde.Tag.ToString() == "kello") 178 { 179 kohde.Destroy(); 180 } 181 } 182 PhysicsObject lisaaKello() 183 { 184 PhysicsObject kello = PhysicsObject.CreateStaticObject(40, 40); 185 kello.Image = kellonKuva; 186 kello.Tag = "kello"; 187 return kello; 188 } 189 void osuKelloon(PhysicsObject hahmo, PhysicsObject kohde) 190 { 191 if (kohde.Tag.ToString() == "kello") 192 { 193 kohde.Destroy(); 194 } 132 195 } 133 196 PhysicsObject lisaaTaso() … … 211 274 void AloitaPeli() 212 275 { 213 Vector impulssi = new Vector(300.0, 0.0); 214 hahmo.Hit(impulssi); 276 ClearAll(); 277 Keyboard.Listen(Key.Escape, ButtonState.Pressed, Valikko, "Palaa valikkoon"); 278 hahmonMuoto = Shape.FromImage(hahmonKuva); 279 280 LuoKenttä(); 281 AsetaOhjaimet(); 282 elämät = 3; 283 alaspainLaskuri = new DoubleMeter(700); 284 285 ajastin = new Timer(); 286 ajastin.Interval = 0.1; 287 ajastin.Trigger += aikaloppui; 288 ajastin.Start(); 289 290 Label aikaNaytto = new Label(); 291 aikaNaytto.TextColor = Color.Black; 292 aikaNaytto.BindTo(alaspainLaskuri); 293 Add(aikaNaytto); 294 215 295 } 216 296 PhysicsObject lisaaPuska() … … 238 318 Keyboard.Listen(Key.Space, ButtonState.Pressed, LiikutaPelaajaa, "Paina SPACE niin hahmo hyppää"); 239 319 Keyboard.Listen(Key.F1, ButtonState.Pressed, ShowControlHelp, "Näytä ohjeet"); 240 Keyboard.Listen(Key.Escape, ButtonState.Pressed, Exit, "Poistu");320 Keyboard.Listen(Key.Escape, ButtonState.Pressed, Valikko, "Poistu valikkoon"); 241 321 242 322 } -
2011/23/hejumunt/RunRunRun/RunRunRun/RunRunRun/kentta.txt
r1757 r1770 1 1 =========================================================================================================================== 2 = / / / 3 = / / / 4 = / / / 5 = / / K12 / 6 = / / ### / 7 = / N / N N N ### / 9 8 = / K112 % / % % % #I# / 99 9 = K112 / #### % / % % % ### / 999=10 = &&& #### / K12 #II# % / % % % #I# 9999=11 = &&&& #II# / ### #### % / % % % ?### 909=12 = &&&&&& #### #I# #II# % & %P %P % #I# 0=13 = &&&&&&&& #O## #O# #O#& % && %P %P % #O# 0=2 = / / / / / = 3 = / / / / / = 4 = / / / / / = 5 = / / K12 / / / = 6 = / / ### / / / = 7 = / N / N N N ### / 9 / N / = 8 = / K112 % / % % % #I# / 99 99 % / = 9 = K112 / 9 #### % / % % % ### / 999 9999 % / = 10 = &&& #### / 999 #II# % / % % % #I# 9999 990999 % / P = 11 = &&&& #II# / 99999 #### % / %E % % ?### 909 9009 % P PP = 12 = &&&&&& #### 999 #II# % & %P %P % #I# E0 00 % P P P = 13 = &&&&&&&& #O## 0 E#O#& % && %P %P % #O# 0 00 % PP EPP PP = 14 14 =========================================================================================================================== -
2011/23/hejumunt/RunRunRun/RunRunRun/RunRunRunContent/RunRunRunContent.contentproj
r1757 r1770 154 154 </Compile> 155 155 </ItemGroup> 156 <ItemGroup> 157 <Compile Include="Kello.png"> 158 <Name>Kello</Name> 159 <Importer>TextureImporter</Importer> 160 <Processor>TextureProcessor</Processor> 161 </Compile> 162 </ItemGroup> 156 163 <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 157 164 <!-- 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.