Changeset 2951


Ignore:
Timestamp:
2012-06-12 14:38:00 (11 years ago)
Author:
matvirkk
Message:

Talletus.

Location:
2012/24/MattiV
Files:
11 added
1 edited

Legend:

Unmodified
Added
Removed
  • 2012/24/MattiV/Space Battle/Space Battle/Space Battle/Space_Battle.cs

    r2945 r2951  
    99public class Space_Battle : PhysicsGame 
    1010{ 
     11    PhysicsObject alus1; 
     12    PhysicsObject alus2; 
     13    Vector nopeusYlos = new Vector(0, 200); 
     14    Vector nopeusAlas = new Vector(0, -200); 
     15    double Pyoriminen = 5.0; 
    1116    public override void Begin() 
    1217    { 
    13         // TODO: Kirjoita ohjelmakoodisi tähän 
     18        Alukset(); 
     19        AsetaOhjaimet(); 
     20         
     21         
    1422 
     23 
     24    } 
     25    void AsetaOhjaimet() 
     26    { 
     27        Keyboard.Listen(Key.W, ButtonState.Down, AsetaNopeus, "Pelaaja 1: Liikuta mailaa ylös", alus1, nopeusYlos); 
     28        Keyboard.Listen(Key.W, ButtonState.Released, AsetaNopeus, null, alus1, Vector.Zero); 
     29        Keyboard.Listen(Key.S, ButtonState.Down, AsetaNopeus, "Pelaaja 1: Liikuta mailaa alas", alus1, nopeusAlas); 
     30        Keyboard.Listen(Key.S, ButtonState.Released, AsetaNopeus, null, alus1, Vector.Zero); 
     31        Keyboard.Listen(Key.D, ButtonState.Down, Kaanto, "Pelaaja 1: Liikuta mailaa ", alus1, -Pyoriminen); 
     32        Keyboard.Listen(Key.D, ButtonState.Released, Kaanto, null, alus1, 0.0); 
     33        Keyboard.Listen(Key.A, ButtonState.Down, Kaanto, "Pelaaja 1: Liikuta mailaa alas", alus1, Pyoriminen); 
     34        Keyboard.Listen(Key.A, ButtonState.Released, Kaanto, null, alus1, 0.0); 
     35          
     36        Keyboard.Listen(Key.Up, ButtonState.Down, AsetaNopeus, "Pelaaja 2: Liikuta mailaa ylös", alus2, nopeusYlos); 
     37        Keyboard.Listen(Key.Up, ButtonState.Released, AsetaNopeus, null, alus2, Vector.Zero); 
     38        Keyboard.Listen(Key.Down, ButtonState.Down, AsetaNopeus, "Pelaaja 2: Liikuta mailaa alas", alus2, nopeusAlas); 
     39        Keyboard.Listen(Key.Down, ButtonState.Released, AsetaNopeus, null, alus2, Vector.Zero); 
     40        Keyboard.Listen(Key.Right, ButtonState.Down, Kaanto, "Pelaaja 2: Liikuta mailaa ylös", alus2, -Pyoriminen); 
     41        Keyboard.Listen(Key.Right, ButtonState.Released, Kaanto, null, alus2, 0.0); 
     42        Keyboard.Listen(Key.Left, ButtonState.Down, Kaanto, "Pelaaja 2: Liikuta mailaa alas", alus2, Pyoriminen); 
     43        Keyboard.Listen(Key.Left, ButtonState.Released, Kaanto, null, alus2, 0.0); 
     44        
    1545        PhoneBackButton.Listen(ConfirmExit, "Lopeta peli"); 
    1646        Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli"); 
    1747    } 
     48    void AsetaNopeus(PhysicsObject alus, Vector nopeus) 
     49    { 
     50        alus.Push(Vector.FromLengthAndAngle(100, alus.Angle)); 
     51    } 
     52    void Kaanto(PhysicsObject alus, double Pyoriminen) 
     53    { 
     54        alus.AngularVelocity = Pyoriminen; 
     55 
     56    } 
     57 
     58 
     59    void Alukset() 
     60    { 
     61         alus1 = new PhysicsObject(20, 30); 
     62        alus1.Shape = Shape.Triangle; 
     63        alus1.Color = Color.DarkBlue; 
     64        alus1.X = -400; 
     65        alus1.Y = -300; 
     66        alus1.Restitution = 1.0; 
     67 
     68        Add(alus1); 
     69 
     70         alus2 = new PhysicsObject(20, 30); 
     71        alus2.Shape = Shape.Triangle; 
     72        alus2.Color = Color.DarkRed; 
     73        alus2.X = 400; 
     74        alus2.Y = 300; 
     75        alus2.Restitution = 1.0; 
     76 
     77        Add(alus2); 
     78        Level.CreateBorders(1.0, false); 
     79        Camera.ZoomToLevel(); 
     80     
     81 
     82 
     83 
     84 
     85 
     86 
     87 
     88 
     89 
     90 
     91 
     92 
     93 
     94 
     95 
     96 
     97 
     98 
     99 
     100 
     101 
     102 
     103 
     104 
     105 
     106 
     107 
     108 
     109 
     110 
     111 
     112 
     113 
     114 
     115 
     116 
     117 
     118 
     119 
     120 
     121 
     122 
     123 
     124 
     125 
     126 
     127 
     128 
     129 
     130 
     131 
     132 
     133 
     134 
     135 
     136 
     137 
     138 
     139 
     140 
     141 
     142 
     143 
     144 
     145 
     146 
     147 
     148 
     149 
     150 
     151 
     152 
     153 
     154 
     155 
     156 
     157    } 
     158 
     159 
     160 
     161 
    18162} 
Note: See TracChangeset for help on using the changeset viewer.