Ignore:
Timestamp:
2017-07-26 11:48:11 (2 years ago)
Author:
npo17_65
Message:

Hoo pystyy liikkkumaan ja Hannin ase toimii.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 2017/30/HugoE/HanniAndHoo/HanniAndHoo/HanniAndHoo/HanniAndHoo.cs

    r9111 r9118  
    99public class HanniAndHoo : PhysicsGame 
    1010{ 
    11     //Image HanninKuva = LoadImage("Hanni"); 
    12     //Image HoonKuva = LoadImage("Hoo"); 
     11     Image HanninKuva = LoadImage("Hanni"); 
     12     Image HoonKuva = LoadImage("Hoo"); 
    1313 
    1414    AssaultRifle HanninAse; 
    1515 
     16    AssaultRifle HoonAse; 
    1617     
    17     PhysicsObject Hanni; 
     18 
     19     
     20    PlatformCharacter Hanni; 
    1821    PhysicsObject Hoo; 
    1922     
    2023    public override void Begin() 
    2124    { 
     25        LuoKentta(); 
    2226        LuoNappaimet(); 
    2327        LuoPelaajat(); 
    24         //AmmuAseella(); 
    25          
    26          
     28 
     29        AmmuAseella(HanninAse); 
     30 
     31 
    2732 
    2833 
     
    3439    { 
    3540 
    36         Hanni = new PhysicsObject(80.0, 80.0); 
     41        Hanni = new PlatformCharacter(80.0, 80.0); 
    3742        Hanni.X = Level.Left + 20.0; 
    3843        Hanni.Y = 0.0; 
    3944        Hanni.Shape = Shape.Circle; 
    4045        Hanni.Color = Color.Blue; 
    41        // Hanni.Image = HanninKuva; 
     46        Hanni.Image = HanninKuva; 
    4247        Hanni.CanRotate = false; 
    4348        Add(Hanni); 
    44         HanninAse = new AssaultRifle(30, 10); 
     49        HanninAse = new AssaultRifle(60, 20); 
    4550        HanninAse.ProjectileCollision = AmmusOsui; 
    46         HanninAse.X = Hanni.Position.X + 550; 
     51        HanninAse.X += 50; 
    4752        Hanni.Add(HanninAse); 
    48         HanninAse.Position = Hanni.Position;        
    49          
    50          
    51         Hoo = new PhysicsObject(100.0, 100.0); 
     53 
     54                 
     55        Hoo = new PlatformCharacter (100.0, 100.0); 
    5256        Hoo.X = Level.Right - 20.0; 
    5357        Hoo.Y = 0.0; 
    5458        Hoo.Shape = Shape.Circle; 
    5559        Hoo.Color = Color.Red; 
    56        // Hoo.Image = HoonKuva; 
     60        Hoo.Image = HoonKuva; 
    5761        Hoo.CanRotate = false; 
    5862        Add(Hoo); 
     63        HoonAse = new AssaultRifle(90, 30); 
     64        HoonAse.ProjectileCollision = AmmusOsui; 
     65        HoonAse.X += 50; 
     66        HoonAse.Y -= 10; 
     67        Hoo.Add(HoonAse); 
    5968    } 
    6069 
    6170    void AmmusOsui(PhysicsObject Ammus, PhysicsObject Kohde) 
    6271    { 
     72        //Ammus.Destroy, Kohde; 
    6373 
    6474    } 
    6575    void LuoNappaimet() 
    6676    { 
    67         Keyboard.Listen(Key.W, ButtonState.Down, LiikutaHannia, null, new Vector(0, 500)); 
    68         Keyboard.Listen(Key.W, ButtonState.Released, LiikutaHannia, null, new Vector(0, 0)); 
    69         Keyboard.Listen(Key.D, ButtonState.Down, LiikutaHannia, null, new Vector(100.0, 0.0)); 
     77        Keyboard.Listen(Key.W, ButtonState.Pressed, LiikutaHannia, null, new Vector(0, 700)); 
     78        Keyboard.Listen(Key.D, ButtonState.Down, LiikutaHannia, null, new Vector(500.0, 0.0)); 
    7079        Keyboard.Listen(Key.D, ButtonState.Released, LiikutaHannia, null, new Vector(0, 0)); 
    71         Keyboard.Listen(Key.A, ButtonState.Down, LiikutaHannia, null, new Vector(-100, 0)); 
     80        Keyboard.Listen(Key.A, ButtonState.Down, LiikutaHannia, null, new Vector(-500, 0)); 
    7281        Keyboard.Listen(Key.A, ButtonState.Released, LiikutaHannia, null, new Vector(0, 0)); 
    73         
     82 
     83 
     84        Keyboard.Listen(Key.Up, ButtonState.Pressed, LiikutaHoota, null, new Vector(0, 700)); 
     85        Keyboard.Listen(Key.Right, ButtonState.Down, LiikutaHoota, null, new Vector(500.0, 0.0)); 
     86        Keyboard.Listen(Key.Right, ButtonState.Released, LiikutaHoota, null, new Vector(0, 0)); 
     87        Keyboard.Listen(Key.Left, ButtonState.Down, LiikutaHoota, null, new Vector(-500, 0)); 
     88        Keyboard.Listen(Key.Left, ButtonState.Released, LiikutaHoota, null, new Vector(0, 0)); 
     89 
    7490 
    7591 
     
    7995    void LuoKentta() 
    8096    { 
     97        Gravity = new Vector(0.0, -800.0); 
     98 
    8199         
    82         Level.CreateBorders(); 
     100        PhysicsObject AlaReuna = Level.CreateBottomBorder(0.0, false); 
     101        PhysicsObject OikeaReuna = Level.CreateRightBorder(0.0, false); 
     102        PhysicsObject VasenReuna = Level.CreateLeftBorder(0.0, false); 
     103 
     104         
     105         
    83106 
    84107         
     
    90113    { 
    91114        Hanni.Velocity = (vektori); 
     115         
    92116 
     117    } 
     118    void LiikutaHoota(Vector vektori) 
     119    { 
     120        Hoo.Velocity = (vektori); 
    93121    } 
    94122 
    95123    void AmmuAseella(AssaultRifle HanninAse) 
    96124    { 
    97         PhysicsObject ammus = HanninAse.Shoot(); 
    98         Keyboard.Listen(Key.Space, ButtonState.Down, AmmuAseella, "Ammu", HanninAse); 
     125        PhysicsObject Ammus = HanninAse.Shoot(); 
     126        Keyboard.Listen(Key.Space, ButtonState.Pressed, AmmuAseella, "Ammu", HanninAse); 
    99127 
    100         if (ammus != null) 
     128        if (Ammus != null) 
    101129        { 
    102             ammus.Size *= 3; 
    103             ammus.MaximumLifetime = TimeSpan.FromSeconds(2.0); 
     130            Ammus.Size *= 3; 
     131            Ammus.MaximumLifetime = TimeSpan.FromSeconds(2.0); 
    104132 
    105133        } 
Note: See TracChangeset for help on using the changeset viewer.