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) )); } }
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 )); } }
public void Draw( SpriteSheet spriteSheet, int frame, Vector2 position, Color4? tint = null, Vector2? origin = null, Vector2? scale = null, float rotation = 0.0f, float layerDepth = 0.0f) { if (spriteSheet == null) throw new ArgumentNullException("spriteSheet"); Rectangle frameRect = spriteSheet[frame]; this.DrawInternal( spriteSheet.Texture, position, frameRect.Width, frameRect.Height, frameRect, tint, origin, scale, rotation, layerDepth); }