Ignore:
Timestamp:
2014-07-01 13:37:29 (7 years ago)
Author:
mijoilmo
Message:

vähän kaikkea
player omassa luokassansa

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 2014/27/AleksanteriV/Protokolla236TrueSurvivor/Protokolla236TrueSurvivor/Protokolla236TrueSurvivor/Protokolla236TrueSurvivor.cs

    r5218 r5224  
    77using Jypeli.Widgets; 
    88 
     9 
     10 
    911public class Proto236b : PhysicsGame //true survivor 
    1012{ 
    11     Image[] images = new Image[1]; 
     13    Player player; 
     14    static public Dictionary<string, Image> images = new Dictionary<string, Image>(); 
    1215    void AssignKeys() 
    1316    { 
    1417        Keyboard.Listen(Key.Escape, ButtonState.Down, Exit, "Lopeta Peli"); 
     18        Keyboard.Listen(Key.Up, ButtonState.Down, player.throttle, "Lento"); 
    1519    } 
    1620    void LoadAllImages() 
    1721    { 
    18         images[0] = LoadImage("graphics/backgrounds/space_background"); 
     22        images["background0"] = LoadImage("graphics/backgrounds/space_background"); 
     23        images["player"] = LoadImage("graphics/ships/player"); 
     24        images["tile0"] = LoadImage("graphics/tiles/tile0.png"); 
    1925    } 
    2026    void LoadLevel(int level) 
    2127    { 
    2228        ClearAll(); 
     29        Add(this.player); 
    2330        AssignKeys(); 
    2431        LevelFromImage("graphics/levels/" + level); 
     
    2734    { 
    2835        ColorTileMap tileMap = ColorTileMap.FromLevelAsset(levelName); 
    29         tileMap.SetTileMethod(Color.FromHexCode("000000"), createTile, "seina"); 
    30         tileMap.Execute(); 
     36        tileMap.SetTileMethod(Color.FromHexCode("000000"), createTile, ""); 
     37        tileMap.SetTileMethod(Color.FromHexCode("ff0000"), spawnPlayer); 
     38        tileMap.Execute(20,20); 
    3139    } 
    32     void createTile(Vector position, double w, double h, string type) 
     40    void createTile(Vector position, double w, double h, string id) 
    3341    { 
    34  
     42        MikonPhysicsObject tile = new MikonPhysicsObject(this, w, h); 
     43        tile.MakeStatic(); 
     44        tile.Position = position; 
     45        if (id != "") 
     46        { 
     47            tile.Image = images[id]; 
     48        } 
     49        Add(tile); 
     50    } 
     51    void spawnPlayer(Vector position, double w, double h) 
     52    { 
     53        player.Position = position; 
    3554    } 
    3655    public override void Begin() 
     
    3857        // TODO: Kirjoita peli tähän 
    3958        LoadAllImages(); 
     59        this.player = new Player(); 
    4060        LoadLevel(0); 
    4161    } 
Note: See TracChangeset for help on using the changeset viewer.