Changeset 6196 for 2015/26/ohjaajat


Ignore:
Timestamp:
2015-06-23 17:34:50 (4 years ago)
Author:
empaheik
Message:

Jäsentelyä + voisi kyllä laittaa menun alussa kommentteihin koska debug.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 2015/26/ohjaajat/HillbillyRun/HillbillyRun/HillbillyRun/HillbillyRun/HillbillyRun.cs

    r6161 r6196  
    3333    private double cameraSpeed = 2.0; // Kameran liikkumisnopeus. 
    3434 
    35     private Image groundImage = LoadImage("ground"); 
    36     private Image groundTopImage = LoadImage("ground_top"); 
     35    # region Images 
     36    private Image[] groundImages = LoadImages("ground");    //Näitä ei tosin kaikkia kenties jaksa tehdä erilaisiksi levelistä riippuen 
     37    private Image[] groundTopImages = LoadImages("ground_top"); 
     38    private Image[] supportStructureImages = LoadImages(""); 
    3739 
    3840    private Image cartImage = LoadImage("cart"); 
    3941    private Image cartWheelImage = LoadImage("cartwheel"); 
     42    #endregion  
     43 
     44    private int levelNumber = 0; 
    4045 
    4146    public override void Begin() 
     
    105110 
    106111        CreateLevel(); 
    107         Extras(); 
    108  
    109         Camera.X = cameraTargetX = players[0].X; 
    110  
    111         Timer cameraTimer = new Timer(); 
    112         cameraTimer.Interval = 1 / 30.0; 
    113         cameraTimer.Timeout += UpdateCamera; 
    114         cameraTimer.Start(); 
     112        ScreenSettings(); 
    115113 
    116114        // Testailen tässä kärryn luomista. 
     
    131129    } 
    132130 
    133     void Extras() 
    134     { 
    135         Gravity = new Vector(0, -1000); 
     131    void ScreenSettings() 
     132    { 
    136133        Window.Width = 1800; 
    137134        Window.Height = 900; 
     135 
     136        Camera.X = cameraTargetX = players[0].X; 
     137 
     138        Timer cameraTimer = new Timer(); 
     139        cameraTimer.Interval = 1 / 30.0; 
     140        cameraTimer.Timeout += UpdateCamera; 
     141        cameraTimer.Start(); 
    138142    } 
    139143 
    140144    void CreateLevel() 
    141145    { 
    142         TileMap level = TileMap.FromLevelAsset("level1"); 
     146        Gravity = new Vector(0, -1000); 
     147 
     148        TileMap level = TileMap.FromLevelAsset("level" + levelNumber); 
    143149        level.SetTileMethod('P', CreatePlayer); 
    144150        level.SetTileMethod('#', CreateGroundTop); 
     
    171177        // Maanpinnan näkyvä osa. 
    172178        GameObject visibleGround = new GameObject(width, height); 
    173         visibleGround.Image = groundImage; 
     179        visibleGround.Image = groundImages[levelNumber]; 
    174180        visibleGround.Position = position; 
    175181        visibleGround.TextureWrapSize = new Vector(width / TILE_SIZE, height / TILE_SIZE); 
     
    180186    { 
    181187        GameObject ground = new GameObject(width, height); 
    182         ground.Image = groundTopImage; 
     188        ground.Image = groundTopImages[levelNumber]; 
    183189        ground.Position = position; 
    184190        ground.TextureWrapSize = new Vector(width / TILE_SIZE, height / TILE_SIZE); 
     
    195201        Keyboard.Listen(Key.Right, ButtonState.Down, delegate { players[1].Walk(300); }, "Player 2 moves right"); 
    196202        Keyboard.Listen(Key.Up, ButtonState.Down, delegate { players[1].Jump(1000); }, "Player 2 jumps"); 
    197  
    198         //Keyboard.Listen(Key.A, ButtonState.Down, delegate { players[0].Walk(Direction.Left); }, "Player 1 moves left"); 
    199         //Keyboard.Listen(Key.D, ButtonState.Down, delegate {players[0].Walk(Direction.Right);}, "Player 1 moves right"); 
    200         //Keyboard.Listen(Key.W, ButtonState.Down, delegate{players[0].Jump(1000);}, "Player 1 jumps"); 
    201  
    202         //Keyboard.Listen(Key.Left, ButtonState.Down, delegate { players[1].Walk(Direction.Left); }, "Player 2 moves left"); 
    203         //Keyboard.Listen(Key.Right, ButtonState.Down, delegate { players[1].Walk(Direction.Right); }, "Player 2 moves right"); 
    204         //Keyboard.Listen(Key.Up, ButtonState.Down, delegate { players[1].Jump(1000); }, "Player 2 jumps"); 
    205203 
    206204        Keyboard.Listen(Key.F1, ButtonState.Pressed, ShowControlHelp, "Show help"); 
Note: See TracChangeset for help on using the changeset viewer.