Changeset 7195


Ignore:
Timestamp:
2016-06-07 16:48:44 (3 years ago)
Author:
empaheik
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • 2016/23/ohjaajat/Punasininen/Punasininen/Punasininen/Punasininen.cs

    r7189 r7195  
    1111    private const double SPEED = 450; 
    1212    private const double JUMPSPEED = 1250; 
    13     private const int RUUDUN_KOKO = 40; 
     13    private const int TILE_SIZE = 40; 
    1414 
    1515    private Player blue; 
     
    2222    { 
    2323        //Gravity = new Vector(0, -1000); 
    24  
    2524        CreateLevel(); 
    2625        AddControls(); 
    27  
    2826    } 
    2927 
     
    3230        Gravity = new Vector(0, -1000); 
    3331 
     32        IsFullScreen = true; 
     33 
    3434        ColorTileMap map = ColorTileMap.FromLevelAsset("dungeon1"); 
    3535        map.SetTileMethod(Color.Black, LisaaTaso); 
    36         map.SetTileMethod(Color.FromHexCode("#FF0026FF"), delegate(Vector paikka, double leveys, double korkeus) { blue = CreatePlayer(paikka, leveys, korkeus, bluepic, Color.Blue); }); 
    37         map.SetTileMethod(Color.Red, delegate(Vector paikka, double leveys, double korkeus) { red = CreatePlayer(paikka, leveys, korkeus, redpic, Color.Red); }); 
    38         map.Execute(RUUDUN_KOKO, RUUDUN_KOKO); 
     36        map.SetTileMethod(Color.FromHexCode("#FF0026FF"), delegate(Vector paikka, double leveys, double korkeus) { blue = CreatePlayer(paikka, leveys, korkeus, bluepic, Color.Blue, new Vector(-Screen.Width / 2 + 50, Screen.Height / 2 - 50)); }); 
     37        map.SetTileMethod(Color.Red, delegate(Vector paikka, double leveys, double korkeus) { red = CreatePlayer(paikka, leveys, korkeus, redpic, Color.Red, new Vector(Screen.Width / 2 - 50, Screen.Height / 2 - 50)); }); 
     38        map.Execute(TILE_SIZE, TILE_SIZE); 
    3939 
    4040        Camera.ZoomToAllObjects(); 
    4141 
    4242        Level.Background.Color = Color.Black; 
    43  
    4443    } 
    4544 
    4645    void LisaaTaso(Vector paikka, double leveys, double korkeus) 
    4746    { 
    48         PhysicsObject taso = PhysicsObject.CreateStaticObject(leveys, korkeus); 
    49         taso.Position = paikka; 
    50         taso.Color = Color.Black; 
    51         AddCollisionHandler(taso, "player", Varjaa); 
    52         Add(taso); 
     47        PhysicsObject platform = PhysicsObject.CreateStaticObject(leveys, korkeus); 
     48        platform.Position = paikka; 
     49        platform.Color = Color.Black; 
     50        platform.Tag = "platform"; 
     51        Add(platform); 
    5352    } 
    5453 
    55     Player CreatePlayer(Vector paikka, double leveys, double korkeus, Image playerspic, Color playersColor) 
     54    Player CreatePlayer(Vector paikka, double leveys, double korkeus, Image playerspic, Color playersColor, Vector trackerPosition) 
    5655    { 
    5756        Player player = new Player(leveys, korkeus, playerspic, playersColor); 
    5857        player.Position = paikka; 
    5958        Add(player); 
     59 
     60        Label percentageLabel = new Label() { TextColor = playersColor, DecimalPlaces = 1, Position = trackerPosition}; 
     61        Add(percentageLabel); 
     62 
     63        DoubleMeter percentageTracker = new DoubleMeter(0, 0, 100); 
     64        percentageLabel.BindTo(percentageTracker); 
     65 
     66        AddCollisionHandler(player, "platform", delegate(PhysicsObject a, PhysicsObject b) 
     67        { 
     68            ColorTile(a, b, percentageTracker); 
     69        }); 
     70 
    6071        return player; 
    6172 
    6273    } 
    6374 
    64     void Varjaa(PhysicsObject platform, PhysicsObject player) 
     75    void ColorTile(PhysicsObject player, PhysicsObject platform, DoubleMeter tracker) 
    6576    { 
    66         platform.Color = player.Color;  
     77        platform.Color = player.Color; 
     78 
     79        tracker.Value = (double)GetObjects(o => o.Color == player.Color && (String)o.Tag == "platform").Count / GetObjectsWithTag("platform").Count * 100.0; 
    6780    } 
    6881 
     
    8598    void Move(AnalogState stick, Player player) 
    8699    { 
    87         /*Vector state = stick.StateVector; 
    88         player.Walk(state.X * 500);*/ 
     100        //player.Walk(stick.StateVector.X * 500); 
    89101         
    90102        if (stick.StateVector.Magnitude > 0.15) 
Note: See TracChangeset for help on using the changeset viewer.