示例#1
0
    static int              frameCount; // counter for decreasing time

    /// <summary>
    /// Initializes game and loads unmanaged resources
    /// </summary>
    public static void Init()
    {
        Lives      = 5;
        Time       = 255;
        Coins      = 0;
        Score      = 0;
        frameCount = 0;

        Actor.CreateList(40);

        HUD.Init();
        HUD.ShowLives(Lives);
        HUD.ShowTime(Time);
        HUD.ShowCoins(Coins);
        HUD.ShowScore(Score);

        world   = new World("smw_foreground.tmx", "smw_background.tmx");
        objects = Spriteset.FromFile("Objects");
        player  = new Player("SuperMario", 0, 16, 16);
    }
示例#2
0
    /// <summary>
    /// Constructor
    /// </summary>
    /// <param name="name">Base name of the spriteset (png/txt pair)</param>
    /// <param name="index">Sprite index</param>
    /// <param name="x">Initial x coordinate in world space</param>
    /// <param name="y">Initial y coordinate in world space</param>
    public Player(string name, int index, int x, int y)
    {
        this.x = x;
        this.y = y;

        flags     = TileFlags.None;
        spriteset = Spriteset.FromFile(name);
        sprite    = Graphics.Engine.Sprites[index];
        sprite.Setup(spriteset, flags);
        orientation = Orientation.Right;
        jumping     = false;
        floor       = true;
        x_fix       = Fixed.Set(x);
        y_fix       = Fixed.Set(y);
        state       = State.Stand;

        SpriteInfo info;

        spriteset.GetInfo(0, out info);
        width  = info.W;
        height = info.H;
    }