- Timestamp:
- 2013-07-23 11:48:20 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
2013/30/VilleF/Lentokone/Lentokone/Lentokone/Lentokone.cs
r4545 r4551 11 11 Image maisema = LoadImage("havutausta"); 12 12 Image havusaurus = LoadImage("havusaurus"); 13 PhysicsObject pelaaja; 13 14 public override void Begin() 14 15 { 15 luokentta(); 16 luohavusaurus(); 17 16 Level.Width = 800; 17 Level.Height = 600; 18 SetWindowSize(800, 600, false); 19 LuoKentta(); 20 LuoHavusaurus(); 21 LiikutaPelaajaa(); 22 Camera.ZoomToLevel(); 18 23 PhoneBackButton.Listen(ConfirmExit, "Lopeta peli"); 19 24 Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli"); 20 25 } 21 void luokentta() 26 27 void LuoKentta() 22 28 { 23 Level.Width = 1920;24 Level.Height = 1080;25 29 Level.BackgroundColor = Color.Red; 26 30 Level.Background.Image = maisema; 27 31 Level.Background.FitToLevel(); 32 Surface alareuna = new Surface(Level.Width, 30, 50, 60, 10); 33 alareuna.Color = Color.Green; 34 alareuna.Bottom = Level.Bottom; 35 Add(alareuna); 36 28 37 } 29 void luohavusaurus()38 void LuoHavusaurus() 30 39 { 31 40 PhysicsObject pelaaja = new PhysicsObject(235.0, 283.0); … … 35 44 36 45 } 46 void LiikutaPelaajaa() 47 { 48 pelaaja.LinearDamping = 0.95; 49 Vector pelaajanSuunta = Vector.FromLengthAndAngle(500.0, pelaaja.Angle); 50 pelaaja.Push(pelaajanSuunta); 51 52 Keyboard.Listen(Key.W, ButtonState.Down, AsetaNopeus, "Pelaaja 1 Mailaa ylös", pelaaja, nopeusYlos); 53 Keyboard.Listen(Key.W, ButtonState.Released, AsetaNopeus, null, pelaaja, Vector.Zero); 54 Keyboard.Listen(Key.S, ButtonState.Down, AsetaNopeus, "Pelaaja 1: Liikuta mailaa alas", pelaaja, nopeusAlas); 55 Keyboard.Listen(Key.S, ButtonState.Released, AsetaNopeus, null, pelaaja, Vector.Zero); 56 Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "PLS DOLAN STAAPH"); 57 } 58 void AsetaNopeus() 59 { 60 if ((nopeus.Y < 0) && (pelaaja.Bottom < Level.Bottom)) 61 { 62 pelaaja.Velocity = Vector.Zero; 63 return; 64 } 65 if ((nopeus.Y > 0) && (pelaaja.Top > Level.Top)) 66 { 67 pelaaja.Velocity = Vector.Zero; 68 return; 69 } 37 70 }
Note: See TracChangeset
for help on using the changeset viewer.