Changeset 2349 for 2011/26


Ignore:
Timestamp:
2011-06-30 12:44:17 (12 years ago)
Author:
jaollipa
Message:
 
Location:
2011/26/JaakkoL/Rogue Agent 2372/Rogue Agent 2372/Rogue Agent 2372
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • 2011/26/JaakkoL/Rogue Agent 2372/Rogue Agent 2372/Rogue Agent 2372/Peli.cs

    r2348 r2349  
    99public class Peli : PhysicsGame 
    1010{ 
     11    List<Label> titleMenu; 
    1112    const int SCREEN_WIDTH = 50; 
    1213    const int SCREEN_HEIGTH = 50; 
    1314    Player player; 
    1415    Image background1 = LoadImage("Images/reactorBG"); 
    15     List<Label> titleMenu; 
     16 
    1617 
    1718    public override void Begin() 
    1819    { 
     20        menuCreate(); 
     21         
     22    } 
     23 
     24    void menuCreate() 
     25    { 
     26        ClearAll(); 
     27        titleMenu = new List<Label>(); 
     28 
     29        Label button1 = new Label("Start Game"); 
     30        button1.Position = new Vector(0, 40); 
     31        titleMenu.Add(button1); 
     32 
     33        Label button2 = new Label("Exit Game"); 
     34        button2.Position = new Vector(0, -40); 
     35        titleMenu.Add(button2); 
     36 
     37        foreach (Label titleMenuScreen in titleMenu) 
     38        { 
     39            Add(titleMenuScreen); 
     40        } 
     41 
     42        Mouse.ListenOn(button1, MouseButton.Left, ButtonState.Pressed, StartGame, null); 
     43        Mouse.ListenOn(button2, MouseButton.Left, ButtonState.Pressed, Exit, null); 
     44 
     45        Mouse.IsCursorVisible = true; 
     46        Mouse.ListenMovement(1.0, MenuMovement, null); 
     47        Keyboard.Listen(Key.Escape, ButtonState.Pressed, Exit, ""); 
     48    } 
     49 
     50    void MenuMovement(AnalogState mouseState) 
     51    { 
     52        foreach (Label button in titleMenu) 
     53        { 
     54            if (Mouse.IsCursorOn(button)) 
     55            { 
     56                button.TextColor = Color.DarkRed; 
     57            } 
     58            else 
     59            { 
     60                button.TextColor = Color.DarkBlue; 
     61            } 
     62        } 
     63    } 
     64 
     65    void StartGame() 
     66    { 
     67        ClearAll(); 
     68        createLevel(); 
    1969        Gravity = new Vector(0, -1000); 
    20         createLevel(); 
    21         menuCreate(); 
    2270 
    2371        // Starts playing the background music, which is set to repeat 
     
    3179    } 
    3280 
    33  
    34     // Creates the level from a text file 
    3581    void createLevel() 
    3682    { 
     
    60106    { 
    61107        PhysicsObject hBlock = PhysicsObject.CreateStaticObject(SCREEN_WIDTH, SCREEN_HEIGTH, 
    62             Shape.Rectangle, CollisionShapeQuality.Best); 
     108        Shape.Rectangle, CollisionShapeQuality.Best); 
    63109        hBlock.Color = Color.Gray; 
    64110        return hBlock; 
     
    68114    { 
    69115        PhysicsObject vBlock = PhysicsObject.CreateStaticObject(SCREEN_WIDTH, SCREEN_HEIGTH, 
    70             Shape.Rectangle, CollisionShapeQuality.Best); 
     116        Shape.Rectangle, CollisionShapeQuality.Best); 
    71117        vBlock.Color = Color.DarkGray; 
    72118        return vBlock; 
    73119    } 
    74  
    75     void menuCreate() 
    76     { 
    77  
    78     } 
    79120} 
  • 2011/26/JaakkoL/Rogue Agent 2372/Rogue Agent 2372/Rogue Agent 2372/Player.cs

    r2348 r2349  
    3737 
    3838        // Collision handlers for enemies 
    39         AddCollisionHandler(); 
     39        // AddCollisionHandler(); 
    4040        } 
    4141 
Note: See TracChangeset for help on using the changeset viewer.