- Timestamp:
- 2016-06-27 14:56:38 (7 years ago)
- Location:
- 2016/26/HennaS/Pong
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
2016/26/HennaS/Pong/Pong/Pong/Pong.cs
r7520 r7526 9 9 public class Pong : PhysicsGame 10 10 { 11 Vector nopeusYlos = new Vector(0, 200); 12 Vector nopeusAlas = new Vector(0, -200); 11 13 PhysicsObject pallo; 14 PhysicsObject maila1; 15 PhysicsObject maila2; 16 12 17 public override void Begin() 13 18 { 14 // TODO: Kirjoita ohjelmakoodisi tähän 19 LuoKentta(); 20 AsetaOhjaimet(); 21 LisaaLaskurit(); 22 AloitaPeli(); 23 } 15 24 16 LuoKentta();17 18 Vector impulssi = new Vector(500.0, 0.0);19 pallo.Hit(impulssi);20 21 22 23 Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli");24 Camera.ZoomToLevel();25 26 27 28 29 }30 31 25 void LuoKentta() 32 26 { … … 35 29 Level.Background.Color = Color.Black; 36 30 31 32 maila1 = LuoMaila(Level.Left + 20.0, 0.0); 33 maila2 = LuoMaila(Level.Right - 20.0, 0.0); 37 34 pallo.Shape = Shape.Circle; 38 35 pallo.X = -200.0; 39 36 pallo.Y = 0.0; 37 pallo.Color = Color.RosePink; 40 38 Add(pallo); 41 39 pallo.Restitution = 1.0; 40 41 } 42 void AloitaPeli() 43 { 44 Vector impulssi = new Vector(500.0, 0.0); 45 pallo.Hit(impulssi); 46 47 48 49 50 51 52 } 53 PhysicsObject LuoMaila(double x, double y) 54 { 42 55 PhysicsObject maila = PhysicsObject.CreateStaticObject(20.0, 100.0); 43 56 maila.Shape = Shape.Rectangle; 44 maila.X = Level.Left + 20.0; 45 maila.Y = 0.0; 57 maila.X = x; 58 maila.Color = Color.Silver; 59 maila.Y = y; 46 60 maila.Restitution = 1.0; 47 61 Add(maila); 62 return maila; 48 63 } 49 } 64 void AsetaOhjaimet() 65 { 66 Keyboard.Listen(Key.A, ButtonState.Down, AsetaNopeus, "Pelaaja 1: Liikuta mailaa ylös", maila1, nopeusYlos); 67 Keyboard.Listen(Key.A, ButtonState.Released, AsetaNopeus, null, maila1, Vector.Zero); 68 Keyboard.Listen(Key.Z, ButtonState.Down, AsetaNopeus, "Pelaaja 1: Liikuta mailaa alas", maila1, nopeusAlas); 69 Keyboard.Listen(Key.Z, ButtonState.Released, AsetaNopeus, null, maila1, Vector.Zero); 70 71 Keyboard.Listen(Key.Up, ButtonState.Down, AsetaNopeus, "Pelaaja 2: Liikuta mailaa ylös", maila2, nopeusYlos); 72 Keyboard.Listen(Key.Up, ButtonState.Released, AsetaNopeus, null, maila2, Vector.Zero); 73 Keyboard.Listen(Key.Down, ButtonState.Down, AsetaNopeus, "Pelaaja 2: Liikuta mailaa alas", maila2, nopeusAlas); 74 Keyboard.Listen(Key.Down, ButtonState.Released, AsetaNopeus, null, maila2, Vector.Zero); 75 76 77 78 Keyboard.Listen(Key.F1, ButtonState.Pressed, ShowControlHelp, "Näytä ohjeet"); 79 Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli"); 80 81 } 82 void AsetaNopeus(PhysicsObject maila, Vector nopeus) 83 { 84 if ((nopeus.Y < 0) && (maila.Bottom < Level.Bottom)) 85 { 86 maila.Velocity = Vector.Zero; 87 return; 88 } 89 if ((nopeus.Y > 0) && (maila.Top > Level.Top)) 90 { 91 maila.Velocity = Vector.Zero; 92 return; 93 } 94 95 maila.Velocity = nopeus; 96 } 97 void LisaaLaskurit() 98 { 99 100 } 101 } 102 103 -
2016/26/HennaS/Pong/Pong/Pong/obj/x86/Debug/ContentPipeline-{A049D026-B69B-4059-9867-FD8DAC258AD0}.xml
r7520 r7526 17 17 <Assembly> 18 18 <Key>C:\Windows\Microsoft.Net\assembly\GAC_32\Microsoft.Xna.Framework.Content.Pipeline\v4.0_4.0.0.0__842cf8be1de50553\Microsoft.Xna.Framework.Content.Pipeline.dll</Key> 19 <Value>2015-09-16T1 2:47:00.0480835+03:00</Value>19 <Value>2015-09-16T19:42:13.6500946+03:00</Value> 20 20 </Assembly> 21 21 </Assemblies>
Note: See TracChangeset
for help on using the changeset viewer.