Changeset 4276
- Timestamp:
- 2013-06-27 14:56:47 (10 years ago)
- Location:
- 2013/26/RoopeR
- Files:
-
- 18 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
2013/26/RoopeR/The Random game/The Random game/The Random game/The_Random_game.cs
r4233 r4276 9 9 public class The_Random_game : PhysicsGame 10 10 { 11 12 const double nopeus = 200; 13 const double hyppyNopeus = 3000; 11 ScoreList topLista = new ScoreList(10, false, 0); 12 13 const double nopeus = 100; 14 const double hyppyNopeus = 2000; 14 15 const int RUUDUN_KOKO = 60; 15 16 int kenttaNro = 1; 17 int maara = 0; 16 18 PlatformCharacter pelaaja1; 17 19 18 19 Image tahtiKuva = LoadImage("tahti"); 20 IntMeter pisteLaskuri; 21 22 Image kerattavaKuva = LoadImage("kerattava"); 20 23 Image esteKuva = LoadImage("Este"); 21 24 Image pelaajakuva = LoadImage("pelaaja"); 22 25 Image maalikuva = LoadImage("Untitled"); 23 26 24 27 SoundEffect maaliAani = LoadSoundEffect("maali"); 25 28 26 29 public override void Begin() 27 30 { 31 alkuvalikko(); 32 33 34 35 } 36 37 38 void alkuvalikko() 39 { 40 MultiSelectWindow alkuValikko = new MultiSelectWindow("The Random Game", "Start game", "exit"); 41 Add(alkuValikko); 42 alkuValikko.AddItemHandler(0, SeuraavaKentta); 43 //alkuValikko.AddItemHandler(1, ParhaatPisteet); 44 alkuValikko.AddItemHandler(1, Exit); 45 } 46 47 void TormaaMaaliin(PhysicsObject pelaaja, PhysicsObject maali) 48 { 49 if (maara == 0) 50 { 51 kenttaNro++; 52 SeuraavaKentta(); 53 } 54 } 55 void SeuraavaKentta() 56 { 57 ClearAll(); 58 maara = 0; 59 if (kenttaNro > 17) Exit(); 60 else LuoKentta("kentta" + kenttaNro); 61 //if (kenttaNro == 1) LuoKentta("kentta1"); 62 //else if (kenttaNro == 2) LuoKentta("kentta2"); 63 //else if (kenttaNro == 3) LuoKentta("kentta3"); 64 //else if (kenttaNro == 4) LuoKentta("kentta4"); 65 //else if (kenttaNro == 5) LuoKentta("kentta5"); 66 //else if (kenttaNro == 6) LuoKentta("kentta6"); 67 //else if (kenttaNro == 7) LuoKentta("kentta7"); 68 //else if (kenttaNro == 8) LuoKentta("kentta8"); 69 //else if (kenttaNro == 9) LuoKentta("kentta9"); 70 //else if (kenttaNro == 10) LuoKentta("kentta10"); 71 //else if (kenttaNro == 11) LuoKentta("kentta11"); 72 //else if (kenttaNro == 12) LuoKentta("kentta12"); 73 //else if (kenttaNro == 13) LuoKentta("kentta13"); 74 //else if (kenttaNro == 14) LuoKentta("kentta14"); 75 //else if (kenttaNro == 15) LuoKentta("kentta15"); 76 //else if (kenttaNro == 16) LuoKentta("kentta16"); 77 //else if (kenttaNro == 17) LuoKentta("kentta17"); 78 //else if (kenttaNro > 17) Exit(); 79 28 80 Gravity = new Vector(0, -3000); 29 81 30 SeuraavaKentta();31 82 LisaaNappaimet(); 83 LuoPistelaskuri(); 84 LuoAikaLaskuri(); 32 85 33 86 Camera.Follow(pelaaja1); 34 87 Camera.ZoomFactor = 1.2; 35 88 Camera.StayInLevel = true; 36 }37 38 void TormaaMaaliin(PhysicsObject pelaaja, PhysicsObject maali)39 {40 41 }42 void SeuraavaKentta()43 {44 if (kenttaNro == 1) LuoKentta("kentta1");45 else if (kenttaNro == 2) LuoKentta("kentta2");46 else if (kenttaNro == 3) LuoKentta("kentta3");47 else if (kenttaNro > 3) Exit();48 89 } 49 90 … … 89 130 void LisaaEste(Vector paikka, double leveys, double korkeus) 90 131 { 91 PhysicsObject este = PhysicsObject.CreateStaticObject(leveys * 1.5, korkeus);132 PhysicsObject este = PhysicsObject.CreateStaticObject(leveys / 2, korkeus / 2); 92 133 este.Image = esteKuva; 93 134 este.Shape = Shape.FromImage(esteKuva); … … 95 136 este.Color = Color.Magenta; 96 137 Add(este); 97 este.Restitution = ( 5.0);138 este.Restitution = (1.0); 98 139 99 140 } … … 104 145 tahti.IgnoresCollisionResponse = true; 105 146 tahti.Position = paikka; 106 tahti.Image = tahtiKuva;147 tahti.Image = kerattavaKuva; 107 148 tahti.Tag = "random"; 108 149 Add(tahti); 109 tahti.Restitution = (2.0); 150 tahti.Restitution = (0.0); 151 maara++; 110 152 } 111 153 112 154 void LisaaPelaaja(Vector paikka, double leveys, double korkeus) 113 155 { 114 pelaaja1 = new PlatformCharacter(leveys , korkeus);156 pelaaja1 = new PlatformCharacter(leveys / 2, korkeus / 2); 115 157 pelaaja1.Position = paikka; 116 158 pelaaja1.Mass = 5.0; 117 pelaaja1.Restitution = 5.0;159 pelaaja1.Restitution = 1.0; 118 160 pelaaja1.Image = pelaajakuva; 119 AddCollisionHandler(pelaaja1, " tahti", TormaaTahteen);161 AddCollisionHandler(pelaaja1, "random", TormaaTahteen); 120 162 AddCollisionHandler(pelaaja1, "maali", TormaaMaaliin); 121 163 Add(pelaaja1); 122 pelaaja1.LifetimeLeft = TimeSpan.FromSeconds(60 .0);123 pelaaja1.Push(new Vector(1 000, 0));124 } 125 164 pelaaja1.LifetimeLeft = TimeSpan.FromSeconds(60); 165 pelaaja1.Push(new Vector(1, 0)); 166 } 167 126 168 127 169 … … 130 172 Keyboard.Listen(Key.F1, ButtonState.Pressed, ShowControlHelp, "Näytä ohjeet"); 131 173 Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli"); 132 174 Keyboard.Listen(Key.A, ButtonState.Down, Liikuta, "Liikkuu vasemmalle", pelaaja1, -nopeus); 175 Keyboard.Listen(Key.D, ButtonState.Down, Liikuta, "Liikkuu vasemmalle", pelaaja1, nopeus); 176 Keyboard.Listen(Key.W, ButtonState.Pressed, Hyppaa, "pelaaja hyppää", pelaaja1, hyppyNopeus); 133 177 Keyboard.Listen(Key.Left, ButtonState.Down, Liikuta, "Liikkuu vasemmalle", pelaaja1, -nopeus); 134 178 Keyboard.Listen(Key.Right, ButtonState.Down, Liikuta, "Liikkuu vasemmalle", pelaaja1, nopeus); 135 179 Keyboard.Listen(Key.Up, ButtonState.Pressed, Hyppaa, "Pelaaja hyppää", pelaaja1, hyppyNopeus); 136 180 Keyboard.Listen(Key.P, ButtonState.Pressed, Pause, "Pysäyttää pelin"); 137 ControllerOne.Listen(Button.Back, ButtonState.Pressed, Exit, "Poistu pelistä"); 138 139 ControllerOne.Listen(Button.DPadLeft, ButtonState.Down, Liikuta, "Pelaaja liikkuu vasemmalle", pelaaja1, -nopeus); 140 ControllerOne.Listen(Button.DPadRight, ButtonState.Down, Liikuta, "Pelaaja liikkuu oikealle", pelaaja1, nopeus); 141 ControllerOne.Listen(Button.A, ButtonState.Pressed, Hyppaa, "Pelaaja hyppää", pelaaja1, hyppyNopeus); 142 143 PhoneBackButton.Listen(ConfirmExit, "Lopeta peli"); 144 } 181 Keyboard.Listen(Key.Enter, ButtonState.Pressed, SeuraavaKentta, "Aloittaa kentän uudestaan"); 182 183 ControllerOne.ListenAnalog(AnalogControl.LeftStick, 0.1, 184 LiikutaTatilla, "Liikuta pelaajaa tattia pyörittämällä.", pelaaja1, 1000.0); 185 ControllerOne.Listen(Button.DPadLeft, ButtonState.Down, Liikuta, null, pelaaja1, -100.0); 186 ControllerOne.Listen(Button.DPadRight, ButtonState.Down, 187 Liikuta, null, pelaaja1, 100.0); 188 ControllerOne.Listen(Button.DPadUp, ButtonState.Down, 189 Hyppaa, null, pelaaja1, 1000.0); 190 ControllerOne.Listen(Button.A, ButtonState.Pressed, Hyppaa, "Hyppää", pelaaja1, 1000.0); 191 192 } 193 194 void LiikutaTatilla(AnalogState a, PlatformCharacter pelaaja, double voima) 195 { 196 Vector tatinAsento = a.StateVector; 197 //if (tatinAsento.Y > 0) pelaaja.Jump(voima*2); 198 pelaaja.Walk(tatinAsento.X * voima); 199 200 } 201 145 202 146 203 void Liikuta(PlatformCharacter hahmo, double nopeus) … … 157 214 { 158 215 // maaliAani.Play(); 159 MessageDisplay.Add("Onnea keräsit tähden!!! :)");216 MessageDisplay.Add("Onnea keräsit merkin!!! :)"); 160 217 tahti.Destroy(); 161 } 162 } 218 pisteLaskuri.Value++; 219 maara--; 220 } 221 222 void LuoPistelaskuri() 223 { 224 pisteLaskuri = new IntMeter(0); 225 226 Label pisteNaytto = new Label(); 227 pisteNaytto.X = Screen.Right - 100; 228 pisteNaytto.Y = Screen.Top - 100; 229 pisteNaytto.TextColor = Color.Black; 230 pisteNaytto.Color = Color.HotPink; 231 pisteNaytto.Title = "Pisteet"; 232 pisteNaytto.BindTo(pisteLaskuri); 233 Add(pisteNaytto); 234 235 } 236 237 238 void LuoAikaLaskuri() 239 { 240 Timer aikaLaskuri = new Timer(); 241 //aikaLaskuri.Interval = 30.0; 242 aikaLaskuri.GetType().GetField("trigInterval", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.GetField | System.Reflection.BindingFlags.Instance).SetValue(aikaLaskuri, TimeSpan.FromSeconds(300)); 243 aikaLaskuri.Timeout += AikaLoppui; 244 aikaLaskuri.Start(1); 245 246 247 Label aikaNaytto = new Label(); 248 aikaNaytto.TextColor = Color.Black; 249 aikaNaytto.DecimalPlaces = 1; 250 aikaNaytto.X = Screen.Right - 100; 251 aikaNaytto.Y = Screen.Top - 200; 252 aikaNaytto.BindTo(aikaLaskuri.SecondCounter); 253 Add(aikaNaytto); 254 } 255 256 void AikaLoppui() 257 { 258 MessageDisplay.Add("Aika loppui..."); 259 SeuraavaKentta(); 260 261 } 262 263 } 264 265 266 163 267 164 165 -
2013/26/RoopeR/The Random game/The Random game/The Random gameContent/The Random gameContent.contentproj
r4233 r4276 56 56 <Processor>TextureProcessor</Processor> 57 57 </Compile> 58 <Compile Include="pelaaja.png"> 59 <Name>pelaaja</Name> 60 <Importer>TextureImporter</Importer> 61 <Processor>TextureProcessor</Processor> 62 </Compile> 58 63 <Compile Include="tahti.png"> 59 64 <Name>tahti</Name> … … 76 81 </ItemGroup> 77 82 <ItemGroup> 78 <Compile Include="pelaaja.png">79 <Name>pelaaja</Name>80 <Importer>TextureImporter</Importer>81 <Processor>TextureProcessor</Processor>82 </Compile>83 </ItemGroup>84 <ItemGroup>85 83 <Compile Include="Untitled.png"> 86 84 <Name>Untitled</Name> 87 85 <Importer>TextureImporter</Importer> 88 86 <Processor>TextureProcessor</Processor> 87 </Compile> 88 </ItemGroup> 89 <ItemGroup> 90 <Compile Include="kerattava.png"> 91 <Name>kerattava</Name> 92 <Importer>TextureImporter</Importer> 93 <Processor>TextureProcessor</Processor> 94 </Compile> 95 </ItemGroup> 96 <ItemGroup> 97 <Compile Include="kentta2.txt"> 98 <CopyToOutputDirectory>Always</CopyToOutputDirectory> 99 <Name>kentta2</Name> 100 <Importer>TextFileImporter</Importer> 101 <Processor>TextFileContentProcessor</Processor> 102 </Compile> 103 </ItemGroup> 104 <ItemGroup> 105 <Compile Include="kentta3.txt"> 106 <CopyToOutputDirectory>Always</CopyToOutputDirectory> 107 <Name>kentta3</Name> 108 <Importer>TextFileImporter</Importer> 109 <Processor>TextFileContentProcessor</Processor> 110 </Compile> 111 </ItemGroup> 112 <ItemGroup> 113 <Compile Include="kentta4.txt"> 114 <CopyToOutputDirectory>Always</CopyToOutputDirectory> 115 <Name>kentta4</Name> 116 <Importer>TextFileImporter</Importer> 117 <Processor>TextFileContentProcessor</Processor> 118 </Compile> 119 </ItemGroup> 120 <ItemGroup> 121 <Compile Include="kentta5.txt"> 122 <CopyToOutputDirectory>Always</CopyToOutputDirectory> 123 <Name>kentta5</Name> 124 <Importer>TextFileImporter</Importer> 125 <Processor>TextFileContentProcessor</Processor> 126 </Compile> 127 </ItemGroup> 128 <ItemGroup> 129 <Compile Include="kentta6.txt"> 130 <CopyToOutputDirectory>Always</CopyToOutputDirectory> 131 <Name>kentta6</Name> 132 <Importer>TextFileImporter</Importer> 133 <Processor>TextFileContentProcessor</Processor> 134 </Compile> 135 </ItemGroup> 136 <ItemGroup> 137 <Compile Include="kentta7.txt"> 138 <CopyToOutputDirectory>Always</CopyToOutputDirectory> 139 <Name>kentta7</Name> 140 <Importer>TextFileImporter</Importer> 141 <Processor>TextFileContentProcessor</Processor> 142 </Compile> 143 </ItemGroup> 144 <ItemGroup> 145 <Compile Include="kentta8.txt"> 146 <CopyToOutputDirectory>Always</CopyToOutputDirectory> 147 <Name>kentta8</Name> 148 <Importer>TextFileImporter</Importer> 149 <Processor>TextFileContentProcessor</Processor> 150 </Compile> 151 </ItemGroup> 152 <ItemGroup> 153 <Compile Include="kentta9.txt"> 154 <CopyToOutputDirectory>Always</CopyToOutputDirectory> 155 <Name>kentta9</Name> 156 <Importer>TextFileImporter</Importer> 157 <Processor>TextFileContentProcessor</Processor> 158 </Compile> 159 </ItemGroup> 160 <ItemGroup> 161 <Compile Include="kentta10.txt"> 162 <CopyToOutputDirectory>Always</CopyToOutputDirectory> 163 <Name>kentta10</Name> 164 <Importer>TextFileImporter</Importer> 165 <Processor>TextFileContentProcessor</Processor> 166 </Compile> 167 </ItemGroup> 168 <ItemGroup> 169 <Compile Include="kentta11.txt"> 170 <CopyToOutputDirectory>Always</CopyToOutputDirectory> 171 <Name>kentta11</Name> 172 <Importer>TextFileImporter</Importer> 173 <Processor>TextFileContentProcessor</Processor> 174 </Compile> 175 </ItemGroup> 176 <ItemGroup> 177 <Compile Include="kentta12.txt"> 178 <CopyToOutputDirectory>Always</CopyToOutputDirectory> 179 <Name>kentta12</Name> 180 <Importer>TextFileImporter</Importer> 181 <Processor>TextFileContentProcessor</Processor> 182 </Compile> 183 </ItemGroup> 184 <ItemGroup> 185 <Compile Include="kentta13.txt"> 186 <CopyToOutputDirectory>Always</CopyToOutputDirectory> 187 <Name>kentta13</Name> 188 <Importer>TextFileImporter</Importer> 189 <Processor>TextFileContentProcessor</Processor> 190 </Compile> 191 </ItemGroup> 192 <ItemGroup> 193 <Compile Include="kentta14.txt"> 194 <CopyToOutputDirectory>Always</CopyToOutputDirectory> 195 <Name>kentta14</Name> 196 <Importer>TextFileImporter</Importer> 197 <Processor>TextFileContentProcessor</Processor> 198 </Compile> 199 </ItemGroup> 200 <ItemGroup> 201 <Compile Include="kentta15.txt"> 202 <CopyToOutputDirectory>Always</CopyToOutputDirectory> 203 <Name>kentta15</Name> 204 <Importer>TextFileImporter</Importer> 205 <Processor>TextFileContentProcessor</Processor> 206 </Compile> 207 </ItemGroup> 208 <ItemGroup> 209 <Compile Include="kentta16.txt"> 210 <CopyToOutputDirectory>Always</CopyToOutputDirectory> 211 <Name>kentta16</Name> 212 <Importer>TextFileImporter</Importer> 213 <Processor>TextFileContentProcessor</Processor> 214 </Compile> 215 </ItemGroup> 216 <ItemGroup> 217 <Compile Include="kentta17.txt"> 218 <CopyToOutputDirectory>Always</CopyToOutputDirectory> 219 <Name>kentta17</Name> 220 <Importer>TextFileImporter</Importer> 221 <Processor>TextFileContentProcessor</Processor> 89 222 </Compile> 90 223 </ItemGroup> -
2013/26/RoopeR/The Random game/The Random game/The Random gameContent/kentta1.txt
r4233 r4276 3 3 4 4 * * 5 ## ## 5 ## ## M 6 6 7 * *7 * * * 8 8 ## ## ## 9 9 10 10 * * * * 11 ## ## ####11 ############### 12 12 13 * * * *13 * * * * * 14 14 ## ## ## ## ## 15 15 16 ! N M16 N 17 17 ######################
Note: See TracChangeset
for help on using the changeset viewer.