- Timestamp:
- 2010-07-08 11:31:36 (13 years ago)
- Location:
- 2010/27/frjolehm/The King of the island/The King of the island
- Files:
-
- 8 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
2010/27/frjolehm/The King of the island/The King of the island/Content/Content.contentproj
r1146 r1178 47 47 </ItemGroup> 48 48 <ItemGroup> 49 <Compile Include="Aita.png">50 <Name>Aita</Name>51 <Importer>TextureImporter</Importer>52 <Processor>TextureProcessor</Processor>53 </Compile>54 </ItemGroup>55 <ItemGroup>56 49 <Compile Include="Tipu1.png"> 57 50 <Name>Tipu1</Name> … … 65 58 </Compile> 66 59 </ItemGroup> 60 <ItemGroup> 61 <Compile Include="Kenttä1.png"> 62 <Name>Kenttä1</Name> 63 <Importer>TextureImporter</Importer> 64 <Processor>TextureProcessor</Processor> 65 </Compile> 66 </ItemGroup> 67 <ItemGroup> 68 <Compile Include="1.png"> 69 <Name>1</Name> 70 <Importer>TextureImporter</Importer> 71 <Processor>TextureProcessor</Processor> 72 </Compile> 73 </ItemGroup> 74 <ItemGroup> 75 <Compile Include="2.png"> 76 <Name>2</Name> 77 <Importer>TextureImporter</Importer> 78 <Processor>TextureProcessor</Processor> 79 </Compile> 80 <Compile Include="3.png"> 81 <Name>3</Name> 82 <Importer>TextureImporter</Importer> 83 <Processor>TextureProcessor</Processor> 84 </Compile> 85 </ItemGroup> 86 <ItemGroup> 87 <Compile Include="Aita.png"> 88 <Name>Aita</Name> 89 <Importer>TextureImporter</Importer> 90 <Processor>TextureProcessor</Processor> 91 </Compile> 92 </ItemGroup> 67 93 </Project> -
2010/27/frjolehm/The King of the island/The King of the island/Peli.cs
r1157 r1178 19 19 int Pelaajan1joukkue = Joukkueenkoko; 20 20 int Pelaajan2joukkue = Joukkueenkoko; 21 int peliMuoto = 2; 21 22 22 23 Boolean Pelaajan1JuoksuAskel; … … 27 28 double Pelaajan2Juoksunopeus = Juoksunopeus; 28 29 30 const double HyppyVoima = 4000; 31 32 ImageDisplay numero; 33 DoubleMeter alaspainLaskuri; 34 29 35 protected override void Begin() 30 36 { 31 Aloitapikkupeli( 1);32 } 33 34 void Aloitapikkupeli( int peliMuoto)37 Aloitapikkupeli(); 38 } 39 40 void Aloitapikkupeli() 35 41 { 36 42 //Kuoleman juoksu 37 43 if (peliMuoto == 1) 38 44 { 39 LuoKenttä(800,700); 45 LuoKenttä(800,700); 40 46 Camera.ZoomToLevel(); 47 Level.Background.Image = LoadImage("Kenttä1"); 41 48 LuoElämät(); 42 AddCollisionHandler(oikeareuna, JuoksuVoitto);49 AddCollisionHandler(oikeareuna, Voitto); 43 50 pelaaja1 = LuoUkko(Level.Left + 30,Level.Bottom + 75,85, 75,"Tipu1"); 44 51 pelaaja2 = LuoUkko(Level.Left+ 30,Level.Bottom + 200,85, 75,"Tipu2"); 45 JuoksuOhjaimet();52 LuoAikaLaskuri(); 46 53 } 47 54 else if (peliMuoto == 2) 48 55 { 49 LuoKenttä(3000, 1000); 50 LuoTausta(3000, Level.Bottom+75); 51 pelaaja1 = LuoUkko(Level.Left + 30, Level.Bottom + 75, 85, 75, "Tipu1"); 56 LuoKenttä(30000, 1000); 57 LuoTausta(30000, Level.Bottom+75); 58 59 pelaaja1 = LuoUkko(Level.Left + 150, Level.Bottom + 75, 85, 75, "Tipu1"); 60 pelaaja2 = LuoUkko(Level.Left + 10, Level.Bottom + 75, 85, 75, "Tipu2"); 61 Pelaajan1Juoksunopeus = 5000; 62 Pelaajan2Juoksunopeus = 5000; 63 52 64 Gravity = new Vector(0, -1000); 53 65 54 Camera.Follow(pelaaja1);55 66 LuoElämät(); 56 JuoksuOhjaimet();67 LuoAikaLaskuri(); 57 68 } 58 69 … … 61 72 void LuoTausta(int w, double y) 62 73 { 63 for (double x = Level.Left ; x < w; x += 100)64 { 65 LuoTaustaEsineitä(x, y, 50, 50, "Aita");74 for (double x = Level.Left+2500; x < w; x += RandomGen.NextDouble(600,1000) ) 75 { 76 LuoTaustaEsineitä(x, y, 100, 50, "Aita"); 66 77 } 67 78 } … … 70 81 PhysicsObject ukko = new PhysicsObject(w,h,Shapes.Rectangle); 71 82 ukko.Image = LoadImage(nimi); 83 ukko.Restitution = 0; 72 84 ukko.X = x; 73 85 ukko.Y = y; … … 95 107 } 96 108 109 void HyppyOhjaimet() 110 { 111 Keyboard.Listen(Key.W, ButtonState.Pressed, LuoHyppy, "Pelaaja1 hyppää", pelaaja1, false); 112 Keyboard.Listen(Key.Up, ButtonState.Pressed, LuoHyppy, "Pelaaja1 hyppää", pelaaja2, true); 113 } 114 115 void LuoHyppy(PlatformCharacter ukko,Boolean pelaaja) 116 { 117 ukko.Jump(HyppyVoima); 118 if (pelaaja == false) 119 { 120 Pelaajan1Juoksunopeus += Juoksunkiihtyvyys * 100; 121 } 122 else 123 { 124 Pelaajan2Juoksunopeus += Juoksunkiihtyvyys * 100; 125 } 126 } 127 128 97 129 void JuoksuOhjaimet() 98 130 { 99 Keyboard.Listen(Key.A, ButtonState.Pressed, LuoJuoksu, "Pelaaja liikkuu", pelaaja1, false, false);100 Keyboard.Listen(Key.D, ButtonState.Pressed, LuoJuoksu, "Pelaaja liikkuu", pelaaja1, false, true);131 Keyboard.Listen(Key.A, ButtonState.Pressed, LuoJuoksu, "Pelaaja1 liikkuu", pelaaja1, false, false); 132 Keyboard.Listen(Key.D, ButtonState.Pressed, LuoJuoksu, "Pelaaja1 liikkuu", pelaaja1, false, true); 101 133 102 134 Keyboard.Listen(Key.Left, ButtonState.Pressed, LuoJuoksu, "Pelaaja2 liikkuu", pelaaja2, true, false); … … 151 183 } 152 184 153 void JuoksuVoitto(PhysicsObject maali, PhysicsObject kohde)185 void Voitto(PhysicsObject maali, PhysicsObject kohde) 154 186 { 155 187 if(kohde == pelaaja1) 156 188 { 157 ClearAll(); 158 Pelaajan2joukkue--; 159 Aloitapikkupeli(2); 189 if (peliMuoto == 1) 190 { 191 ClearAll(); 192 Pelaajan2joukkue--; 193 peliMuoto++; 194 Aloitapikkupeli(); 195 } 196 else if (peliMuoto == 2) 197 { 198 ClearAll(); 199 Pelaajan1joukkue--; 200 peliMuoto++; 201 Aloitapikkupeli(); 202 } 160 203 } 161 204 else if (kohde == pelaaja2) 162 205 { 163 ClearAll(); 164 Pelaajan2joukkue--; 165 Aloitapikkupeli(2); 166 } 167 } 206 if (peliMuoto == 1) 207 { 208 ClearAll(); 209 Pelaajan1joukkue--; 210 peliMuoto++; 211 Aloitapikkupeli(); 212 } 213 else if (peliMuoto == 2) 214 { 215 ClearAll(); 216 Pelaajan2joukkue--; 217 peliMuoto++; 218 Aloitapikkupeli(); 219 } 220 } 221 } 222 168 223 169 224 void LuoElämät() … … 203 258 } 204 259 260 void LuoAikaLaskuri() 261 { 262 alaspainLaskuri = new DoubleMeter(4); 263 numero = new ImageDisplay(); ; 264 265 Timer aikaLaskuri = new Timer(); 266 aikaLaskuri.Interval = 1; 267 aikaLaskuri.Trigger += LaskeAlaspäin; 268 Add(aikaLaskuri); 269 aikaLaskuri.Start(); 270 271 } 272 273 void LaskeAlaspäin(Timer timer) 274 { 275 alaspainLaskuri.Value -= 1; 276 if (alaspainLaskuri.Value <= 0) 277 { 278 if (peliMuoto == 1) 279 { 280 JuoksuOhjaimet(); 281 } 282 else if (peliMuoto == 2) 283 { 284 HyppyOhjaimet(); 285 } 286 287 timer.Stop(); 288 numero.Destroy(); 289 290 // täydennä mitä tapahtuu, kun aika loppuu 291 }else if (alaspainLaskuri.Value <= 1) 292 { 293 numero.Image = LoadImage("1"); 294 295 } 296 else if (alaspainLaskuri.Value <= 2) 297 { 298 numero.Image = LoadImage("2"); 299 } 300 else if (alaspainLaskuri.Value <= 3) 301 { 302 numero.Image = LoadImage("3"); 303 Add(numero); 304 } 305 } 306 307 205 308 void Liikuta(PlatformCharacter ukko, double nopeus) 206 309 { … … 208 311 } 209 312 313 210 314 PlatformCharacter LuoUkko(double x, double y, double kokoX, double kokoY, string nimi) 211 315 { 212 PlatformCharacter ukko = new PlatformCharacter(kokoX, kokoY, Shapes. Circle);316 PlatformCharacter ukko = new PlatformCharacter(kokoX, kokoY, Shapes.Rectangle); 213 317 ukko.Mass = 4.0; 214 318 ukko.X = x; … … 218 322 return ukko; 219 323 } 324 325 protected override void Update(Time time) 326 { 327 base.Update(time); 328 if (peliMuoto == 2) 329 { 330 pelaaja1.Push(new Vector(Pelaajan1Juoksunopeus, 0)); 331 pelaaja2.Push(new Vector(Pelaajan2Juoksunopeus, 0)); 332 Camera.X = (pelaaja1.X + pelaaja2.X) / 2; 333 } 334 } 220 335 } -
2010/27/frjolehm/The King of the island/The King of the island/The King of the island.csproj
r1125 r1178 57 57 </PropertyGroup> 58 58 <ItemGroup> 59 <Reference Include="Jypeli2, Version=2. 3.1.0, Culture=neutral, processorArchitecture=x86">59 <Reference Include="Jypeli2, Version=2.2.3.0, Culture=neutral, processorArchitecture=x86"> 60 60 <SpecificVersion>False</SpecificVersion> 61 61 <HintPath>..\..\..\lib\Jypeli2.dll</HintPath>
Note: See TracChangeset
for help on using the changeset viewer.