/// <summary>
    /// Constructs the pane with all the sprites.
    /// </summary>
    public DemoSpriteSimple()
    {
        // Create the basics
        sprites = new SpriteList();
        viewport = new SpriteViewport(sprites);
        viewport.BackgroundColor = new Color(0, 0, 50);

        // Load in a basic sprite
        IDrawable drawable = DemoSprites.PixbufFactory.Create("blue-sphere");
        sprite = new DrawableSprite(drawable);
        sprite.X = 10;
        sprite.Y = 10;
        sprite.Width = sprite.Height = 64;
        sprites.Add(sprite);

        // Load the second sprite
        drawable = DemoSprites.PixbufFactory.Create("green-sphere");
        sprite2 = new DrawableSprite(drawable);
        sprite2.X = 10;
        sprite2.Y = 300;
        sprite2.Width = sprite2.Height = 128;
        sprites.Add(sprite2);

        // Load in just a red sphere
        drawable = DemoSprites.TilesetFactory.Create("red-sphere");
        ISprite s = new DrawableSprite(drawable);
        s.X = 400;
        s.Y = 10;
        s.Width = s.Height = 256;
        sprites.Add(s);
    }
    /// <summary>
    /// Constructs the pane with all the sprites.
    /// </summary>
    public DemoSpriteMoving()
    {
        // Create the basics
        sprites = new SpriteList();
        viewport = new SpriteViewport(sprites);
        viewport.BackgroundColor = new Color(0, 0, 50);

        // Load in the static green sphere
        IDrawable drawable = DemoSprites.TilesetFactory.Create("red-sphere");
        DrawableSprite sprite1 = new DrawableSprite(drawable);
        sprite = new MovingSprite(sprite1);
        sprite.StoppedMoving += OnStoppedMoving;
        sprite.Height = sprite.Width = 64;
        sprite.X = sprite.Y = 10;
        sprites.Add(sprite);

        // Create the target
        drawable = DemoSprites.TilesetFactory.Create("green-sphere");
        target = new DrawableSprite(drawable);
        target.Height = target.Width = 32;
        sprites.Add(target);

        // Load in the static green sphere
        drawable = DemoSprites.TilesetFactory.Create("red-sphere2");
        DrawableSprite sprite2a = new DrawableSprite(drawable);
        sprite2 = new MovingSprite(sprite2a);
        sprite2.Height = sprite2.Width = 64;
        sprite2.X = sprite2.Y = 10;
        sprites.Add(sprite2);

        // Create the target
        drawable = DemoSprites.TilesetFactory.Create("green-sphere");
        target2 = new DrawableSprite(drawable);
        target2.Height = target2.Width = 32;
        sprites.Add(target2);
        sprite2.DesiredX = Entropy.Next(0, viewport.Width - sprite.Width);
        sprite2.DesiredY = Entropy.Next(0, viewport.Height - sprite.Height);
        target2.X = sprite2.DesiredX + 16;
        target2.Y = sprite2.DesiredY + 16;

        // Start our timer
        Timeout.Add(1000, OnNewLocation2);
    }
    /// <summary>
    /// Constructs the pane with all the sprites.
    /// </summary>
    public DemoSpriteTileset()
    {
        // Create the basics
        sprites = new SpriteList();
        viewport = new SpriteViewport(sprites);
        viewport.BackgroundColor = new Color(0, 0, 50);

        // Load in the static green sphere
        IDrawable drawable = DemoSprites.TilesetFactory.Create("green-sphere");
        DrawableSprite sprite = new DrawableSprite(drawable);
        sprite.Height = sprite.Width = 64;
        sprite.X = sprite.Y = 10;
        sprites.Add(sprite);

        // Load in the animated red sphere
        int rows = 6;
        int cols = 6;

        for (int i = 0; i < cols; i++)
        {
            for (int j = 0; j < rows; j++)
            {
                if (i == j)
                {
                    drawable = DemoSprites.TilesetFactory.Create("red-sphere2");
                }
                else
                {
                    drawable = DemoSprites.TilesetFactory.Create("red-sphere");
                }

                sprite = new DrawableSprite(drawable);
                sprite.Height = sprite.Width = 64;
                sprite.X = 100 + i * 100;
                sprite.Y = 10 + j * 100;
                sprite.Randomize();
                sprites.Add(sprite);
            }
        }
    }
Exemple #4
0
    /// <summary>
    /// Main entry point into the system.
    /// </summary>
    public static void Main(string[] args)
    {
        // Set up Gtk
        Application.Init();

        // Load in the tileset
        // Create the demo
        ViewerEntry demo = new ViewerEntry();
        Viewer.TilesetFactory.Load(new FileInfo(args[0]));

        // Load the sprite
        IDrawable drawable = Viewer.TilesetFactory.Create(args[1]);
        DrawableSprite sprite = new DrawableSprite(drawable);
        sprite.Height = sprite.Width = 64;
        sprite.X = sprite.Y = 10;
        sprite.Randomize();
        Viewer.Sprites.Add(sprite);
        Viewer.Sprite = sprite;

        // Start everything running
        demo.ShowAll();
        Application.Run();
    }
Exemple #5
0
        /// <summary>
        /// Adds the game over screen sprites.
        /// </summary>
        private void AddGameOver()
        {
            // TODO should be a sprite scene builder
            IDrawable drawable = Game.Theme.DrawableFactory.Create("game-over");
            DrawableSprite ds = new DrawableSprite(drawable);
            ds.X = ds.Y = 0;
            ds.Width = viewport.Width;
            ds.Height = viewport.Height;
            sprites.Add(ds);

            // Queue the redraw
            QueueDraw();

            // Do the high score processing
            HighScoreTable hst = Game.HighScores.GetTable(Game.Config);

            if (hst.IsHighScore(Game.Score))
            {
                // We need to get the username
                UserNameDialog dialog = new UserNameDialog();
                dialog.Run();
                dialog.Destroy();

                // Register it
                hst.RegisterScores(Game.Config.UserName, Game.Score);
            }

            // Show the high score
            HighScoreWindow hsw = new HighScoreWindow();
            hsw.ShowAll();
        }