- Timestamp:
- 2017-06-13 13:08:10 (6 years ago)
- Location:
- 2017/24/SebastianH/Pong/Pong
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
2017/24/SebastianH/Pong/Pong/Pong/Pong.cs
r8540 r8585 13 13 14 14 PhysicsObject pallo; 15 16 15 PhysicsObject maila1; 17 16 PhysicsObject maila2; 17 18 PhysicsObject vasenReuna; 19 PhysicsObject oikeaReuna; 20 21 IntMeter pelaajan1Pisteet; 22 IntMeter pelaajan2Pisteet; 18 23 public override void Begin() 19 24 { 20 25 LuoKentta(); 21 26 AsetaOhjaimet(); 27 LisaaLaskurit(); 22 28 AloitaPeli(); 23 29 … … 34 40 Add(pallo); 35 41 36 LuoMaila(Level.Left + 20.0, 0.0); 37 LuoMaila(Level.Right - 20.0, 0.0); 42 AddCollisionHandler(pallo, KasittelePallonTormays); 38 43 39 Level.CreateBorders(1.0, false); 44 maila1 = LuoMaila(Level.Left + 20.0, 0.0); 45 maila2 = LuoMaila(Level.Right - 20.0, 0.0); 46 47 vasenReuna = Level.CreateLeftBorder(); 48 vasenReuna.Restitution = 1.0; 49 vasenReuna.IsVisible = false; 50 51 oikeaReuna = Level.CreateRightBorder(); 52 oikeaReuna.Restitution = 1.0; 53 vasenReuna.IsVisible = false; 54 55 PhysicsObject alareuna = Level.CreateBottomBorder(); 56 alareuna.Restitution = 1.0; 57 alareuna.IsVisible = false; 58 59 PhysicsObject ylaReuna = Level.CreateTopBorder(); 60 ylaReuna.Restitution = 1.0; 61 ylaReuna.IsVisible = false; 62 40 63 Level.Background.Color = Color.Black; 41 64 … … 47 70 pallo.Hit(impulssi); 48 71 } 49 voidLuoMaila(double x, double y)72 PhysicsObject LuoMaila(double x, double y) 50 73 { 51 74 PhysicsObject maila = PhysicsObject.CreateStaticObject(20.0, 100.0); … … 55 78 maila.Restitution = 1.0; 56 79 Add(maila); 80 return maila; 57 81 } 58 82 void AsetaOhjaimet() 59 83 { 60 Keyboard.Listen(Key.W, ButtonState.Down, LiikutaMaila1Ylos, "Pelaaja 1: Liikuta mailaa ylös"); 61 Keyboard.Listen(Key.W, ButtonState.Released, PysaytaMaila1, null); 84 Keyboard.Listen(Key.W, ButtonState.Down, AsetaNopeus, "Pelaaja 1: Liikuta mailaa ylös", maila1, nopeusYlos); 85 Keyboard.Listen(Key.W, ButtonState.Released, AsetaNopeus, null, maila1, Vector.Zero); 86 Keyboard.Listen(Key.S, ButtonState.Down, AsetaNopeus, "Pelaaja 1: Liikuta mailaa alas", maila1, nopeusAlas); 87 Keyboard.Listen(Key.S, ButtonState.Released, AsetaNopeus, null, maila1, Vector.Zero); 88 89 Keyboard.Listen(Key.Up, ButtonState.Down, AsetaNopeus, "Pelaaja 2: Liikuta mailaa ylös", maila2, nopeusYlos); 90 Keyboard.Listen(Key.Up, ButtonState.Released, AsetaNopeus, null, maila2, Vector.Zero); 91 Keyboard.Listen(Key.Down, ButtonState.Down, AsetaNopeus, "Pelaaja 2: Liikuta mailaa alas", maila2, nopeusAlas); 92 Keyboard.Listen(Key.Down, ButtonState.Released, AsetaNopeus, null, maila2, Vector.Zero); 93 94 Keyboard.Listen(Key.F1, ButtonState.Pressed, ShowControlHelp, "Näytä ohjeet"); 62 95 Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli"); 63 96 } 64 97 void AsetaNopeus(PhysicsObject maila, Vector nopeus) 65 98 { 99 if ((nopeus.Y < 0) && (maila.Bottom < Level.Bottom)) 100 { 101 maila.Velocity = Vector.Zero; 102 return; 103 } 104 if ((nopeus.Y > 0) && (maila.Top > Level.Top)) 105 { 106 maila.Velocity = Vector.Zero; 107 return; 108 } 109 66 110 maila.Velocity = nopeus; 67 111 } 112 void LisaaLaskurit() 113 { 114 pelaajan1Pisteet = LuoPisteLaskuri(Screen.Left + 100.0, Screen.Top - 100.0); 115 pelaajan2Pisteet = LuoPisteLaskuri(Screen.Right - 100.0, Screen.Top - 100.0); 116 } 117 IntMeter LuoPisteLaskuri(double x, double y) 118 { 119 IntMeter laskuri = new IntMeter(0); 120 laskuri.MaxValue = 10; 121 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 = Level.Background.Color; 128 naytto.Color = Level.Background.Color; 129 Add(naytto); 130 131 return laskuri; 132 } 133 void KasittelePallonTormays(PhysicsObject pallo, PhysicsObject kohde) 134 { 135 if (kohde == oikeaReuna) 136 { 137 pelaajan1Pisteet.Value += 1; 138 } 139 else if (kohde == vasenReuna) 140 { 141 pelaajan2Pisteet.Value += 1; 142 } 143 } 68 144 } -
2017/24/SebastianH/Pong/Pong/Pong/obj/x86/Debug/ContentPipeline-{0A35FA10-CC5B-4A14-91E0-8CF99771CD54}.xml
r8540 r8585 9 9 <BuildConfiguration>Debug</BuildConfiguration> 10 10 <CompressContent>false</CompressContent> 11 <RootDirectory>C:\MyTemp\ Pong\Pong\PongContent\</RootDirectory>12 <LoggerRootDirectory>C:\MyTemp\ Pong\Pong\Pong\</LoggerRootDirectory>13 <IntermediateDirectory>C:\MyTemp\ Pong\Pong\Pong\obj\x86\Debug\</IntermediateDirectory>14 <OutputDirectory>C:\MyTemp\ Pong\Pong\Pong\bin\x86\Debug\Content\</OutputDirectory>11 <RootDirectory>C:\MyTemp\SebastianH\Pong\Pong\PongContent\</RootDirectory> 12 <LoggerRootDirectory>C:\MyTemp\SebastianH\Pong\Pong\Pong\</LoggerRootDirectory> 13 <IntermediateDirectory>C:\MyTemp\SebastianH\Pong\Pong\Pong\obj\x86\Debug\</IntermediateDirectory> 14 <OutputDirectory>C:\MyTemp\SebastianH\Pong\Pong\Pong\bin\x86\Debug\Content\</OutputDirectory> 15 15 </Settings> 16 16 <Assemblies> -
2017/24/SebastianH/Pong/Pong/Pong/obj/x86/Debug/Pong.csproj.FileListAbsolute.txt
r8540 r8585 7 7 C:\MyTemp\Pong\Pong\Pong\obj\x86\Debug\Pong.exe 8 8 C:\MyTemp\Pong\Pong\Pong\obj\x86\Debug\Pong.pdb 9 C:\MyTemp\SebastianH\Pong\Pong\Pong\obj\x86\Debug\Pong.csprojResolveAssemblyReference.cache 10 C:\MyTemp\SebastianH\Pong\Pong\Pong\obj\x86\Debug\Microsoft.Xna.Framework.RuntimeProfile.txt 11 C:\MyTemp\SebastianH\Pong\Pong\Pong\obj\x86\Debug\Pong.exe 12 C:\MyTemp\SebastianH\Pong\Pong\Pong\obj\x86\Debug\Pong.pdb 13 C:\MyTemp\SebastianH\Pong\Pong\Pong\bin\x86\Debug\Pong.exe 14 C:\MyTemp\SebastianH\Pong\Pong\Pong\bin\x86\Debug\Pong.pdb 15 C:\MyTemp\SebastianH\Pong\Pong\Pong\bin\x86\Debug\Jypeli.dll 16 C:\MyTemp\SebastianH\Pong\Pong\Pong\bin\x86\Debug\Jypeli.xml -
2017/24/SebastianH/Pong/Pong/PongContent/obj/x86/Debug/PongContent.contentproj.FileListAbsolute.txt
r8540 r8585 1 1 C:\MyTemp\Pong\Pong\PongContent\obj\x86\Debug\PongContent.contentprojResolveAssemblyReference.cache 2 C:\MyTemp\SebastianH\Pong\Pong\PongContent\obj\x86\Debug\PongContent.contentprojResolveAssemblyReference.cache
Note: See TracChangeset
for help on using the changeset viewer.