Example #1
0
        public PlanesSample()
            : base()
        {
            this.Window.Title = "Samurai Planes Sample";

            this.spriteRenderer = new SpriteRenderer(this.Graphics);
            this.shaderProgram = new BasicSpriteShaderProgram(this.Graphics);

            this.planesTexture = Texture2D.LoadFromFile(this.Graphics, "Planes.png", new TextureParams()
                {
                });

            this.planeSpriteSheet = SpriteSheet.Build(this.planesTexture, 64, 64);

            this.font = TextureFont.Build(this.Graphics, "Segoe UI", 72, new TextureFontParams()
                {
                    Color = Color4.White,
                    BackgroundColor = Color4.Transparent,
                });

            Random random = new Random();

            this.planes = new List<Plane>();

            for (int i = 0; i < PlaneCount; i++)
            {
                this.planes.Add(new Plane(
                    random.Next(4) * 3,
                    new Vector2(random.Next(this.Window.Width), random.Next(this.Window.Height)),
                    (float)random.Next(360),
                    new Size(this.Window.Width, this.Window.Height)
                ));
            }
        }
Example #2
0
        public ControlRenderer(GraphicsContext graphics)
        {
            if (graphics == null)
                throw new ArgumentNullException("graphics");

            this.graphics = graphics;
            this.spriteBatch = new SpriteRenderer(this.graphics);
            this.spriteBatchShader = new BasicSpriteShaderProgram(this.graphics);

            this.scissorStack = new Stack<Rectangle>();
        }
Example #3
0
        public Demo2DGame()
            : base(new GameOptions()
            {
                AutoResizeViewport = true,
                WindowResizable = true
            })
        {
            this.Window.Title = "Samurai 2D Demo";

            this.Graphics.DepthBufferState = DepthBufferState.LessThanOrEqual;

            this.Graphics.BlendState = BlendState.AlphaBlend;
            this.Graphics.RasterizerState = RasterizerState.Default;

            this.spriteRenderer = new SpriteRenderer(this.Graphics, 1024);
            this.shaderProgram = new BasicSpriteShaderProgram(this.Graphics);

            this.planesTexture = Texture2D.LoadFromFile(this.Graphics, "Planes.png", new TextureParams()
                {
                });

            this.planeSpriteSheet = SpriteSheet.Build(this.planesTexture, 64, 64);

            this.font = TextureFont.Build(this.Graphics, "Segoe UI", 72, new TextureFontParams()
                {
                    Color = Color4.White,
                    BackgroundColor = Color4.Transparent,
                    //ColorKey = Color4.Black
                });

            this.keyboard = new Keyboard();
            this.mouse = new Mouse(this.Window);

            Random random = new Random();

            this.planes = new List<Plane>();

            for (int i = 0; i < PlaneCount; i++)
            {
                this.planes.Add(new Plane(
                    random.Next(4) * 3,
                    new Vector2(random.Next(this.Window.Width), random.Next(this.Window.Height)),
                    (float)random.Next(360),
                    this.Window.Size
                ));
            }
        }