Changeset 7210 for 2016/23/ohjaajat


Ignore:
Timestamp:
2016-06-08 15:05:22 (3 years ago)
Author:
sieerinn
Message:

Kentän alareunaa aloitettu

Location:
2016/23/ohjaajat/Punasininen/Punasininen
Files:
3 edited

Legend:

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

    r7209 r7210  
    1111    public Weapon Secondary; 
    1212 
     13    public Vector Spawn; 
     14 
    1315    public Player(double leveys, double korkeus, Image pic, Color color) 
    1416        : base(leveys, korkeus) 
  • 2016/23/ohjaajat/Punasininen/Punasininen/Punasininen/Punasininen.cs

    r7209 r7210  
    2626    private Image redpic; 
    2727 
     28    Color blueColor = Color.FromHexCode("FF1D65CF"); 
     29    Color redColor = Color.FromHexCode("FABE1A"); 
     30 
    2831    private Image bluePistolpic = LoadImage("bluegun"); 
    2932    private Image orangePistolpic = LoadImage("orangegun"); 
     
    6063        ColorTileMap map = ColorTileMap.FromLevelAsset("dungeon1"); 
    6164        map.SetTileMethod(Color.Black, AddPlatform); 
    62         map.SetTileMethod(Color.FromHexCode("#FF0026FF"), delegate(Vector paikka, double leveys, double korkeus) { blue = CreatePlayer(paikka, leveys, korkeus, bluepic, Color.Blue);}); 
     65        map.SetTileMethod(Color.FromHexCode("#FF0026FF"), delegate(Vector paikka, double leveys, double korkeus) { blue = CreatePlayer(paikka, leveys, korkeus, bluepic, blueColor);}); 
    6366        map.SetTileMethod(Color.FromHexCode("FFD800"), CreateWeaponCrate); 
    64         map.SetTileMethod(Color.Red, delegate(Vector paikka, double leveys, double korkeus) { red = CreatePlayer(paikka, leveys, korkeus, redpic, Color.Red); }); 
     67        map.SetTileMethod(Color.Red, delegate(Vector paikka, double leveys, double korkeus) { red = CreatePlayer(paikka, leveys, korkeus, redpic, redColor); }); 
    6568        map.Execute(TILE_SIZE, TILE_SIZE); 
    6669 
    67         Camera.ZoomToAllObjects(); 
     70        Surface bottom = Surface.CreateBottom(Level); 
     71        bottom.Width *= 2; 
     72        bottom.Y -= Level.Height / 2; 
     73        bottom.Tag = "death"; 
     74        Add(bottom); 
     75 
     76        Camera.ZoomToLevel(); 
    6877 
    6978        Level.Background.Color = Color.Black; 
     
    100109        player.AnimIdle = new Animation(new[] { blueWalkImages[0] }); 
    101110        player.Position = paikka; 
     111        player.Spawn = paikka; 
    102112        Add(player); 
    103113 
     
    122132            b.Destroy(); 
    123133        }); 
     134        AddCollisionHandler(player, "death", delegate(PhysicsObject a, PhysicsObject b) 
     135        { 
     136            Restore((Player)a); 
     137        }); 
    124138 
    125139        return player; 
    126140    } 
    127141 
     142    void Restore(Player temp) 
     143    { 
     144        temp.Position = temp.Spawn; 
     145    } 
     146 
    128147    void BulletHitsSomething(PhysicsObject bullet, PhysicsObject target) 
    129148    { 
     
    131150        { 
    132151            // TODO bullet must know its owner 
    133             if (bullet.Color == Color.Blue) 
     152            if (bullet.Color == blueColor) 
    134153            { 
    135154                ColorTile(blue, target); 
    136155            } 
    137             else if (bullet.Color == Color.Red) 
     156            else if (bullet.Color == redColor) 
    138157            { 
    139158                ColorTile(red, target); 
     
    166185    void ColorTile(PhysicsObject player, PhysicsObject platform) 
    167186    { 
    168         var imgs = player.Color == Color.Blue? blueTileImages : orangeTileImages; 
    169         var glowImg = player.Color == Color.Blue ? blueGlow : orangeGlow; 
     187        var imgs = player.Color == blueColor? blueTileImages : orangeTileImages; 
     188        var glowImg = player.Color == blueColor ? blueGlow : orangeGlow; 
    170189        ((Tile)platform).SetColor(imgs, glowImg, player.Color); 
    171190 
     
    209228            if (bullet != null) 
    210229            { 
     230                bullet.Image = null; 
    211231                bullet.Color = player.Color;   
    212232            } 
Note: See TracChangeset for help on using the changeset viewer.