- Timestamp:
- 2011-08-02 15:01:31 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
2011/31/TeemuM/FysiikkaPeli1/FysiikkaPeli1/FysiikkaPeli1/Peli.cs
r2469 r2510 10 10 { 11 11 PhysicsObject alus; 12 LaserGun laser; 13 PhysicsObject vihu1; 14 12 15 public override void Begin() 13 16 { 14 17 18 luokentta(); 15 19 asetaohjaimet(); 16 luokentta();17 20 Keyboard.Listen(Key.Escape, ButtonState.Pressed, Exit, "poistu"); 18 21 luovihu1(); 19 22 20 23 } … … 24 27 this.Level.Width = 3500; 25 28 Level.CreateBorders(true); 26 Gravity = new Vector(0, -40); 29 Gravity = new Vector(0, -600); 30 Level.CreateGround(10, 30, 100, Color.Brown); 27 31 28 29 Level.Background.CreateStars(10000); 30 32 tausta(); 33 Level.BackgroundColor = Color.Black; 31 34 32 35 alus = new PhysicsObject(30, 50); 33 36 Add(alus); 37 alus.Restitution = 0; 38 alus.LinearDamping = 0.95; 39 alus.AngularDamping = 0.75; 34 40 Camera.Follow(alus); 35 41 Camera.StayInLevel = true; … … 37 43 alus.Y = -1350; 38 44 alus.X = 0; 45 LaserGun laser = new LaserGun(10, 10); 46 alus.Add(laser); 47 39 48 49 } 50 51 void luovihu1() 52 { 53 vihu1 = new PhysicsObject(30, 50); 54 Add(vihu1); 55 vihu1.Color = Color.Red; 56 vihu1.Restitution = 0; 57 vihu1.LinearDamping = 0.95; 58 vihu1.AngularDamping = 0.75; 59 //Camera.Follow(alus); 60 //Camera.StayInLevel = true; 61 vihu1.Shape = Shape.Triangle; 62 vihu1.Y = 1350; 63 vihu1.X = 0; 64 FollowerBrain aivo1 = new FollowerBrain(); 65 aivo1.Active = true; 66 aivo1.Target = alus; 67 aivo1.Speed = 400; 68 aivo1.TargetFollowDistance = 15000; 69 //aivo1.TargetCloseDistance = 10; 70 //aivo1.StopWhenTargetClose = true; 71 vihu1.Brain = aivo1; 40 72 41 73 } … … 43 75 void tausta() 44 76 { 45 GameObject tähti = new GameObject(10, 10); 46 /* taustaPilvet.Image = pilviKuva;*/ 47 Add(taustaPilvet, -3); 48 GetLayer(-3).RelativeTransition = new Vector(0.5, 0.5); 77 78 for (int i = 0; i < 1100; i++) 79 { 80 GameObject tahti = new GameObject(3, 3); 81 tahti.Shape = Shape.Star; 82 Add(tahti, -3); 83 tahti.Y = RandomGen.NextDouble(Level.Bottom, Level.Top); 84 tahti.X = RandomGen.NextDouble(Level.Left, Level.Right); 85 GetLayer(-3).RelativeTransition = new Vector(0.5, 0.5); 86 } 87 49 88 50 89 } … … 53 92 { 54 93 Vector voima = new Vector(); 55 voima = Vector.FromLengthAndAngle( 500, alus.Angle - Angle.FromDegrees(-90));94 voima = Vector.FromLengthAndAngle(2200, alus.Angle - Angle.FromDegrees(-90)); 56 95 alus.Push(voima); 57 96 97 } 98 void pyoroik() 99 { 100 alus.AngularVelocity = -4; 101 } 102 103 void pyorvas() 104 { 105 alus.AngularVelocity = 4; 58 106 } 59 107 … … 62 110 Keyboard.Listen(Key.Up, ButtonState.Down, kaasu, null); 63 111 Keyboard.Listen(Key.W, ButtonState.Down, kaasu, null); 112 Keyboard.Listen(Key.Right, ButtonState.Down, pyoroik, null); 113 Keyboard.Listen(Key.D, ButtonState.Down, pyoroik, null); 114 Keyboard.Listen(Key.Left, ButtonState.Down, pyorvas, null); 115 Keyboard.Listen(Key.A, ButtonState.Down, pyorvas, null); 116 Keyboard.Listen(Key.Space, ButtonState.Pressed, laser, null); 64 117 65 118 } 66 119 120 protected override void Update(Time time) 121 { 122 vihu1.Angle = vihu1.Velocity.Angle + Angle.FromDegrees(-90); 123 124 base.Update(time); 125 } 126 67 127 }
Note: See TracChangeset
for help on using the changeset viewer.