/// <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);
    }
Beispiel #2
0
    /// <summary>
    /// Constructs the sprite drawing area, along with the various
    /// rules needed.
    /// </summary>
    public Viewer()
    {
        // Create the drop-down list
        HBox box = new HBox();

        fps          = new SpinButton(1, 100, 1);
        fps.Value    = DesiredFps;
        fps.Changed += OnFpsChanged;
        showUpdate   = new CheckButton();
        box.PackStart(new Label("FPS"), false, false, 0);
        box.PackStart(fps, false, false, 2);
        box.PackStart(new Label("Show Update"), false, false, 5);
        box.PackStart(showUpdate, false, false, 2);
        box.PackStart(new Label(), true, true, 0);
        PackStart(box, false, false, 2);

        // Create the drawing area and pack it
        area                 = new DrawingArea();
        area.Realized       += OnRealized;
        area.ExposeEvent    += OnExposed;
        area.ConfigureEvent += OnConfigure;
        PackStart(area, true, true, 2);

        // Create the viewport
        Sprites  = new SpriteList();
        viewport = new SpriteViewport(Sprites);

        // Start up a little animation loop
        Timeout.Add(1000 / DesiredFps, OnTick);
    }
Beispiel #3
0
        public Environment()
        {
            // Create the sprite viewports
            sprites = new SpriteViewport [4];

            for (int i = 0; i < 4; i++)
            {
                sprites[i] = new SpriteViewport();
                sprites[i].Point = PointF.Empty;
            }
        }
Beispiel #4
0
        public Environment()
        {
            // Create the sprite viewports
            sprites = new SpriteViewport [4];

            for (int i = 0; i < 4; i++)
            {
                sprites[i]       = new SpriteViewport();
                sprites[i].Point = PointF.Empty;
            }
        }
Beispiel #5
0
    /// <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 DemoSpriteBounce()
    {
        // Create the basics
        sprites  = new SpriteList();
        viewport = new SpriteViewport(sprites);
        viewport.BackgroundColor = new Color(0, 0, 50);

        // Load in a basic drawable
        IDrawable drawable = DemoSprites.PixbufFactory.Create("green-sphere");

        // Create the sprites
        for (int i = 0; i < 20; i++)
        {
            Bounce sprite = new Bounce(drawable);
            sprite.Width = sprite.Height = 64;
            sprites.Add(sprite);
        }
    }
    /// <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);
            }
        }
    }
Beispiel #8
0
        /// <summary>
        /// Constructs the display and sets up the internal widgets.
        /// </summary>
        public Display()
        {
            // Set up our size
            tileSize = 72;
            SetSizeRequest(
                tileSize * Game.Config.BoardSize, tileSize * Game.Config.BoardSize);

            // Create our viewport
            sprites  = new SpriteList();
            viewport = new SpriteViewport(sprites);

            // Set up the events
            ExposeEvent      += OnExposed;
            ConfigureEvent   += OnConfigure;
            ButtonPressEvent += OnButtonPress;
            Events            = EventMask.AllEventsMask;

            // Set up the animation timer
            Timeout.Add(1000 / Game.Config.FramesPerSecond, OnTick);

            log = new Log();
        }
Beispiel #9
0
        /// <summary>
        /// Indicates to the game mode that it is activated.
        /// </summary>
        public void Activate()
        {
            // If we don't have a game state, kick this over to the
            // new game state as an error condition.
            if (Game.State == null)
                Game.GameMode = new NewGameMode();

            // Create the sprite manager
            sprites = new SpriteViewport();
            sprites.IsMouseSensitive = true;
            sprites.ClipContents = true;
            Game.SpriteManager.Add(sprites);

            // Create the board viewport
            blockViewport =
                new BlockViewport(Game.State.Board, AssetLoader.Instance);
            blockViewport.ClipContents = true;
            blockViewport.IsMouseSensitive = true;
            blockViewport.MousePosition = 8;
            blockViewport.FocusPosition = Constants.FocusPosition;
            sprites.Add(blockViewport);

            // Create the top-down vertical explorer
            vertViewport = new VerticalViewport(Game.State.Board);
            vertViewport.Z = 50;
            vertViewport.BackgroundColor = Color.FromArgb(32, Color.Black);
            vertViewport.Padding = 2;
            vertViewport.BlockWidth = vertViewport.BlockHeight = 16;
            vertViewport.MaximumHeight = vertViewport.MinimumHeight = 4;
            vertViewport.Size = vertViewport.Extents.Size;
            vertViewport.Visible = false;
            vertViewport.Opacity = 0.75f;
            sprites.Add(vertViewport);

            // Speeches and overlays
            speeches = new SpriteViewport();
            speeches.Z = 100;
            speeches.IsMouseSensitive = true;
            sprites.Add(speeches);

            // Connect our events for selectors
            blockViewport.StackMouseEnter += OnStackMouseEnter;
            blockViewport.StackMouseExit += OnStackMouseExit;

            // Create the scroller on the viewport
            scroller = new MouseEdgeScroller();
            scroller.Register(blockViewport);

            // Create our selector icon
            selector = AssetLoader.Instance.CreateBlock("Selector");
            selector.Height = 0;
            selector.CastsShadows = false;

            // Create the scores and other indicators
            CreateIndicators();

            // Connect the events
            Game.State.Board.MovingChanged += OnMovingChanged;
            Game.State.Board.BlockMovingChanged += OnBlockMovingChanged;
            Game.State.Board.BlockMovingChanged += Game.Sound.BlockLanded;
        }
Beispiel #10
0
        protected DisplayStatusMinorMode()
        {
            // Create a sprite viewport to handle everything
            sprites = new SpriteViewport();

            // Create the heart and star icons
            heartSprite = AssetLoader.Instance.CreateSprite("Heart");
            sprites.Add(heartSprite);

            heartText           = new TextDrawableSprite(Game.GetFont(FullTextSize));
            heartText.Tint      = Constants.HeartColor;
            heartText.Text      = Game.State.Hearts.ToString();
            heartText.Alignment = ContentAlignment.MiddleLeft;
            sprites.Add(heartText);

            starSprite = AssetLoader.Instance.CreateSprite("Star");
            sprites.Add(starSprite);

            starText           = new TextDrawableSprite(Game.GetFont(FullTextSize));
            starText.Tint      = Constants.StarColor;
            starText.Text      = Game.State.Stars.ToString();
            starText.Alignment = ContentAlignment.MiddleLeft;
            sprites.Add(starText);

            chestSprite = AssetLoader.Instance.CreateSprite(ChestDrawableName);
            sprites.Add(chestSprite);

            chestText           = new TextDrawableSprite(Game.GetFont(FullTextSize));
            chestText.Tint      = Constants.ChestColor;
            chestText.Text      = "0";
            chestText.Alignment = ContentAlignment.MiddleLeft;
            sprites.Add(chestText);

            // Create the viewport
            viewport = new SpriteViewport();
            viewport.ClipContents = true;
            sprites.Add(viewport);

            // Add the text elements
            subtitle = new TextDrawableSprite(
                Game.GetFont(NewFontSize), "");
            subtitle.Tint      = Color.FromArgb(128, Color.White);
            subtitle.Alignment = ContentAlignment.TopCenter;
            subtitle.Visible   = false;
            viewport.Add(subtitle);

            // Create the title text
            title = new TextDrawableSprite(
                Game.GetFont(TitleFontSize), "");
            title.Tint      = Color.White;
            title.Alignment = ContentAlignment.TopCenter;
            title.Visible   = false;
            viewport.Add(title);

            // Create the title text
            text = new TextLayoutDrawableSprite(
                Game.GetFont(DescriptionFontSize), "");
            text.Tint      = Color.White;
            text.Alignment = ContentAlignment.TopCenter;
            viewport.Add(text);
        }
        protected DisplayStatusMinorMode()
        {
            // Create a sprite viewport to handle everything
            sprites = new SpriteViewport();

            // Create the heart and star icons
            heartSprite = AssetLoader.Instance.CreateSprite("Heart");
            sprites.Add(heartSprite);

            heartText = new TextDrawableSprite(Game.GetFont(FullTextSize));
            heartText.Tint = Constants.HeartColor;
            heartText.Text = Game.State.Hearts.ToString();
            heartText.Alignment = ContentAlignment.MiddleLeft;
            sprites.Add(heartText);

            starSprite = AssetLoader.Instance.CreateSprite("Star");
            sprites.Add(starSprite);

            starText = new TextDrawableSprite(Game.GetFont(FullTextSize));
            starText.Tint = Constants.StarColor;
            starText.Text = Game.State.Stars.ToString();
            starText.Alignment = ContentAlignment.MiddleLeft;
            sprites.Add(starText);

            chestSprite = AssetLoader.Instance.CreateSprite(ChestDrawableName);
            sprites.Add(chestSprite);

            chestText = new TextDrawableSprite(Game.GetFont(FullTextSize));
            chestText.Tint = Constants.ChestColor;
            chestText.Text = "0";
            chestText.Alignment = ContentAlignment.MiddleLeft;
            sprites.Add(chestText);

            // Create the viewport
            viewport = new SpriteViewport();
            viewport.ClipContents = true;
            sprites.Add(viewport);

            // Add the text elements
            subtitle = new TextDrawableSprite(
                Game.GetFont(NewFontSize), "");
            subtitle.Tint = Color.FromArgb(128, Color.White);
            subtitle.Alignment = ContentAlignment.TopCenter;
            subtitle.Visible = false;
            viewport.Add(subtitle);

            // Create the title text
            title = new TextDrawableSprite(
                Game.GetFont(TitleFontSize), "");
            title.Tint = Color.White;
            title.Alignment = ContentAlignment.TopCenter;
            title.Visible = false;
            viewport.Add(title);

            // Create the title text
            text = new TextLayoutDrawableSprite(
                Game.GetFont(DescriptionFontSize), "");
            text.Tint = Color.White;
            text.Alignment = ContentAlignment.TopCenter;
            viewport.Add(text);
        }
Beispiel #12
0
        /// <summary>
        /// Constructs the viewport and arranges all the needed
        /// elements.
        /// </summary>
        public IndicatorsViewport()
        {
            // Set the default values
            BackgroundColor = Color.FromArgb(128, Color.Black);
            Z = 100;

            // Create the status viewport
            statusViewport = new SpriteViewport();
            statusViewport.ClipContents = true;
            statusViewport.Z = 200;
            Add(statusViewport);

            // Load the mini icons
            heart = AssetLoader.Instance.CreateSprite(Constants.MiniHeartName);
            heart.Z = 300;
            heart.Point = new PointF(5, 0);
            statusViewport.Add(heart);

            star = AssetLoader.Instance.CreateSprite(Constants.MiniStarName);
            star.Point = new PointF(5, FontSize + 2);
            star.Z = 300;
            statusViewport.Add(star);

            clock = AssetLoader.Instance.CreateSprite(Constants.MiniClockName);
            clock.Z = 300;
            clock.Point = new PointF(155, 0);
            statusViewport.Add(clock);

            bug = AssetLoader.Instance.CreateSprite(Constants.MiniBugName);
            bug.Point = new PointF(155, FontSize + 2);
            bug.Z = 300;
            statusViewport.Add(bug);

            // Create the heart scores
            heartScore =
                new TextDrawableSprite(Game.GetFont(FontSize),
                    Game.State.Hearts.ToString());
            heartScore.Z = 300;
            heartScore.Point = new PointF(35, 15);
            heartScore.Tint = Constants.HeartColor;
            heartScore.Alignment = ContentAlignment.MiddleLeft;
            statusViewport.Add(heartScore);

            // Create the star scores
            starScore =
                new TextDrawableSprite(Game.GetFont(FontSize),
                    Game.State.Stars.ToString());
            starScore.Z = 300;
            starScore.Point = new PointF(35, FontSize + 15 + 4);
            starScore.Tint = Constants.StarColor;
            starScore.Alignment = ContentAlignment.MiddleLeft;
            statusViewport.Add(starScore);

            // Create the clock scores
            clockScore =
                new TextDrawableSprite(Game.GetFont(FontSize),
                    Game.State.SecondsRemaining.ToString());
            clockScore.Z = 300;
            clockScore.Point = new PointF(185, heartScore.Point.Y);
            clockScore.Tint = Constants.ClockColor;
            clockScore.Alignment = ContentAlignment.MiddleLeft;
            statusViewport.Add(clockScore);

            // Create the star scores
            bugScore =
                new TextDrawableSprite(Game.GetFont(FontSize),
                    Game.State.Stars.ToString());
            bugScore.Z = 300;
            bugScore.Point = new PointF(clockScore.Point.X, starScore.Point.Y);
            bugScore.Tint = Constants.BugColor;
            bugScore.Alignment = ContentAlignment.MiddleLeft;
            statusViewport.Add(bugScore);

            // Create the prayer viewport
            prayerViewport = new SpriteViewport();
            prayerViewport.ClipContents = true;
            Add(prayerViewport);
        }
Beispiel #13
0
        /// <summary>
        /// Indicates to the game mode that it is activated.
        /// </summary>
        public void Activate()
        {
            // If we don't have a game state, kick this over to the
            // new game state as an error condition.
            if (Game.State == null)
            {
                Game.GameMode = new NewGameMode();
            }

            // Create the sprite manager
            sprites = new SpriteViewport();
            sprites.IsMouseSensitive = true;
            sprites.ClipContents     = true;
            Game.SpriteManager.Add(sprites);

            // Create the board viewport
            blockViewport =
                new BlockViewport(Game.State.Board, AssetLoader.Instance);
            blockViewport.ClipContents     = true;
            blockViewport.IsMouseSensitive = true;
            blockViewport.MousePosition    = 8;
            blockViewport.FocusPosition    = Constants.FocusPosition;
            sprites.Add(blockViewport);

            // Create the top-down vertical explorer
            vertViewport   = new VerticalViewport(Game.State.Board);
            vertViewport.Z = 50;
            vertViewport.BackgroundColor = Color.FromArgb(32, Color.Black);
            vertViewport.Padding         = 2;
            vertViewport.BlockWidth      = vertViewport.BlockHeight = 16;
            vertViewport.MaximumHeight   = vertViewport.MinimumHeight = 4;
            vertViewport.Size            = vertViewport.Extents.Size;
            vertViewport.Visible         = false;
            vertViewport.Opacity         = 0.75f;
            sprites.Add(vertViewport);

            // Speeches and overlays
            speeches   = new SpriteViewport();
            speeches.Z = 100;
            speeches.IsMouseSensitive = true;
            sprites.Add(speeches);

            // Connect our events for selectors
            blockViewport.StackMouseEnter += OnStackMouseEnter;
            blockViewport.StackMouseExit  += OnStackMouseExit;

            // Create the scroller on the viewport
            scroller = new MouseEdgeScroller();
            scroller.Register(blockViewport);

            // Create our selector icon
            selector              = AssetLoader.Instance.CreateBlock("Selector");
            selector.Height       = 0;
            selector.CastsShadows = false;

            // Create the scores and other indicators
            CreateIndicators();

            // Connect the events
            Game.State.Board.MovingChanged      += OnMovingChanged;
            Game.State.Board.BlockMovingChanged += OnBlockMovingChanged;
            Game.State.Board.BlockMovingChanged += Game.Sound.BlockLanded;
        }
        /// <summary>
        /// Constructs the viewport and arranges all the needed
        /// elements.
        /// </summary>
        public IndicatorsViewport()
        {
            // Set the default values
            BackgroundColor = Color.FromArgb(128, Color.Black);
            Z = 100;

            // Create the status viewport
            statusViewport = new SpriteViewport();
            statusViewport.ClipContents = true;
            statusViewport.Z            = 200;
            Add(statusViewport);

            // Load the mini icons
            heart       = AssetLoader.Instance.CreateSprite(Constants.MiniHeartName);
            heart.Z     = 300;
            heart.Point = new PointF(5, 0);
            statusViewport.Add(heart);

            star       = AssetLoader.Instance.CreateSprite(Constants.MiniStarName);
            star.Point = new PointF(5, FontSize + 2);
            star.Z     = 300;
            statusViewport.Add(star);

            clock       = AssetLoader.Instance.CreateSprite(Constants.MiniClockName);
            clock.Z     = 300;
            clock.Point = new PointF(155, 0);
            statusViewport.Add(clock);

            bug       = AssetLoader.Instance.CreateSprite(Constants.MiniBugName);
            bug.Point = new PointF(155, FontSize + 2);
            bug.Z     = 300;
            statusViewport.Add(bug);

            // Create the heart scores
            heartScore =
                new TextDrawableSprite(Game.GetFont(FontSize),
                                       Game.State.Hearts.ToString());
            heartScore.Z         = 300;
            heartScore.Point     = new PointF(35, 15);
            heartScore.Tint      = Constants.HeartColor;
            heartScore.Alignment = ContentAlignment.MiddleLeft;
            statusViewport.Add(heartScore);

            // Create the star scores
            starScore =
                new TextDrawableSprite(Game.GetFont(FontSize),
                                       Game.State.Stars.ToString());
            starScore.Z         = 300;
            starScore.Point     = new PointF(35, FontSize + 15 + 4);
            starScore.Tint      = Constants.StarColor;
            starScore.Alignment = ContentAlignment.MiddleLeft;
            statusViewport.Add(starScore);

            // Create the clock scores
            clockScore =
                new TextDrawableSprite(Game.GetFont(FontSize),
                                       Game.State.SecondsRemaining.ToString());
            clockScore.Z         = 300;
            clockScore.Point     = new PointF(185, heartScore.Point.Y);
            clockScore.Tint      = Constants.ClockColor;
            clockScore.Alignment = ContentAlignment.MiddleLeft;
            statusViewport.Add(clockScore);

            // Create the star scores
            bugScore =
                new TextDrawableSprite(Game.GetFont(FontSize),
                                       Game.State.Stars.ToString());
            bugScore.Z         = 300;
            bugScore.Point     = new PointF(clockScore.Point.X, starScore.Point.Y);
            bugScore.Tint      = Constants.BugColor;
            bugScore.Alignment = ContentAlignment.MiddleLeft;
            statusViewport.Add(bugScore);

            // Create the prayer viewport
            prayerViewport = new SpriteViewport();
            prayerViewport.ClipContents = true;
            Add(prayerViewport);
        }