- Timestamp:
- 2011-06-17 12:23:29 (12 years ago)
- Location:
- 2011/24/PauliN
- Files:
-
- 5 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
2011/24/PauliN/Jalkapallopeli/Jalkapallopeli/Jalkapallopeli/Jalkapallopeli.csproj
r2048 r2097 121 121 <Content Include="ground.png" /> 122 122 <Content Include="imagesCA9N94Z4.jpg" /> 123 <Content Include="pelaaja1.png" /> 123 124 <Content Include="pelaaja1oik.png" /> 124 125 <Content Include="pelaaja2.png" /> -
2011/24/PauliN/Jalkapallopeli/Jalkapallopeli/Jalkapallopeli/Peli.cs
r2048 r2097 15 15 Image pelaaja2vasKuva = LoadImage("pelaaja2vas"); 16 16 Image tausta = LoadImage("tausta"); 17 Image maali1Kuva = LoadImage("maali1"); 18 Image maali2Kuva = LoadImage("maali2"); 17 19 18 20 PhysicsObject pallo; … … 22 24 PhysicsObject pelaaja1; 23 25 PhysicsObject pelaaja2; 26 PhysicsObject raja1; 27 PhysicsObject raja2; 28 29 24 30 25 31 IntMeter Pelaajan1Pisteet; … … 27 33 28 34 29 30 35 Vector NopeusVasemmalle = new Vector(-150, 0); 31 36 Vector NopeusOikealle = new Vector(150, 0); 32 Vector HyppyVoima = new Vector(0, 400); 37 Vector HyppyVoima = new Vector(0, 400); 33 38 34 39 public override void Begin() … … 43 48 void LuoKentta() 44 49 { 50 PhysicsObject raja1 = PhysicsObject.CreateStaticObject(10, 1000); 51 raja1.X = Level.Left + 50; 52 raja1.Y = 0; 53 raja1.IsVisible = false; 54 Add(raja1); 55 56 PhysicsObject raja2 = PhysicsObject.CreateStaticObject(10, 1000); 57 raja2.X = Level.Right - 50; 58 raja2.Y = 0; 59 raja2.IsVisible = false; 60 Add(raja2); 61 45 62 pallo = new PhysicsObject(45, 45); 46 63 pallo.Image = pallonKuva; 47 64 pallo.X = 0; 48 65 pallo.Y = 300; 49 pallo.Mass = 1; 66 pallo.Mass = 0.2; 67 pallo.Restitution = 1; 50 68 Add(pallo); 69 70 71 51 72 52 73 Level.Background.Image = tausta; … … 61 82 62 83 63 maali1 = PhysicsObject.CreateStaticObject( 20, 120);64 maali1. Shape = Shape.Rectangle;84 maali1 = PhysicsObject.CreateStaticObject(100, 180); 85 maali1.Image = maali1Kuva; 65 86 maali1.X = Level.Left + 20; 66 87 maali1.Y = Level.Bottom + 75; 67 88 Add(maali1); 68 89 69 maali2 = PhysicsObject.CreateStaticObject( 20, 120);70 maali2. Shape = Shape.Rectangle;90 maali2 = PhysicsObject.CreateStaticObject(100, 180); 91 maali2.Image = maali2Kuva; 71 92 maali2.X = Level.Right - 20; 72 93 maali2.Y = Level.Bottom + 75; … … 79 100 80 101 Camera.ZoomToLevel(); 81 Camera.Follow(pallo);102 //Camera.Follow(pallo); 82 103 83 104 pelaaja1 = LuoPelaaja(Level.Left + 200, 0); … … 96 117 void AloitaPeli() 97 118 { 98 Gravity = new Vector(0.0, - 400);119 Gravity = new Vector(0.0, -600); 99 120 } 100 121 … … 153 174 154 175 Keyboard.Listen(Key.Up, ButtonState.Pressed, AsetaHyppy, "Pelaaja2: Hyppaa", pelaaja2, HyppyVoima); 155 156 157 158 159 160 176 177 Keyboard.Listen(Key.LeftControl, ButtonState.Released, Potkaise, "Pelaaja1: Potkaise", pelaaja1); 178 Keyboard.Listen(Key.RightControl, ButtonState.Released, Potkaise, "Pelaaja2: Potkaise", pelaaja2); 179 161 180 162 181 } … … 164 183 void AsetaNopeus(PhysicsObject pelaaja, Vector nopeus) 165 184 { 166 pelaaja.Velocity = nopeus ;185 pelaaja.Velocity = nopeus + new Vector(0, pelaaja.Velocity.Y); 167 186 if (nopeus.X > 0) 168 187 { … … 188 207 void AsetaHyppy(PhysicsObject pelaaja, Vector voima) 189 208 { 190 pelaaja.Hit (voima); 209 210 211 if (pelaaja.Y < -350) 212 { 213 pelaaja.Hit (voima); 214 } 191 215 192 216 } … … 201 225 pelaaja1.X = -200; 202 226 pelaaja2.X = 200; 227 pallo.Stop(); 203 228 } 204 229 else if (kohde == maali1) … … 209 234 pelaaja2.X = 200; 210 235 Pelaajan2Pisteet.Value += 1; 211 } 212 213 236 pallo.Stop(); 237 } 238 239 240 241 242 } 243 void Potkaise(PhysicsObject pelaaja) 244 { 245 246 247 Vector suunta = (pallo.Position - pelaaja.Position); 248 if (suunta.Magnitude < 60) 249 { 250 Vector potku = suunta + new Vector(0, 80); 251 if ((pelaaja.Image == pelaaja1oikKuva) || (pelaaja.Image == pelaaja2Kuva)) 252 { 253 if (pelaaja.X < pallo.X) 254 { 255 pallo.Hit(potku * 0.8); 256 } 257 } 258 else 259 { 260 if (pelaaja.X > pallo.X) 261 { 262 pallo.Hit(potku * 0.8); 263 } 264 } 265 266 267 } 268 214 269 215 270 -
2011/24/PauliN/Jalkapallopeli/Jalkapallopeli/JalkapallopeliContent/JalkapallopeliContent.contentproj
r2048 r2097 57 57 </ItemGroup> 58 58 <ItemGroup> 59 <Compile Include="pelaaja1.png">60 <Name>pelaaja1</Name>61 <Importer>TextureImporter</Importer>62 <Processor>TextureProcessor</Processor>63 </Compile>64 </ItemGroup>65 <ItemGroup>66 <Compile Include="pelaaja1oik.png">67 <Name>pelaaja1oik</Name>68 <Importer>TextureImporter</Importer>69 <Processor>TextureProcessor</Processor>70 </Compile>71 </ItemGroup>72 <ItemGroup>73 59 <Compile Include="pelaaja2.png"> 74 60 <Name>pelaaja2</Name> … … 91 77 </Compile> 92 78 </ItemGroup> 79 <ItemGroup> 80 <Compile Include="pelaaja1.png"> 81 <Name>pelaaja1</Name> 82 <Importer>TextureImporter</Importer> 83 <Processor>TextureProcessor</Processor> 84 </Compile> 85 </ItemGroup> 86 <ItemGroup> 87 <Compile Include="pelaaja1oik.png"> 88 <Name>pelaaja1oik</Name> 89 <Importer>TextureImporter</Importer> 90 <Processor>TextureProcessor</Processor> 91 </Compile> 92 </ItemGroup> 93 <ItemGroup> 94 <Compile Include="maali1.png"> 95 <Name>maali1</Name> 96 <Importer>TextureImporter</Importer> 97 <Processor>TextureProcessor</Processor> 98 </Compile> 99 </ItemGroup> 100 <ItemGroup> 101 <Compile Include="maali2.png"> 102 <Name>maali2</Name> 103 <Importer>TextureImporter</Importer> 104 <Processor>TextureProcessor</Processor> 105 </Compile> 106 </ItemGroup> 93 107 <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 94 108 <!-- 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.