Changeset 7309
- Timestamp:
- 2016-06-14 15:03:01 (7 years ago)
- Location:
- 2016/24/JereP/Bong
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
2016/24/JereP/Bong/Bong/Bong/Bong.cs
r7271 r7309 9 9 public class Bong : PhysicsGame 10 10 { 11 Vector nopeusYlos = new Vector(0, 200);12 Vector nopeusAlas = new Vector(0, -200);11 Vector nopeusYlos = new Vector(0,300); 12 Vector nopeusAlas = new Vector(0,-300); 13 13 14 14 PhysicsObject pallo; 15 15 PhysicsObject maila1; 16 16 PhysicsObject maila2; 17 18 PhysicsObject vasenReuna; 19 PhysicsObject oikeaReuna; 20 21 IntMeter Pelaajan1Pisteet; 22 IntMeter Pelaajan2Pisteet; 17 23 public override void Begin() 18 24 { … … 29 35 pallo.X = -500.0; 30 36 pallo.Y = 100.0; 31 Level.CreateBorders(1.0, true); 37 38 vasenReuna = Level.CreateLeftBorder(); 39 vasenReuna.Restitution = 1.0; 40 vasenReuna.IsVisible = false; 41 oikeaReuna = Level.CreateRightBorder(); 42 oikeaReuna.Restitution = 1.0; 43 oikeaReuna.IsVisible = false; 44 PhysicsObject alaReuna = Level.CreateBottomBorder(); 45 alaReuna.Restitution = 1.0; 46 alaReuna.IsVisible = false; 47 PhysicsObject ylaReuna = Level.CreateTopBorder(); 48 ylaReuna.Restitution = 1.0; 49 ylaReuna.IsVisible = false; 50 32 51 pallo.Restitution = 1.0; 33 Level.Background.Color = Color.Pink; 52 pallo.KineticFriction = 1.0; 53 54 Level.Background.Color = Color.Black; 55 Camera.ZoomToLevel(); 34 56 35 57 Add(pallo); 36 58 37 maila1 = LuoMaila(Level.Left + 20.0, 0.0); 38 maila2 = LuoMaila(Level.Right - 20.0, 0.0); 59 AddCollisionHandler(pallo, KasittelePallonTormays); 39 60 40 61 maila1 = LuoMaila(Level.Left + 40.0, 0.0); 62 maila2 = LuoMaila(Level.Right - 40.0, 0.0); 63 41 64 42 65 … … 62 85 void AsetaOhjaimet() 63 86 { 64 Keyboard.Listen(Key. A, ButtonState.Down, AsetaNopeus, "Pelaaja 1: Liikuta mailaa ylös", maila1, nopeusYlos);65 Keyboard.Listen(Key. A, ButtonState.Released, AsetaNopeus, null, maila1, Vector.Zero);87 Keyboard.Listen(Key.W, ButtonState.Down, AsetaNopeus, "Pelaaja 1: Liikuta mailaa ylös", maila1, nopeusYlos); 88 Keyboard.Listen(Key.W, ButtonState.Released, AsetaNopeus, null, maila1, Vector.Zero); 66 89 67 Keyboard.Listen(Key. Z, ButtonState.Down, AsetaNopeus, "Pelaaja 1: Liikuta mailaa alas", maila1, nopeusAlas);68 Keyboard.Listen(Key. Z, ButtonState.Released, AsetaNopeus, null, maila1, Vector.Zero);90 Keyboard.Listen(Key.S, ButtonState.Down, AsetaNopeus, "Pelaaja 1: Liikuta mailaa alas", maila1, nopeusAlas); 91 Keyboard.Listen(Key.S, ButtonState.Released, AsetaNopeus, null, maila1, Vector.Zero); 69 92 70 93 Keyboard.Listen(Key.Up, ButtonState.Down, AsetaNopeus, "Pelaaja 2: Liikuta mailaa ylös", maila2, nopeusYlos); … … 101 124 return; 102 125 } 103 126 104 127 maila.Velocity = nopeus; 105 128 } 106 129 void LisaaLaskurit() 107 130 { 108 /// laskuri 131 Pelaajan1Pisteet = LuoPisteLaskuri(Screen.Left + 100.0, Screen.Top - 100.0); 132 Pelaajan2Pisteet = LuoPisteLaskuri(Screen.Right - 100.0, Screen.Top - 100.0); 109 133 } 110 IntMeter LuoPisteLaskuri( )134 IntMeter LuoPisteLaskuri(double x, double y) 111 135 { 136 112 137 IntMeter laskuri = new IntMeter(0); 113 laskuri.MaxValue = 10; 114 138 laskuri.MaxValue = 300000000; 115 139 Label naytto = new Label(); 116 140 naytto.BindTo(laskuri); 117 141 naytto.X = x; 118 142 naytto.Y = y; 119 naytto.TextColor = Color. Black;143 naytto.TextColor = Color.White; 120 144 naytto.BorderColor = Level.Background.Color; 121 145 naytto.Color = Level.Background.Color; 122 146 Add(naytto); 123 147 148 149 124 150 return laskuri; 125 151 } 152 void KasittelePallonTormays(PhysicsObject pallo, PhysicsObject kohde) 153 { 154 if (kohde == oikeaReuna) 155 { 156 Pelaajan1Pisteet.Value += 1; 157 } 158 else if (kohde == vasenReuna) 159 { 160 Pelaajan2Pisteet.Value += 1; 161 } 162 } 163 const double PALLON_MIN_NOPEUS = 500; 164 protected override void Update(Time time) 165 { 166 if (pallo != null && Math.Abs(pallo.Velocity.X) < PALLON_MIN_NOPEUS) 167 { 168 pallo.Velocity = new Vector(pallo.Velocity.X * 1.1, pallo.Velocity.Y); 169 } 170 base.Update(time); 171 } 172 126 173 } -
2016/24/JereP/Bong/Bong/Bong/obj/x86/Debug/Bong.csproj.FileListAbsolute.txt
r7271 r7309 7 7 C:\MyTemp\JerePöntynen\Bong\Bong\Bong\obj\x86\Debug\Bong.exe 8 8 C:\MyTemp\JerePöntynen\Bong\Bong\Bong\obj\x86\Debug\Bong.pdb 9 C:\MyTemp\Jere2\Bong\Bong\Bong\bin\x86\Debug\Bong.exe 10 C:\MyTemp\Jere2\Bong\Bong\Bong\bin\x86\Debug\Bong.pdb 11 C:\MyTemp\Jere2\Bong\Bong\Bong\bin\x86\Debug\Jypeli.dll 12 C:\MyTemp\Jere2\Bong\Bong\Bong\bin\x86\Debug\Jypeli.xml 13 C:\MyTemp\Jere2\Bong\Bong\Bong\obj\x86\Debug\Bong.csprojResolveAssemblyReference.cache 14 C:\MyTemp\Jere2\Bong\Bong\Bong\obj\x86\Debug\Microsoft.Xna.Framework.RuntimeProfile.txt 15 C:\MyTemp\Jere2\Bong\Bong\Bong\obj\x86\Debug\Bong.exe 16 C:\MyTemp\Jere2\Bong\Bong\Bong\obj\x86\Debug\Bong.pdb -
2016/24/JereP/Bong/Bong/Bong/obj/x86/Debug/ContentPipeline-{D693B282-540A-4A65-8EE0-577FDC978B51}.xml
r7271 r7309 9 9 <BuildConfiguration>Debug</BuildConfiguration> 10 10 <CompressContent>false</CompressContent> 11 <RootDirectory>C:\MyTemp\Jere Pöntynen\Bong\Bong\BongContent\</RootDirectory>12 <LoggerRootDirectory>C:\MyTemp\Jere Pöntynen\Bong\Bong\Bong\</LoggerRootDirectory>13 <IntermediateDirectory>C:\MyTemp\Jere Pöntynen\Bong\Bong\Bong\obj\x86\Debug\</IntermediateDirectory>14 <OutputDirectory>C:\MyTemp\Jere Pöntynen\Bong\Bong\Bong\bin\x86\Debug\Content\</OutputDirectory>11 <RootDirectory>C:\MyTemp\Jere2\Bong\Bong\BongContent\</RootDirectory> 12 <LoggerRootDirectory>C:\MyTemp\Jere2\Bong\Bong\Bong\</LoggerRootDirectory> 13 <IntermediateDirectory>C:\MyTemp\Jere2\Bong\Bong\Bong\obj\x86\Debug\</IntermediateDirectory> 14 <OutputDirectory>C:\MyTemp\Jere2\Bong\Bong\Bong\bin\x86\Debug\Content\</OutputDirectory> 15 15 </Settings> 16 16 <Assemblies> -
2016/24/JereP/Bong/Bong/BongContent/obj/x86/Debug/BongContent.contentproj.FileListAbsolute.txt
r7271 r7309 1 1 C:\MyTemp\JerePöntynen\Bong\Bong\BongContent\obj\x86\Debug\BongContent.contentprojResolveAssemblyReference.cache 2 C:\MyTemp\Jere2\Bong\Bong\BongContent\obj\x86\Debug\BongContent.contentprojResolveAssemblyReference.cache
Note: See TracChangeset
for help on using the changeset viewer.