コード例 #1
0
    /// <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);
    }
コード例 #2
0
    /// <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);
        }
    }
コード例 #3
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);
    }
コード例 #4
0
    /// <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);
            }
        }
    }
コード例 #5
0
ファイル: Display.cs プロジェクト: dmoonfire/wordplay
        /// <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();
        }
コード例 #6
0
ファイル: Viewer.cs プロジェクト: dmoonfire/wordplay
    /// <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);
    }