- Timestamp:
- 2012-07-05 12:49:13 (11 years ago)
- Location:
- 2012/27/LeeviK
- Files:
-
- 22 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
2012/27/LeeviK/PhysicsBall/PhysicsBall/PhysicsBall/PhysicsBall.cs
r3545 r3581 9 9 public class PhysicsBall : PhysicsGame 10 10 { 11 11 PhysicsObject este2; 12 PhysicsObject Tynnyri1; 13 PhysicsObject Este1; 14 Image BLOCK = LoadImage("Este"); 15 PhysicsObject Este; 16 PhysicsObject Aloitus; 12 17 Image Barrel = LoadImage("Kohde"); 13 18 PhysicsObject Tynnyri; 19 PhysicsObject Lava; 14 20 Image Kuva = LoadImage("Tausta"); 21 Image Laava = LoadImage("Lava"); 15 22 PhysicsObject Pelaaja; 16 23 PhysicsObject Maali; … … 22 29 Image Sahko = LoadImage("Warning"); 23 30 Image Tausta2 = LoadImage("Tausta42"); 31 SoundEffect maaliAani = LoadSoundEffect("maali"); 32 Image startti = LoadImage("Aloitus1"); 33 24 34 25 35 public override void Begin() 26 36 { 27 28 37 29 38 ControllerOne.Listen(Button.DPadLeft, ButtonState.Down, … … 45 54 Pelaaja.Color = Color.Lime; 46 55 47 48 49 56 Add(Pelaaja); 50 57 AddCollisionHandler(Pelaaja, KasittelePallonTormays); … … 53 60 Pelaaja.Restitution = 0.2; 54 61 Pelaaja.Image = Pallo; 55 56 57 62 58 63 Gravity = new Vector(0, -700); … … 93 98 Tynnyri.X = 240; 94 99 Tynnyri.Y = 75; 100 Tynnyri.Tag = "tynnyri"; 95 101 Add(Tynnyri); 96 102 Tynnyri.Image = Barrel; … … 98 104 return Maali; 99 105 Nappula.Image = button; 100 101 102 103 104 106 } 105 107 void MuutaPainovoima() … … 132 134 } 133 135 134 } 135 136 137 138 139 136 if (kohde.Tag.ToString() == "tynnyri") 137 { 138 139 kohde.Destroy(); 140 MessageDisplay.Add("Tuhosit tynnyrin!"); 141 maaliAani.Play(); 142 143 PhysicsObject Pelaaja1 = new PhysicsObject(50, 50); 144 Pelaaja1.X = -400; 145 Pelaaja1.Y = -150; 146 Pelaaja.Destroy(); 147 Add(Pelaaja1); 148 Pelaaja1.Image = Pallo; 149 150 151 ControllerOne.Listen(Button.DPadLeft, ButtonState.Down, 152 LiikutaPelaajaa, null, new Vector(-300, 0), Pelaaja1); 153 ControllerOne.Listen(Button.DPadRight, ButtonState.Down, 154 LiikutaPelaajaa, null, new Vector(300, 0), Pelaaja1); 155 156 Keyboard.Listen(Key.A, ButtonState.Down, 157 LiikutaPelaajaa1, null, new Vector(-300, 0), Pelaaja1); 158 Keyboard.Listen(Key.D, ButtonState.Down, 159 LiikutaPelaajaa1, null, new Vector(300, 0), Pelaaja1); 160 PhoneBackButton.Listen(ConfirmExit, "Lopeta peli"); 161 Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli"); 162 Level.BackgroundColor = Color.Gray; 163 Camera.Follow(Pelaaja1); 164 Camera.ZoomFactor = 1.0; 165 AddCollisionHandler(Pelaaja1, KasittelePallonTormays2); 166 AddCollisionHandler(Pelaaja1, KasittelePallonTormays3); 167 168 Level2(); 169 MessageDisplay.Add("Level2"); 170 171 172 } 173 174 } 175 void LiikutaPelaajaa1(Vector vektori, PhysicsObject pelaaja) 176 { 177 pelaaja.Push(vektori); 178 179 } 180 void Level2() 181 { 182 Level.CreateBottomBorder(); 183 PhysicsObject Lava = PhysicsObject.CreateStaticObject(800, 100); 184 Lava.X = -100; 185 Lava.Y = -300; 186 Add(Lava); 187 Lava.Image = Laava; 188 Lava.Tag = "Magma"; 189 190 PhysicsObject Aloitus = PhysicsObject.CreateStaticObject(200, 50); 191 Add(Aloitus); 192 Aloitus.X = -400; 193 Aloitus.Y = -200; 194 Aloitus.Image = startti; 195 196 197 PhysicsObject Este = PhysicsObject.CreateStaticObject(50, 400); 198 Add(Este); 199 Este.X = -200; 200 Este.Y = -200; 201 Este.Image = BLOCK; 202 Este.Tag = "ESTE1"; 203 204 PhysicsObject Este1 = PhysicsObject.CreateStaticObject(700, 50); 205 Add(Este1); 206 Este1.X = -150; 207 Este1.Y = 200; 208 Este1.Image = BLOCK; 209 Este1.Tag = "ESTE1"; 210 211 PhysicsObject Tynnyri1 = PhysicsObject.CreateStaticObject(100, 100); 212 Tynnyri1.X = 240; 213 Tynnyri1.Y = 75; 214 Tynnyri1.Tag = "tynnyri1"; 215 Add(Tynnyri1); 216 Tynnyri1.Image = Barrel; 217 218 PhysicsObject este2 = PhysicsObject.CreateStaticObject(50, 450); 219 este2.X = 200; 220 este2.Y = 140; 221 Add(este2); 222 este2.Image = BLOCK; 223 224 225 226 227 } 228 229 void KasittelePallonTormays2(PhysicsObject Pelaaja1, PhysicsObject kohde) 230 { 231 if (kohde.Tag.ToString() == "Magma") 232 { 233 Pelaaja1.Destroy(); 234 MessageDisplay.Add("Kuolit!"); 235 236 } 237 else if (kohde.Tag.ToString() == "ESTE1") 238 { 239 Pelaaja1.Destroy(); 240 MessageDisplay.Add("Kuolit!"); 241 } 242 243 244 245 } 246 void KasittelePallonTormays3(PhysicsObject Pelaaja1, PhysicsObject kohde) 247 { 248 if (kohde.Tag.ToString() == "tynnyri1") 249 { 250 kohde.Destroy(); 251 252 MessageDisplay.Add("Tuhosit Tynnyrin!"); 253 MessageDisplay.Add("Level3"); 254 255 } 140 256 } 141 257 142 258 } 143 259 144 145 146 260 261 262 263 264 -
2012/27/LeeviK/PhysicsBall/PhysicsBall/PhysicsBallContent/PhysicsBallContent.contentproj
r3542 r3581 100 100 </Compile> 101 101 </ItemGroup> 102 <ItemGroup> 103 <Compile Include="tahti.png"> 104 <Name>tahti</Name> 105 <Importer>TextureImporter</Importer> 106 <Processor>TextureProcessor</Processor> 107 </Compile> 108 </ItemGroup> 109 <ItemGroup> 110 <Compile Include="whoosh1.mp3"> 111 <Name>whoosh1</Name> 112 <Importer>Mp3Importer</Importer> 113 <Processor>SongProcessor</Processor> 114 </Compile> 115 </ItemGroup> 116 <ItemGroup> 117 <Compile Include="maali.wav"> 118 <Name>maali</Name> 119 <Importer>WavImporter</Importer> 120 <Processor>SoundEffectProcessor</Processor> 121 </Compile> 122 </ItemGroup> 123 <ItemGroup> 124 <Compile Include="Lava.png"> 125 <Name>Lava</Name> 126 <Importer>TextureImporter</Importer> 127 <Processor>TextureProcessor</Processor> 128 </Compile> 129 </ItemGroup> 130 <ItemGroup> 131 <Compile Include="Este.png"> 132 <Name>Este</Name> 133 <Importer>TextureImporter</Importer> 134 <Processor>TextureProcessor</Processor> 135 </Compile> 136 </ItemGroup> 137 <ItemGroup> 138 <Compile Include="Aloitus1.png"> 139 <Name>Aloitus1</Name> 140 <Importer>TextureImporter</Importer> 141 <Processor>TextureProcessor</Processor> 142 </Compile> 143 </ItemGroup> 102 144 <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 103 145 <!-- 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.