- Timestamp:
- 2015-06-10 11:35:49 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
2015/24/TaneliL/FysiikkaPeli2/FysiikkaPeli2/FysiikkaPeli2/FysiikkaPeli2.cs
r5958 r5985 9 9 public class FysiikkaPeli2 : PhysicsGame 10 10 { 11 Vector nopeusYlös = new Vector(100 , 0);11 Vector nopeusYlös = new Vector(1000, 0); 12 12 PhysicsObject Pelaaja; 13 13 14 PhysicsObject Alareuna; 15 PhysicsObject Ylareuna; 14 16 public override void Begin() 15 17 { 16 18 17 Luo Pelaaja(0, 0);18 AsetaNappaimet();19 LuoMaailma(0, 0); 20 19 21 20 22 21 23 Keyboard.Listen(Key.Up, ButtonState.Down, LiikutaPelaajaa, "liikuta Pelaajaa Ylös", new Vector (0, 1000)); 22 24 PhoneBackButton.Listen(ConfirmExit, "Lopeta peli"); 23 25 Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli"); 24 26 } 25 27 26 void Luo Pelaaja(double x, double y)28 void LuoMaailma(double x, double y) 27 29 { 28 P hysicsObject Pelaaja = new PhysicsObject(50, 50);30 Pelaaja = new PhysicsObject(50, 50); 29 31 Pelaaja.Shape = Shape.Circle; 30 32 Pelaaja.Color = Color.GreenYellow; 31 33 Pelaaja.X = x; 32 34 Pelaaja.Y = y; 33 Gravity = new Vector(0, - 100);35 Gravity = new Vector(0, -500); 34 36 Add(Pelaaja); 35 37 36 Level.CreateBorders(); 38 Alareuna = Level.CreateBottomBorder(0,true); 39 Alareuna.Width = 2000; 40 Ylareuna = Level.CreateTopBorder(0, true); 41 Ylareuna.Width = 2000; 42 PhysicsObject Este = PhysicsObject.CreateStaticObject(100,500); 43 44 Add(Este); 45 46 //Level.CreateVerticalBorders(0, true, Color.White); 37 47 Level.Background.Color = Color.Cyan; 38 Camera. ZoomToLevel();48 Camera.Follow(Pelaaja); 39 49 } 40 50 41 void AsetaNappaimet() 51 52 protected override void Update(Microsoft.Xna.Framework.GameTime gameTime) 42 53 { 43 Keyboard.Listen(Key.Space, ButtonState.Down, LiikutaPelaajaYlos, "Pelaaja liikkuu ylös"); 54 base.Update(gameTime); 55 Pelaaja.Push(new Vector(70, 0)); 56 Alareuna.X = Pelaaja.X; 57 Ylareuna.X = Pelaaja.X; 58 44 59 45 60 } 46 void AsetaNopeus(PhysicsObject Pelaaja, Vector Nopeus) 61 62 void LiikutaPelaajaa(Vector vektori) 47 63 { 48 Pelaaja. Velocity = Nopeus;64 Pelaaja.Push(vektori); 49 65 } 50 66 }
Note: See TracChangeset
for help on using the changeset viewer.