- Timestamp:
- 2013-06-11 11:01:15 (10 years ago)
- Location:
- 2013/24/NicoL/Pong
- Files:
-
- 2 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
2013/24/NicoL/Pong/Pong/Pong/Pong.cs
r4055 r4063 9 9 public class Pong : PhysicsGame 10 10 { 11 Vector nopeusYlos = new Vector(0, 200); 12 Vector nopeusAlas = new Vector(0, -200); 11 Image mailu1 = LoadImage("Maila1"); 12 Image mailu2=LoadImage("Maila2"); 13 Image pallu = LoadImage("Untitled"); 14 15 Vector nopeusYlos = new Vector(0, 400); 16 Vector nopeusAlas = new Vector(0, -400); 13 17 14 18 PhysicsObject pallo; 19 15 20 IntMeter pelaajan1Pisteet; 16 21 IntMeter pelaajan2Pisteet; … … 18 23 PhysicsObject maila1; 19 24 PhysicsObject maila2; 25 26 PhysicsObject vasenReuna; 27 PhysicsObject oikeaReuna; 20 28 21 29 … … 41 49 pallo.Y = 0.0; 42 50 pallo.Restitution = 1.0; 51 pallo.Image = pallu; 52 43 53 AddCollisionHandler(pallo, KasittelePallonTormays); 44 54 45 55 maila1 = LuoMaila(Level.Left + 20.0, 0.0); 56 maila1.Image = mailu1; 57 46 58 maila2 = LuoMaila(Level.Right - 20.0, 0.0); 59 maila2.Image = mailu2; 47 60 48 PhysicsObjectvasenReuna = Level.CreateLeftBorder();61 vasenReuna = Level.CreateLeftBorder(); 49 62 vasenReuna.Restitution = 1.0; 50 63 vasenReuna.IsVisible = false; 51 64 52 PhysicsObjectoikeaReuna = Level.CreateRightBorder();65 oikeaReuna = Level.CreateRightBorder(); 53 66 oikeaReuna.Restitution = 1.0; 54 67 oikeaReuna.IsVisible = false; … … 70 83 void AloitaPeli() 71 84 { 72 Vector impulssi = new Vector( 300.0, 0.0);85 Vector impulssi = new Vector(500.0, 0.0); 73 86 pallo.Hit(impulssi); 74 87 } … … 116 129 maila.Velocity = nopeus; 117 130 } 118 void LisaaLaskurit( double x, double y)131 void LisaaLaskurit() 119 132 { 120 // ... 133 pelaajan1Pisteet = LuoPisteLaskuri(Screen.Left + 100.0, Screen.Top - 100.0); 134 pelaajan2Pisteet = LuoPisteLaskuri(Screen.Right - 100.0, Screen.Top - 100.0); 121 135 } 122 IntMeter LuoPisteLaskuri( )136 IntMeter LuoPisteLaskuri(Double x, Double y) 123 137 { 124 138 IntMeter laskuri = new IntMeter(0); 125 139 laskuri.MaxValue = 10; 140 126 141 Label naytto = new Label(); 127 142 naytto.BindTo(laskuri); … … 137 152 void KasittelePallonTormays(PhysicsObject pallo, PhysicsObject kohde) 138 153 { 139 154 if (kohde == oikeaReuna) 155 { 156 pelaajan1Pisteet.Value += 1; 157 } 158 else if (kohde == vasenReuna) 159 { 160 pelaajan2Pisteet.Value += 1; 161 } 140 162 } 141 163 } -
2013/24/NicoL/Pong/Pong/PongContent/PongContent.contentproj
r4055 r4063 45 45 <Reference Include="AnimationExtension" /> 46 46 </ItemGroup> 47 <ItemGroup> 48 <Compile Include="Maila1.png"> 49 <Name>Maila1</Name> 50 <Importer>TextureImporter</Importer> 51 <Processor>TextureProcessor</Processor> 52 </Compile> 53 </ItemGroup> 54 <ItemGroup> 55 <Compile Include="Maila2.png"> 56 <Name>Maila2</Name> 57 <Importer>TextureImporter</Importer> 58 <Processor>TextureProcessor</Processor> 59 </Compile> 60 </ItemGroup> 61 <ItemGroup> 62 <Compile Include="Untitled.png"> 63 <Name>Untitled</Name> 64 <Importer>TextureImporter</Importer> 65 <Processor>TextureProcessor</Processor> 66 </Compile> 67 </ItemGroup> 47 68 <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 48 69 <!-- 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.