- Timestamp:
- 2011-06-16 15:01:20 (12 years ago)
- Location:
- 2011/24/PauliN
- Files:
-
- 21 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
2011/24/PauliN/Jalkapallopeli/Jalkapallopeli/Jalkapallopeli/Jalkapallopeli.csproj
r1991 r2048 119 119 <Content Include="Game.ico" /> 120 120 <Content Include="GameThumbnail.png" /> 121 <Content Include="ground.png" /> 121 122 <Content Include="imagesCA9N94Z4.jpg" /> 123 <Content Include="pelaaja1oik.png" /> 124 <Content Include="pelaaja2.png" /> 125 <Content Include="pelaaja2vas.png" /> 126 <Content Include="tausta.png" /> 122 127 </ItemGroup> 123 128 <ItemGroup> -
2011/24/PauliN/Jalkapallopeli/Jalkapallopeli/Jalkapallopeli/Ohjelma.cs
r1991 r2048 11 11 game.IsFullScreen = true; 12 12 #endif 13 game.Run(); 14 } 13 game.Run(); } 15 14 } 16 15 #endif -
2011/24/PauliN/Jalkapallopeli/Jalkapallopeli/Jalkapallopeli/Peli.cs
r2022 r2048 9 9 public class Peli : PhysicsGame 10 10 { 11 Image pallonKuva = LoadImage("football"); 11 Image pallonKuva = LoadImage("football"); 12 Image pelaaja1Kuva = LoadImage("pelaaja1"); 13 Image pelaaja1oikKuva = LoadImage("pelaaja1oik"); 14 Image pelaaja2Kuva = LoadImage("pelaaja2"); 15 Image pelaaja2vasKuva = LoadImage("pelaaja2vas"); 16 Image tausta = LoadImage("tausta"); 17 12 18 PhysicsObject pallo; 13 19 PhysicsObject nurmi; 20 PhysicsObject maali1; 21 PhysicsObject maali2; 14 22 PhysicsObject pelaaja1; 15 23 PhysicsObject pelaaja2; 16 24 17 Vector NopeusVasemmalle = new Vector(-200, 0); 18 Vector NopeusOikealle = new Vector(200, 0); 19 25 IntMeter Pelaajan1Pisteet; 26 IntMeter Pelaajan2Pisteet; 27 28 29 30 Vector NopeusVasemmalle = new Vector(-150, 0); 31 Vector NopeusOikealle = new Vector(150, 0); 20 32 Vector HyppyVoima = new Vector(0, 400); 21 22 23 24 33 25 34 public override void Begin() 26 35 { 27 36 LuoKentta(); 28 37 AloitaPeli(); 29 AsetaOhjaimet(); 38 AsetaOhjaimet(); 39 LisaaLaskurit(); 40 30 41 31 32 42 } 33 43 void LuoKentta() 34 44 { 35 pallo = new PhysicsObject( 60, 60);45 pallo = new PhysicsObject(45, 45); 36 46 pallo.Image = pallonKuva; 37 47 pallo.X = 0; 38 48 pallo.Y = 300; 49 pallo.Mass = 1; 39 50 Add(pallo); 40 51 41 Level.CreateLeftBorder(1, false); 42 Level.CreateBottomBorder(); 52 Level.Background.Image = tausta; 53 Level.Background.FitToLevel(); 54 55 PhysicsObject nurmi = PhysicsObject.CreateStaticObject(1000, 50); 56 nurmi.Shape = Shape.Rectangle; 57 nurmi.X = 0; 58 nurmi.Y = Level.Bottom; 59 nurmi.Color = Color.Green; 60 Add(nurmi); 61 62 63 maali1 = PhysicsObject.CreateStaticObject(20, 120); 64 maali1.Shape = Shape.Rectangle; 65 maali1.X = Level.Left + 20; 66 maali1.Y = Level.Bottom + 75; 67 Add(maali1); 68 69 maali2 = PhysicsObject.CreateStaticObject(20, 120); 70 maali2.Shape = Shape.Rectangle; 71 maali2.X = Level.Right - 20; 72 maali2.Y = Level.Bottom + 75; 73 Add(maali2); 74 75 Level.CreateLeftBorder(1, false); 43 76 Level.CreateTopBorder(1, false); 44 77 Level.CreateRightBorder(1, false); 78 Level.CreateBottomBorder(1, false); 45 79 46 80 Camera.ZoomToLevel(); 81 Camera.Follow(pallo); 47 82 48 83 pelaaja1 = LuoPelaaja(Level.Left + 200, 0); 49 84 pelaaja2 = LuoPelaaja(Level.Right - 200, 0); 50 85 51 52 86 pelaaja1.Image = pelaaja1oikKuva; 87 pelaaja2.Image = pelaaja2vasKuva; 88 89 AddCollisionHandler(pallo, KasittelePallonTormays); 90 91 pelaaja1.CanRotate = false; 92 pelaaja2.CanRotate = false; 93 53 94 54 95 } … … 60 101 PhysicsObject LuoPelaaja(double x, double y) 61 102 { 62 PhysicsObject pelaaja = new PhysicsObject( 80, 80);63 pelaaja.Shape = Shape. Star;103 PhysicsObject pelaaja = new PhysicsObject(40, 40); 104 pelaaja.Shape = Shape.Circle; 64 105 pelaaja.X = x; 65 pelaaja.Y = y; 106 pelaaja.Y = y; 66 107 Add(pelaaja); 67 108 68 109 return pelaaja; 69 110 } 111 112 void LisaaLaskurit() 113 { 114 Pelaajan1Pisteet = LuoPisteLaskuri ( Screen.Left + 50, Screen.Top - 50); 115 Pelaajan2Pisteet = LuoPisteLaskuri ( Screen.Right - 50, Screen.Top - 50); 116 } 117 118 IntMeter LuoPisteLaskuri(double x, double y) 119 { 120 IntMeter laskuri = new IntMeter(0); 121 laskuri.MaxValue = 10; 122 Label naytto = new Label(); 123 naytto.BindTo (laskuri); 124 naytto.X = x; 125 naytto.Y = y; 126 naytto.TextColor = Color.White; 127 naytto.BorderColor = Color.LightBlue; 128 naytto.Color = Color.LightBlue; 129 Add(naytto); 130 131 return laskuri; 132 133 } 134 135 70 136 void AsetaOhjaimet() 71 137 { … … 84 150 Keyboard.Listen(Key.Right, ButtonState.Released, AsetaNopeus, null, pelaaja2, NopeusOikealle); 85 151 152 Keyboard.Listen(Key.W, ButtonState.Pressed, AsetaHyppy, "Pelaaja1: Hyppaa", pelaaja1, HyppyVoima); 153 86 154 Keyboard.Listen(Key.Up, ButtonState.Pressed, AsetaHyppy, "Pelaaja2: Hyppaa", pelaaja2, HyppyVoima); 87 155 … … 95 163 96 164 void AsetaNopeus(PhysicsObject pelaaja, Vector nopeus) 97 { 165 { 98 166 pelaaja.Velocity = nopeus; 167 if (nopeus.X > 0) 168 { 169 if (pelaaja == pelaaja1) 170 171 pelaaja1.Image = pelaaja1oikKuva; 172 if (pelaaja == pelaaja2) 173 174 pelaaja2.Image = pelaaja2Kuva; 175 } 176 if (nopeus.X < 0) 177 { 178 if (pelaaja == pelaaja1) 179 pelaaja1.Image = pelaaja1Kuva; 180 181 if (pelaaja == pelaaja2) 182 pelaaja2.Image = pelaaja2vasKuva; 183 } 184 185 99 186 } 100 187 … … 105 192 } 106 193 194 void KasittelePallonTormays(PhysicsObject pallo, PhysicsObject kohde) 195 { 196 if(kohde == maali2) 197 { 198 Pelaajan1Pisteet.Value += 1; 199 pallo.X = 0; 200 pallo.Y = 300; 201 pelaaja1.X = -200; 202 pelaaja2.X = 200; 203 } 204 else if (kohde == maali1) 205 { 206 pallo.X = 0; 207 pallo.Y = 300; 208 pelaaja1.X = -200; 209 pelaaja2.X = 200; 210 Pelaajan2Pisteet.Value += 1; 211 } 212 213 214 215 216 } 217 107 218 108 219 } -
2011/24/PauliN/Jalkapallopeli/Jalkapallopeli/JalkapallopeliContent/JalkapallopeliContent.contentproj
r1991 r2048 49 49 </Compile> 50 50 </ItemGroup> 51 <ItemGroup> 52 <Compile Include="ground.png"> 53 <Name>ground</Name> 54 <Importer>TextureImporter</Importer> 55 <Processor>TextureProcessor</Processor> 56 </Compile> 57 </ItemGroup> 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 <Compile Include="pelaaja2.png"> 74 <Name>pelaaja2</Name> 75 <Importer>TextureImporter</Importer> 76 <Processor>TextureProcessor</Processor> 77 </Compile> 78 </ItemGroup> 79 <ItemGroup> 80 <Compile Include="pelaaja2vas.png"> 81 <Name>pelaaja2vas</Name> 82 <Importer>TextureImporter</Importer> 83 <Processor>TextureProcessor</Processor> 84 </Compile> 85 </ItemGroup> 86 <ItemGroup> 87 <Compile Include="tausta.png"> 88 <Name>tausta</Name> 89 <Importer>TextureImporter</Importer> 90 <Processor>TextureProcessor</Processor> 91 </Compile> 92 </ItemGroup> 51 93 <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 52 94 <!-- 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.