Changeset 7534
- Timestamp:
- 2016-06-27 14:58:42 (7 years ago)
- Location:
- 2016/26/HeiniI/Pong
- Files:
-
- 1 added
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
2016/26/HeiniI/Pong/Pong/Pong/Pong.cs
r7518 r7534 9 9 public class Pong : PhysicsGame 10 10 { 11 Vector nopeusYlos = new Vector(0, 200); 12 Vector nopeusalas = new Vector(0, -200); 13 11 14 PhysicsObject pallo; 15 PhysicsObject maila1; 16 PhysicsObject maila2; 17 18 PhysicsObject VasenReuna; 19 PhysicsObject OikeaReuna; 20 21 IntMeter Pelaajan1Pisteet; 22 IntMeter Pelaajan2Pisteet; 23 12 24 public override void Begin() 13 25 { 14 26 luoKentta(); 15 27 AsetaOhjaimet(); 28 LisaaLaskurit(); 16 29 AloitaPeli(); 17 30 18 Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli");19 31 } 20 32 void luoKentta() … … 25 37 pallo.Y = 0.0; 26 38 pallo.Restitution = 1.0; 39 pallo.KineticFriction = 0.0; 40 pallo.MomentOfInertia = Double.PositiveInfinity; 27 41 Add(pallo); 42 AddCollisionHandler(pallo, KasittelePallonTormays); 28 43 29 LuoMaila(Level.Left + 20.0, 0.0);30 LuoMaila(Level.Right - 20.0, 0.0);44 maila1 = LuoMaila(Level.Left + 20.0, 0.0); 45 maila2 = LuoMaila(Level.Right - 20.0, 0.0); 31 46 32 Level.CreateBorders(1.0, false); 47 VasenReuna = Level.CreateLeftBorder(); 48 VasenReuna.Restitution = 1.0; 49 VasenReuna.IsVisible = false; 50 51 OikeaReuna = Level.CreateRightBorder(); 52 OikeaReuna.Restitution = 1.0; 53 OikeaReuna.IsVisible = false; 54 55 PhysicsObject ylaReuna = Level.CreateTopBorder(); 56 ylaReuna.Restitution = 1.0; 57 ylaReuna.IsVisible = false; 58 59 PhysicsObject alaReuna = Level.CreateBottomBorder(); 60 alaReuna.Restitution = 1.0; 61 alaReuna.IsVisible = false; 62 63 33 64 Level.Background.Color = Color.Aquamarine; 34 65 … … 41 72 pallo.Hit(impulssi); 42 73 } 43 voidLuoMaila (double x, double y)74 PhysicsObject LuoMaila (double x, double y) 44 75 { 45 76 PhysicsObject maila = PhysicsObject.CreateStaticObject(20.0, 100.0); … … 49 80 maila.Restitution = 1.0; 50 81 Add(maila); 82 return maila; 51 83 } 52 84 void AsetaOhjaimet() 53 85 { 54 Keyboard.Listen(Key.A, ButtonState.Down, LiikutaMaila1Ylös, "Pelaaja 1: liikuta mailaa ylös"); 55 Keyboard.Listen(Key.A, ButtonState.Released, PysaytaMaila1, null); 86 Keyboard.Listen(Key.A, ButtonState.Down, AsetaNopeus, "Pelaaja 1: liikuta mailaa ylös",maila1, nopeusYlos); 87 Keyboard.Listen(Key.A, ButtonState.Released, AsetaNopeus, null, maila1, Vector.Zero); 88 Keyboard.Listen(Key.Z, ButtonState.Down, AsetaNopeus, "Pelaaja 1. liikuta mailaa alas", maila1, nopeusalas); 89 Keyboard.Listen(Key.Z, ButtonState.Released, AsetaNopeus, null, maila1, Vector.Zero); 56 90 91 92 93 Keyboard.Listen(Key.Up, ButtonState.Down, AsetaNopeus, "Pelaaja 2: Liikuta mailaa ylös", maila2, nopeusYlos); 94 Keyboard.Listen(Key.Up, ButtonState.Released, AsetaNopeus, null, maila2, Vector.Zero); 95 Keyboard.Listen(Key.Down, ButtonState.Down, AsetaNopeus, "Pelaaja 2: Liikuta mailaa alas", maila2, nopeusalas); 96 Keyboard.Listen(Key.Down, ButtonState.Released, AsetaNopeus, null, maila2, Vector.Zero); 97 98 Keyboard.Listen(Key.F1, ButtonState.Pressed, ShowControlHelp, "Näytä ohjeet"); 57 99 Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli"); 100 101 } 102 void AsetaNopeus(PhysicsObject maila, Vector nopeus) 103 104 { 105 if ((nopeus.Y < 0) && (maila.Bottom < Level.Bottom)) 106 { 107 maila.Velocity = Vector.Zero; 108 return; 109 } 110 if ((nopeus.Y > 0) && (maila.Top > Level.Top)) 111 { 112 maila.Velocity = Vector.Zero; 113 return; 114 } 115 maila.Velocity = nopeus; 116 } 117 void LisaaLaskurit() 118 { 119 Pelaajan1Pisteet = LuoPistelaskuri(Screen.Left + 100.0, Screen.Top - 100.0); 120 Pelaajan2Pisteet = LuoPistelaskuri(Screen.Right - 100.0, Screen.Top - 100.0); 121 } 122 IntMeter LuoPistelaskuri( double x, double y) 123 { 124 IntMeter laskuri = new IntMeter(0); 125 laskuri.MaxValue = 10; 126 Label naytto = new Label(); 127 naytto.BindTo(laskuri); 128 naytto.X = x; 129 naytto.Y = y; 130 naytto.TextColor = Color.HotPink; 131 naytto.BorderColor = Level.Background.Color; 132 naytto.Color = Level.Background.Color; 133 Add(naytto); 134 135 return laskuri; 136 } 137 void KasittelePallonTormays(PhysicsObject pallo,PhysicsObject kohde) 138 { 139 if (kohde == OikeaReuna) 140 { 141 Pelaajan1Pisteet.Value += 1; 142 } 143 else if (kohde == VasenReuna) 144 { 145 Pelaajan2Pisteet.Value += 1; 146 } 58 147 59 148 } -
2016/26/HeiniI/Pong/Pong/Pong/obj/x86/Debug/ContentPipeline-{9F11FD93-1081-4299-B6D1-7923FB13FBD7}.xml
r7518 r7534 9 9 <BuildConfiguration>Debug</BuildConfiguration> 10 10 <CompressContent>false</CompressContent> 11 <RootDirectory>C:\MyTemp\HeiniI \Pong\Pong\PongContent\</RootDirectory>12 <LoggerRootDirectory>C:\MyTemp\HeiniI \Pong\Pong\Pong\</LoggerRootDirectory>13 <IntermediateDirectory>C:\MyTemp\HeiniI \Pong\Pong\Pong\obj\x86\Debug\</IntermediateDirectory>14 <OutputDirectory>C:\MyTemp\HeiniI \Pong\Pong\Pong\bin\x86\Debug\Content\</OutputDirectory>11 <RootDirectory>C:\MyTemp\HeiniI-uusin\Pong\Pong\PongContent\</RootDirectory> 12 <LoggerRootDirectory>C:\MyTemp\HeiniI-uusin\Pong\Pong\Pong\</LoggerRootDirectory> 13 <IntermediateDirectory>C:\MyTemp\HeiniI-uusin\Pong\Pong\Pong\obj\x86\Debug\</IntermediateDirectory> 14 <OutputDirectory>C:\MyTemp\HeiniI-uusin\Pong\Pong\Pong\bin\x86\Debug\Content\</OutputDirectory> 15 15 </Settings> 16 16 <Assemblies> -
2016/26/HeiniI/Pong/Pong/Pong/obj/x86/Debug/Pong.csproj.FileListAbsolute.txt
r7518 r7534 7 7 C:\MyTemp\HeiniI\Pong\Pong\Pong\obj\x86\Debug\Pong.exe 8 8 C:\MyTemp\HeiniI\Pong\Pong\Pong\obj\x86\Debug\Pong.pdb 9 C:\MyTemp\HeiniI-uusin\Pong\Pong\Pong\obj\x86\Debug\Pong.csprojResolveAssemblyReference.cache 10 C:\MyTemp\HeiniI-uusin\Pong\Pong\Pong\obj\x86\Debug\Microsoft.Xna.Framework.RuntimeProfile.txt 11 C:\MyTemp\HeiniI-uusin\Pong\Pong\Pong\obj\x86\Debug\Pong.exe 12 C:\MyTemp\HeiniI-uusin\Pong\Pong\Pong\obj\x86\Debug\Pong.pdb 13 C:\MyTemp\HeiniI-uusin\Pong\Pong\Pong\bin\x86\Debug\Pong.exe 14 C:\MyTemp\HeiniI-uusin\Pong\Pong\Pong\bin\x86\Debug\Pong.pdb 15 C:\MyTemp\HeiniI-uusin\Pong\Pong\Pong\bin\x86\Debug\Jypeli.dll 16 C:\MyTemp\HeiniI-uusin\Pong\Pong\Pong\bin\x86\Debug\Jypeli.xml -
2016/26/HeiniI/Pong/Pong/PongContent/obj/x86/Debug/PongContent.contentproj.FileListAbsolute.txt
r7518 r7534 1 1 C:\MyTemp\HeiniI\Pong\Pong\PongContent\obj\x86\Debug\PongContent.contentprojResolveAssemblyReference.cache 2 C:\MyTemp\HeiniI-uusin\Pong\Pong\PongContent\obj\x86\Debug\PongContent.contentprojResolveAssemblyReference.cache
Note: See TracChangeset
for help on using the changeset viewer.