- Timestamp:
- 2010-07-28 14:52:38 (13 years ago)
- Location:
- 2010/30/alkivima/Car Duels
- Files:
-
- 2 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
2010/30/alkivima/Car Duels/Content/Content.contentproj
r1330 r1371 1 <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">1 <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5"> 2 2 <PropertyGroup> 3 3 <ProjectGuid>3293a2c2-5ed0-425a-be83-3d20380c3edd</ProjectGuid> … … 28 28 <Reference Include="Microsoft.Xna.Framework.Content.Pipeline.XImporter, Version=3.1.0.0, Culture=neutral, PublicKeyToken=6d5c3888ef60e27d" /> 29 29 </ItemGroup> 30 <ItemGroup> 31 <Compile Include="rajahdysEsimerkki.png"> 32 <Name>rajahdysEsimerkki</Name> 33 <Importer>TextureImporter</Importer> 34 <Processor>TextureProcessor</Processor> 35 </Compile> 36 </ItemGroup> 37 <ItemGroup> 38 <Compile Include="liekkiEsimerkki.png"> 39 <Name>liekkiEsimerkki</Name> 40 <Importer>TextureImporter</Importer> 41 <Processor>TextureProcessor</Processor> 42 </Compile> 43 </ItemGroup> 30 44 <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 31 45 <!-- To modify your build process, add your task inside one of the targets below and uncomment it. -
2010/30/alkivima/Car Duels/Peli.cs
r1354 r1371 9 9 PhysicsObject vasenReuna; 10 10 PhysicsObject oikeaReuna; 11 DoubleMeter voimaMittari; 12 DoubleMeter voimaMittari2; 13 Automobile auto1; 14 Automobile auto2; 15 IntMeter pelaajan1Pisteet; 16 IntMeter pelaajan2Pisteet; 11 17 12 18 protected override void Begin() 13 19 { 14 20 KineticFriction = 0.5; // Asetetaan kitka 15 16 Automobile auto = new Automobile(60, 50); 17 auto.Mass = 100.0; 18 auto.Color = new Color(1, 1, 1); 19 auto.X = -200; 20 auto.Y = 0; 21 auto.LinearDamping = 0.99; 22 auto.AngularDamping = 1.0; 23 Add(auto); 24 25 Automobile auto2 = new Automobile(60, 50); 21 22 23 auto1 = new Automobile(60, 50); 24 auto1.Mass = 100.0; 25 auto1.Color = new Color(1, 1, 1); 26 auto1.X = -200; 27 auto1.Y = 0; 28 auto1.LinearDamping = 0.95; 29 auto1.AngularDamping = 0.1; 30 auto1.CanRotate = false; 31 auto1.Acceleration = 1500; 32 Add(auto1); 33 34 auto2 = new Automobile(60, 50); 26 35 auto2.Mass = 100.0; 27 36 auto2.Color = new Color(255, 255, 255); 28 37 auto2.X = 200; 29 38 auto2.Y = 0; 30 auto2.LinearDamping = 0.99; 31 auto2.AngularDamping = 1.0; 32 auto2.Angle = Angle.Degrees (180.0); 39 auto2.LinearDamping = 0.95; 40 auto2.AngularDamping = 0.1; 41 auto2.Angle = Angle.Degrees(180.0); 42 auto2.CanRotate = false; 43 auto2.Acceleration = 1500; 33 44 Add(auto2); 34 45 35 46 Keyboard.Listen(Key.F1, ButtonState.Pressed, ShowControlHelp, "Näytä ohjeet"); 36 47 Keyboard.Listen(Key.Escape, ButtonState.Pressed, Exit, "Poistu pelistä"); 37 Keyboard.Listen(Key. Up, ButtonState.Down, kiihdyta, "Kiihdytä", auto);38 Keyboard.Listen(Key. Down, ButtonState.Down, jarruta, "Jarruta", auto);39 Keyboard.Listen(Key. Left, ButtonState.Down, kaanny, "Käänny vasemmalle", auto, 2.0);40 Keyboard.Listen(Key. Right, ButtonState.Down, kaanny, "Käänny oikealle", auto, -2.0);48 Keyboard.Listen(Key.W, ButtonState.Down, kiihdyta, "Kiihdytä", auto1); 49 Keyboard.Listen(Key.S, ButtonState.Down, jarruta, "Jarruta", auto1); 50 Keyboard.Listen(Key.A, ButtonState.Down, kaanny, "Käänny vasemmalle", auto1, 2.0); 51 Keyboard.Listen(Key.D, ButtonState.Down, kaanny, "Käänny oikealle", auto1, -2.0); 41 52 42 53 Keyboard.Listen(Key.F1, ButtonState.Pressed, ShowControlHelp, "Näytä ohjeet"); 43 54 Keyboard.Listen(Key.Escape, ButtonState.Pressed, Exit, "Poistu pelistä"); 44 Keyboard.Listen(Key.W, ButtonState.Down, kiihdyta, "Kiihdytä", auto2); 45 Keyboard.Listen(Key.S, ButtonState.Down, jarruta, "Jarruta", auto2); 46 Keyboard.Listen(Key.A, ButtonState.Down, kaanny, "Käänny vasemmalle", auto2, 2.0); 47 Keyboard.Listen(Key.D, ButtonState.Down, kaanny, "Käänny oikealle", auto2, -2.0); 55 Keyboard.Listen(Key.Up, ButtonState.Down, kiihdyta, "Kiihdytä", auto2); 56 Keyboard.Listen(Key.Down, ButtonState.Down, jarruta, "Jarruta", auto2); 57 Keyboard.Listen(Key.Left, ButtonState.Down, kaanny, "Käänny vasemmalle", auto2, 2.0); 58 Keyboard.Listen(Key.Right, ButtonState.Down, kaanny, "Käänny oikealle", auto2, -2.0); 59 60 AddCollisionHandler(auto1, KasitteleAuto1Tormays); 61 AddCollisionHandler(auto2, KasitteleAuto2Tormays); 48 62 49 63 ShowControlHelp(); 50 64 51 65 Kentta(); 52 } 53 66 67 Pelaaja1HP(); 68 Pelaaja2HP(); 69 70 LisaaLaskurit(); 71 } 54 72 void kiihdyta(Automobile auto) 55 73 { … … 75 93 pylvas1.Restitution = 0.2; 76 94 pylvas1.Tag = "pylvas"; 95 pylvas1.Color = Color.DarkGray; 77 96 Add(pylvas1); 78 97 … … 83 102 pylvas2.Restitution = 0.2; 84 103 pylvas2.Tag = "pylvas"; 104 pylvas2.Color = Color.DarkGray; 85 105 Add(pylvas2); 86 106 … … 91 111 pylvas3.Restitution = 0.2; 92 112 pylvas3.Tag = "pylvas"; 113 pylvas3.Color = Color.DarkGray; 93 114 Add(pylvas3); 94 115 … … 99 120 pylvas4.Restitution = 0.2; 100 121 pylvas4.Tag = "pylvas"; 122 pylvas4.Color = Color.DarkGray; 101 123 Add(pylvas4); 102 124 … … 110 132 Reuna.Color = Color.Black; 111 133 Add(Reuna); 112 134 113 135 GameObject Boostipaikka = new GameObject(60.0, 60.0); 114 136 Boostipaikka.Shape = Shapes.Circle; … … 129 151 alaReuna.Restitution = 0.3; 130 152 alaReuna.IsVisible = true; 131 153 132 154 Level.BackgroundColor = Color.ForestGreen; 133 155 … … 135 157 Camera.Y = 0.0; 136 158 Camera.Zoom(1.2); 159 } 160 void Pelaaja1Tuhoutuu() 161 { 162 int pMaxMaara = 210; 163 ExplosionSystem rajahdys = new ExplosionSystem(LoadImage("liekkiEsimerkki"), pMaxMaara); 164 ExplosionSystem rajahdys2 = new ExplosionSystem(LoadImage("rajahdysEsimerkki"), pMaxMaara); 165 Add(rajahdys); 166 Add(rajahdys2); 167 168 double x = auto1.X; 169 double y = auto1.Y; 170 int pMaara = 200; 171 int pMaara2 = 10; 172 rajahdys.AddEffect(x, y, pMaara); 173 rajahdys2.AddEffect(x, y, pMaara2); 174 175 pelaajan2Pisteet.Value += 1; 176 177 UusiEra(); 178 } 179 void Pelaaja2Tuhoutuu() 180 { 181 int pMaxMaara = 210; 182 ExplosionSystem rajahdys = new ExplosionSystem(LoadImage("liekkiEsimerkki"), pMaxMaara); 183 ExplosionSystem rajahdys2 = new ExplosionSystem(LoadImage("rajahdysEsimerkki"), pMaxMaara); 184 Add(rajahdys); 185 Add(rajahdys2); 186 187 double x = auto2.X; 188 double y = auto2.Y; 189 int pMaara = 200; 190 int pMaara2 = 10; 191 rajahdys.AddEffect(x, y, pMaara); 192 rajahdys2.AddEffect(x, y, pMaara2); 193 194 pelaajan1Pisteet.Value += 1; 137 195 138 } 139 void PylvaidenVarit() 140 { 196 UusiEra(); 197 } 198 void Pelaaja1HP() 199 { 200 voimaMittari = new DoubleMeter(10); 201 voimaMittari.MaxValue = 10; 202 BarGauge voimaPalkki = new BarGauge(10, 150); 203 voimaPalkki.BindTo(voimaMittari); 204 voimaPalkki.X = (0.95 * Screen.LeftSafe); 205 voimaPalkki.Y = (0.05 * Screen.Height); 206 Add(voimaPalkki); 207 } 208 void Pelaaja2HP() 209 { 210 voimaMittari2 = new DoubleMeter(10); 211 voimaMittari2.MaxValue = 10; 212 BarGauge voimaPalkki2 = new BarGauge(10, 150); 213 voimaPalkki2.BindTo(voimaMittari2); 214 voimaPalkki2.X = (0.95 * Screen.RightSafe); 215 voimaPalkki2.Y = (0.05 * Screen.Height); 216 Add(voimaPalkki2); 217 } 218 void KasitteleAuto1Tormays(PhysicsObject auto1, PhysicsObject kohde) 219 { 141 220 142 } 143 221 if (auto1.Velocity.Magnitude > 200) 222 { 223 voimaMittari.Value++; 224 voimaMittari.Value -= 1; 225 voimaMittari.Value = voimaMittari.Value - 1; 226 } 227 if (voimaMittari.Value == 0) 228 { 229 Pelaaja1Tuhoutuu(); 230 } 231 } 232 void KasitteleAuto2Tormays(PhysicsObject auto2, PhysicsObject kohde) 233 { 234 235 if (auto2.Velocity.Magnitude > 200) 236 { 237 voimaMittari2.Value++; 238 voimaMittari2.Value -= 1; 239 voimaMittari2.Value = voimaMittari2.Value - 1; 240 } 241 if (voimaMittari2.Value == 0) 242 { 243 Pelaaja2Tuhoutuu(); 244 } 245 } 246 void LisaaLaskurit() 247 { 248 pelaajan1Pisteet = LuoPisteLaskuri( - 250.0, 250.0); 249 pelaajan2Pisteet = LuoPisteLaskuri( 230.0, 250.0); 250 } 251 IntMeter LuoPisteLaskuri(double x, double y) 252 { 253 IntMeter laskuri = new IntMeter(0); 254 laskuri.MaxValue = 5; 255 Label naytto = new Label(); 256 naytto.BindTo(laskuri); 257 naytto.X = x; 258 naytto.Y = y; 259 naytto.TextColor = Color.White; 260 Add(naytto); 261 return laskuri; 262 } 263 void UusiEra() 264 { 265 auto1.Destroy(); 266 auto2.Destroy(); 267 voimaMittari.Value = 10; 268 voimaMittari2.Value = 10; 269 270 Add(auto1); 271 Add(auto2); 272 } 144 273 }
Note: See TracChangeset
for help on using the changeset viewer.