Changeset 2497
- Timestamp:
- 2011-08-02 14:57:09 (11 years ago)
- Location:
- 2011/31/JesseP
- Files:
-
- 13 added
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
2011/31/JesseP/Pong/Pong/Pong/Peli.cs
r2476 r2497 8 8 9 9 public class Peli : PhysicsGame 10 { Vector nopeusYlos = new Vector (0, 200 ); 11 Vector nopeusAlas = new Vector (0, 200 ); 10 { 11 12 Vector nopeusYlos = new Vector(0, 200); 13 Vector nopeusAlas = new Vector(0, -200); 12 14 PhysicsObject pallo; 15 13 16 PhysicsObject maila1; 14 17 PhysicsObject maila2; 18 IntMeter pelaajan1Pisteet; 19 IntMeter pelaajan2Pisteet; 20 PhysicsObject vasenReuna; 21 PhysicsObject oikeaReuna; 15 22 public override void Begin() 16 23 { 24 17 25 LuoKentta(); 18 26 asetaohjaimet(); 27 Lisaalaskurit(); 19 28 aloitapeli(); 20 29 } … … 25 34 { 26 35 pallo = new PhysicsObject(40.0, 40.0); 27 pallo.Shape = Shape.Circle;36 //pallo.Shape = Shape.Circle; 28 37 pallo.X = -200.0; 29 38 pallo.Y = 0.0; 30 39 Add(pallo); 31 40 32 Level.CreateBorders(1.0, false); 33 pallo.Restitution = 1.0; 41 vasenReuna = Level.CreateLeftBorder(); 42 vasenReuna.Restitution = 1.0; 43 vasenReuna.IsVisible = false; 44 oikeaReuna = Level.CreateRightBorder(); 45 oikeaReuna.Restitution = 1.0; 46 oikeaReuna.IsVisible = false; 47 PhysicsObject alaReuna = Level.CreateBottomBorder(); 48 alaReuna.Restitution = 1.0; 49 alaReuna.IsVisible = false; 50 PhysicsObject yläReuna = Level.CreateTopBorder(); 51 yläReuna.Restitution = 1.0; 52 yläReuna.IsVisible = false; 53 pallo.Restitution = 50; 34 54 Level.BackgroundColor = Color.Black; 35 55 Camera.ZoomToLevel(); 36 37 maila1 = LuoMaila(Level.Left + 20.0, 0.0 ); 38 maila2 = LuoMaila(Level.Right - 20.0, 0.0 ); 56 AddCollisionHandler(pallo, KasittelePallonTormays); 57 maila1 = LuoMaila(Level.Left + 20.0, 0.0); 58 maila2 = LuoMaila(Level.Right - 20.0, 0.0); 59 MessageDisplay.TextColor = Color.White; 39 60 } 40 61 … … 45 66 Vector impulssi = new Vector(500.0, 0.0); 46 67 pallo.Hit(impulssi); 47 48 } 49 PhysicsObject LuoMaila (double x, double y)68 69 } 70 PhysicsObject LuoMaila(double x, double y) 50 71 { 51 PhysicsObject maila = PhysicsObject.CreateStaticObject(20.0, 100.0);72 PhysicsObject maila = PhysicsObject.CreateStaticObject(20.0, 100.0); 52 73 maila.Shape = Shape.Rectangle; 53 74 maila.X = x; … … 60 81 void asetaohjaimet() 61 82 { 62 Keyboard.Listen(Key.Escape, ButtonState.Pressed, Exit, "poistu"); 63 Keyboard.Listen(Key.A, ButtonState.Down,AsetaNopeus LiikutaMailaaYlos, "pelaaja 1: 64 Keyboard.Listen(Key.A, ButtonState.Released, PysaytaMaila, null ); 65 83 Keyboard.Listen(Key.A, ButtonState.Down, AsetaNopeus, "pelaaja 1: Liikuta mailaa ylös", maila1, nopeusYlos); 84 Keyboard.Listen(Key.A, ButtonState.Released, AsetaNopeus, null, maila1, Vector.Zero); 85 Keyboard.Listen(Key.Escape, ButtonState.Pressed, Exit, "poistu"); 86 Keyboard.Listen(Key.Z, ButtonState.Down, AsetaNopeus, "Pelaaja 1: Liikuta mailaa alas", maila1, nopeusAlas); 87 Keyboard.Listen(Key.Z, ButtonState.Released, AsetaNopeus, null, maila1, Vector.Zero); 88 Keyboard.Listen(Key.Up, ButtonState.Down, AsetaNopeus, "Pelaaja 2: Liikuta mailaa ylös", maila2, nopeusYlos); 89 Keyboard.Listen(Key.Up, ButtonState.Released, AsetaNopeus, null, maila2, Vector.Zero); 90 Keyboard.Listen(Key.Down, ButtonState.Down, AsetaNopeus, "Pelaaja 2: Liikuta mailaa alas", maila2, nopeusAlas); 91 Keyboard.Listen(Key.Down, ButtonState.Released, AsetaNopeus, null, maila2, Vector.Zero); 92 Keyboard.Listen(Key.F1, ButtonState.Pressed, ShowControlHelp, "Näytä ohjeet"); 93 ControllerOne.Listen(Button.DPadUp, ButtonState.Down, AsetaNopeus, "Liikuta mailaa ylös", maila1, nopeusYlos); 94 ControllerOne.Listen(Button.DPadUp, ButtonState.Released, AsetaNopeus, null, maila1, Vector.Zero); 95 ControllerOne.Listen(Button.DPadDown, ButtonState.Down, AsetaNopeus, "Liikuta mailaa alas", maila1, nopeusAlas); 96 ControllerOne.Listen(Button.DPadDown, ButtonState.Released, AsetaNopeus, null, maila1, Vector.Zero); 97 ControllerTwo.Listen(Button.DPadUp, ButtonState.Down, AsetaNopeus, "Liikuta mailaa ylös", maila2, nopeusYlos); 98 ControllerTwo.Listen(Button.DPadUp, ButtonState.Released, AsetaNopeus, null, maila2, Vector.Zero); 99 ControllerTwo.Listen(Button.DPadDown, ButtonState.Down, AsetaNopeus, "Liikuta mailaa alas", maila2, nopeusAlas); 100 ControllerTwo.Listen(Button.DPadDown, ButtonState.Released, AsetaNopeus, null, maila2, Vector.Zero); 101 102 ControllerOne.Listen(Button.Back, ButtonState.Pressed, Exit, "Poistu"); 103 ControllerTwo.Listen(Button.Back, ButtonState.Pressed, Exit, "Poistu"); 104 66 105 } 67 voidAsetaNopeus( PhysicsObject maila,Vector nopeus) 68 {maila.Velocity = nopeus;} 106 void AsetaNopeus(PhysicsObject maila, Vector nopeus) 107 { 108 if ((nopeus.Y < 0) && (maila.Bottom < Level.Bottom)) 109 { 110 maila.Velocity = Vector.Zero; 111 return; 112 } 69 113 114 if ((nopeus.Y > 0) && (maila.Top > Level.Top)) 115 { 116 maila.Velocity = Vector.Zero; 117 return; 118 119 } 120 121 maila.Velocity = nopeus; 122 123 } 124 void Lisaalaskurit() 125 { 126 pelaajan1Pisteet = LuoPisteLaskuri(Screen.Left + 100.0, Screen.Top - 100.0); 127 pelaajan2Pisteet = LuoPisteLaskuri(Screen.Right - 100.0, Screen.Top - 100.0); 128 } 129 130 IntMeter LuoPisteLaskuri(double x, double y) 131 { 132 IntMeter laskuri = new IntMeter(0); 133 laskuri.MaxValue = 100000; 134 Label naytto = new Label(); 135 naytto.BindTo(laskuri); 136 naytto.X = x; 137 naytto.Y = y; 138 naytto.TextColor = Color.White; 139 naytto.BorderColor = Level.BackgroundColor; 140 naytto.Color = Level.BackgroundColor; 141 Add(naytto); 142 143 return laskuri; 144 } 145 void KasittelePallonTormays(PhysicsObject pallo, PhysicsObject kohde) 146 { 147 if (kohde == oikeaReuna) 148 { 149 pelaajan1Pisteet.Value += 1; 150 } 151 else if (kohde == vasenReuna) 152 { 153 pelaajan2Pisteet.Value += 1; 154 } 155 } 156 157 70 158 } 71 -
2011/31/JesseP/Pong/Pong/Pong/obj/x86/Debug/Pong.csproj.FileListAbsolute.txt
r2476 r2497 7 7 c:\documents and settings\jemapalm\my documents\visual studio 2010\Projects\Pong\Pong\Pong\obj\x86\Debug\Pong.exe 8 8 c:\documents and settings\jemapalm\my documents\visual studio 2010\Projects\Pong\Pong\Pong\obj\x86\Debug\Pong.pdb 9 C:\MyTemp\JesseP\Pong\Pong\Pong\obj\x86\Debug\ResolveAssemblyReference.cache 10 C:\MyTemp\JesseP\Pong\Pong\Pong\obj\x86\Debug\Microsoft.Xna.Framework.RuntimeProfile.txt 11 C:\MyTemp\JesseP\Pong\Pong\Pong\obj\x86\Debug\Pong.exe 12 C:\MyTemp\JesseP\Pong\Pong\Pong\obj\x86\Debug\Pong.pdb 13 C:\MyTemp\JesseP\Pong\Pong\Pong\bin\x86\Debug\Pong.exe 14 C:\MyTemp\JesseP\Pong\Pong\Pong\bin\x86\Debug\Pong.pdb 15 C:\MyTemp\JesseP\Pong\Pong\Pong\bin\x86\Debug\Jypeli4.dll 16 C:\MyTemp\JesseP\Pong\Pong\Pong\bin\x86\Debug\Jypeli4.xml -
2011/31/JesseP/Pong/Pong/PongContent/obj/x86/Debug/ContentPipeline.xml
r2476 r2497 8 8 <BuildConfiguration>Debug</BuildConfiguration> 9 9 <CompressContent>false</CompressContent> 10 <RootDirectory> c:\documents and settings\jemapalm\my documents\visual studio 2010\Projects\Pong\Pong\PongContent\</RootDirectory>11 <LoggerRootDirectory> c:\documents and settings\jemapalm\my documents\visual studio 2010\Projects\Pong\Pong\Pong\</LoggerRootDirectory>12 <IntermediateDirectory> c:\documents and settings\jemapalm\my documents\visual studio 2010\Projects\Pong\Pong\PongContent\obj\x86\Debug\</IntermediateDirectory>13 <OutputDirectory> c:\documents and settings\jemapalm\my documents\visual studio 2010\Projects\Pong\Pong\Pong\bin\x86\Debug\Content\</OutputDirectory>10 <RootDirectory>C:\MyTemp\JesseP\Pong\Pong\PongContent\</RootDirectory> 11 <LoggerRootDirectory>C:\MyTemp\JesseP\Pong\Pong\Pong\</LoggerRootDirectory> 12 <IntermediateDirectory>C:\MyTemp\JesseP\Pong\Pong\PongContent\obj\x86\Debug\</IntermediateDirectory> 13 <OutputDirectory>C:\MyTemp\JesseP\Pong\Pong\Pong\bin\x86\Debug\Content\</OutputDirectory> 14 14 </Settings> 15 15 <Assemblies> -
2011/31/JesseP/Pong/Pong/PongContent/obj/x86/Debug/PongContent.contentproj.FileListAbsolute.txt
r2476 r2497 1 1 c:\documents and settings\jemapalm\my documents\visual studio 2010\Projects\Pong\Pong\PongContent\obj\x86\Debug\ResolveAssemblyReference.cache 2 C:\MyTemp\JesseP\Pong\Pong\PongContent\obj\x86\Debug\ResolveAssemblyReference.cache
Note: See TracChangeset
for help on using the changeset viewer.