Changeset 2510


Ignore:
Timestamp:
2011-08-02 15:01:31 (12 years ago)
Author:
teematma
Message:

Talletus.

Location:
2011/31/TeemuM/FysiikkaPeli1
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • 2011/31/TeemuM/FysiikkaPeli1/FysiikkaPeli1/FysiikkaPeli1/Peli.cs

    r2469 r2510  
    1010{ 
    1111    PhysicsObject alus; 
     12    LaserGun laser; 
     13    PhysicsObject vihu1; 
     14 
    1215    public override void Begin() 
    1316    { 
    1417 
     18        luokentta(); 
    1519        asetaohjaimet(); 
    16         luokentta(); 
    1720        Keyboard.Listen(Key.Escape, ButtonState.Pressed, Exit, "poistu"); 
    18         
     21        luovihu1(); 
    1922 
    2023   } 
     
    2427        this.Level.Width = 3500; 
    2528        Level.CreateBorders(true); 
    26         Gravity = new Vector(0, -40); 
     29        Gravity = new Vector(0, -600); 
     30        Level.CreateGround(10, 30, 100, Color.Brown); 
    2731 
    28        
    29         Level.Background.CreateStars(10000); 
    30          
     32        tausta(); 
     33        Level.BackgroundColor = Color.Black; 
    3134 
    3235        alus = new PhysicsObject(30, 50); 
    3336        Add(alus); 
     37        alus.Restitution = 0; 
     38        alus.LinearDamping = 0.95; 
     39        alus.AngularDamping = 0.75; 
    3440        Camera.Follow(alus); 
    3541        Camera.StayInLevel = true; 
     
    3743        alus.Y = -1350; 
    3844        alus.X = 0; 
     45        LaserGun laser = new LaserGun(10, 10); 
     46        alus.Add(laser); 
     47        
    3948 
     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; 
    4072 
    4173    } 
     
    4375    void tausta() 
    4476    { 
    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         
    4988 
    5089    } 
     
    5392    { 
    5493        Vector voima = new Vector(); 
    55         voima = Vector.FromLengthAndAngle(500, alus.Angle - Angle.FromDegrees(-90));         
     94        voima = Vector.FromLengthAndAngle(2200, alus.Angle - Angle.FromDegrees(-90));         
    5695        alus.Push(voima); 
    5796         
     97    } 
     98    void pyoroik() 
     99    { 
     100        alus.AngularVelocity = -4; 
     101    } 
     102 
     103    void pyorvas() 
     104    { 
     105        alus.AngularVelocity = 4; 
    58106    } 
    59107 
     
    62110       Keyboard.Listen(Key.Up, ButtonState.Down, kaasu, null); 
    63111       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); 
    64117 
    65118   } 
    66119 
     120    protected override void Update(Time time) 
     121    { 
     122        vihu1.Angle = vihu1.Velocity.Angle + Angle.FromDegrees(-90); 
     123 
     124        base.Update(time); 
     125    } 
     126 
    67127} 
Note: See TracChangeset for help on using the changeset viewer.