Changeset 7464 for 2016/25


Ignore:
Timestamp:
2016-06-19 15:47:43 (7 years ago)
Author:
koannak
Message:
 
Location:
2016/25/PetteriR/Pang
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • 2016/25/PetteriR/Pang/Pang/Pang/Pang.cs

    r7451 r7464  
    11using System; 
    22using System.Collections.Generic; 
     3using System.Linq; 
     4using System.Text; 
    35using Jypeli; 
    46using Jypeli.Assets; 
     
    911public class Pang : PhysicsGame 
    1012{ 
     13 
     14    PhysicsObject pallo; 
     15 
    1116    public override void Begin() 
    1217    { 
    13         // TODO: Kirjoita ohjelmakoodisi tähän 
    14         PhysicsObject pallo = new PhysicsObject(50, 50); 
     18        LuoKentta(); 
     19        AloitaPeli(); 
     20 
     21         Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli"); 
     22    } 
     23 
     24    void LuoKentta() 
     25    { 
     26        pallo = new PhysicsObject(40.0, 40.0); 
    1527        pallo.Shape = Shape.Circle; 
    16         pallo.Color = Color.Gold; 
    17         Add(pallo); 
    1828        pallo.X = -200.0; 
    1929        pallo.Y = 0.0; 
     30        pallo.Restitution = 1.0; 
     31        Add(pallo); 
     32 
     33        LuoMaila(Level.Left + 20.0, 0.0); 
     34        LuoMaila(Level.Right - 20.0, 0.0); 
     35 
     36        Level.CreateBorders(1.0, false); 
     37        Level.Background.Color = Color.Black; 
     38 
     39        Camera.ZoomToLevel(); 
     40    } 
     41 
     42    void AloitaPeli() 
     43    { 
    2044        Vector impulssi = new Vector(500.0, 0.0); 
    21         Level.Background.CreateGradient(Color.Black, Color.Blue); 
    22         Level.CreateBorders(); 
     45        pallo.Hit(impulssi); 
     46    } 
    2347 
    24  
    25  
    26  
    27         Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli"); 
    28  
     48    void LuoMaila(double x, double y) 
     49    { 
     50        PhysicsObject maila = PhysicsObject.CreateStaticObject(20.0, 100.0); 
     51        maila.Shape = Shape.Rectangle; 
     52        maila.X = x; 
     53        maila.Y = y; 
     54        maila.Restitution = 1.0; 
     55        Add(maila); 
    2956    } 
    3057} 
Note: See TracChangeset for help on using the changeset viewer.