Changeset 1548
- Timestamp:
- 2010-08-03 11:06:11 (13 years ago)
- Location:
- 2010/31/eeveturu/pong
- Files:
-
- 2 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
2010/31/eeveturu/pong/Content/Content.contentproj
r1522 r1548 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>578922f1-1cc2-40e0-8fab-78f26b55f67e</ProjectGuid> … … 34 34 <Reference Include="Microsoft.Xna.Framework.Content.Pipeline.XImporter, Version=3.1.0.0, Culture=neutral, PublicKeyToken=6d5c3888ef60e27d" /> 35 35 </ItemGroup> 36 <ItemGroup> 37 <Compile Include="ping%2520pong%2520ball%2520copy[1].jpg"> 38 <Name>ping%2520pong%2520ball%2520copy[1]</Name> 39 <Importer>TextureImporter</Importer> 40 <Processor>TextureProcessor</Processor> 41 </Compile> 42 </ItemGroup> 36 43 </Project> -
2010/31/eeveturu/pong/Peli.cs
r1522 r1548 12 12 PhysicsObject maila2; 13 13 14 PhysicsObject vasenReuna; 15 PhysicsObject oikeaReuna; 16 14 17 IntMeter pelaajan1Pisteet; 15 18 IntMeter pelaajan2Pisteet; 16 17 19 18 20 protected override void Begin() 19 21 { 20 22 LuoKentta(); 21 LisaaLaskuri();22 23 AsetaOhjaimet(); 24 LisaaLaskurit(); 23 25 AloitaPeli(); 24 26 } … … 28 30 pallo = new PhysicsObject(40.0, 40.0); 29 31 pallo.Shape = Shapes.Circle; 32 pallo.Color = Color.Yellow; 30 33 pallo.X = -200.0; 31 34 pallo.Y = 0.0; 32 35 pallo.Restitution = 1.0; 33 36 Add(pallo); 37 AddCollisionHandler(pallo, KasittelePallonTormays); 34 38 35 39 maila1 = LuoMaila(Level.Left + 20.0, 0.0); 36 40 maila2 = LuoMaila(Level.Right - 20.0, 0.0); 37 41 38 PhysicsObjectvasenReuna = Level.CreateLeftBorder();42 vasenReuna = Level.CreateLeftBorder(); 39 43 vasenReuna.Restitution = 1.0; 40 44 vasenReuna.IsVisible = false; 41 PhysicsObjectoikeaReuna = Level.CreateRightBorder();42 oikeaReuna = 1.0;45 oikeaReuna = Level.CreateRightBorder(); 46 oikeaReuna.Restitution = 1.0; 43 47 oikeaReuna.IsVisible = false; 44 48 PhysicsObject ylaReuna = Level.CreateTopBorder(); 49 ylaReuna.Restitution = 1.0; 50 ylaReuna.IsVisible = false; 51 PhysicsObject alaReuna = Level.CreateBottomBorder(); 52 alaReuna.Restitution = 1.0; 53 alaReuna.IsVisible = false; 45 54 46 47 Level.BackgroundColor = Color.Black; 55 Level.BackgroundColor = Color.Green; 48 56 49 57 Camera.ZoomToLevel(); 50 51 AddCollisionHandler(pallo, KasittelePallonTormays);52 53 58 } 54 59 … … 62 67 Add(maila); 63 68 return maila; 69 } 70 71 void LisaaLaskurit() 72 { 73 pelaajan1Pisteet = LuoPisteLaskuri(Screen.Left + 100.0, Screen.Top - 100.0); 74 pelaajan2Pisteet = LuoPisteLaskuri(Screen.Right - 100.0, Screen.Top - 100.0); 75 } 76 77 IntMeter LuoPisteLaskuri(double x, double y) 78 { 79 IntMeter laskuri = new IntMeter(0); 80 laskuri.MaxValue = 10; 81 Label naytto = new Label(); 82 naytto.BindTo(laskuri); 83 naytto.X = x; 84 naytto.Y = y; 85 naytto.TextColor = Color.White; 86 Add(naytto); 87 return laskuri; 88 } 89 90 void KasittelePallonTormays(PhysicsObject pallo, PhysicsObject kohde) 91 { 92 if (kohde == oikeaReuna) 93 { 94 pelaajan1Pisteet.Value += 1; 95 } 96 else if (kohde == vasenReuna) 97 { 98 pelaajan2Pisteet.Value += 1; 99 } 64 100 } 65 101 … … 84 120 Keyboard.Listen(Key.F1, ButtonState.Pressed, ShowControlHelp, "Näytä ohjeet"); 85 121 Keyboard.Listen(Key.Escape, ButtonState.Pressed, Exit, "Poistu"); 122 123 ControllerOne.Listen(Button.DPadUp, ButtonState.Down, AsetaNopeus, "Liikuta mailaa ylös", maila1, nopeusYlos); 124 ControllerOne.Listen(Button.DPadUp, ButtonState.Released, AsetaNopeus, null, maila1, Vector.Zero); 125 ControllerOne.Listen(Button.DPadDown, ButtonState.Down, AsetaNopeus, "Liikuta mailaa alas", maila1, nopeusAlas); 126 ControllerOne.Listen(Button.DPadDown, ButtonState.Released, AsetaNopeus, null, maila1, Vector.Zero); 127 128 ControllerTwo.Listen(Button.DPadUp, ButtonState.Down, AsetaNopeus, "Liikuta mailaa ylös", maila2, nopeusYlos); 129 ControllerTwo.Listen(Button.DPadUp, ButtonState.Released, AsetaNopeus, null, maila2, Vector.Zero); 130 ControllerTwo.Listen(Button.DPadDown, ButtonState.Down, AsetaNopeus, "Liikuta mailaa alas", maila2, nopeusAlas); 131 ControllerTwo.Listen(Button.DPadDown, ButtonState.Released, AsetaNopeus, null, maila2, Vector.Zero); 132 133 ControllerOne.Listen(Button.Back, ButtonState.Pressed, Exit, "Poistu"); 134 ControllerTwo.Listen(Button.Back, ButtonState.Pressed, Exit, "Poistu"); 86 135 } 87 136 … … 100 149 101 150 maila.Velocity = nopeus; 102 103 151 } 104 void LisaaLaskuri()105 {106 pelaajan1Pisteet = LuoPisteLaskuri(Screen.Left + 100.0, Screen.Top - 100.0);107 pelaajan2Pisteet = LuoPisteLaskuri(Screen.Right - 100.0, Screen.Top - 100.0);108 }109 110 IntMeter LuoPisteLaskuri( double x, double y )111 {112 IntMeter laskuri = new IntMeter(0);113 laskuri.MaxValue = 10;114 Label naytto = new Label();115 naytto.BindTo(laskuri);116 naytto.X = x;117 naytto.Y = y;118 naytto.TextColor = Color.White;119 Add(naytto);120 return laskuri;121 122 }123 void KasittelePallonTormays(PhysicsObject pallo, PhysicsObject kohde)124 {125 }126 127 152 } 128 129
Note: See TracChangeset
for help on using the changeset viewer.