public SceneTitle() { sceneType = SceneType.Title; _menuItems = new MenuItem[] { new MenuItem(Key.S, "Start"), new MenuItem(Key.O, "Option"), new MenuItem(Key.Q, "Quit") }; _keys = new Key[] { Key.UpArrow, Key.DownArrow, Key.Return, Key.M, Key.O, Key.Q }; _cursor = ResourceManager.GetColoredCursorGraphic(Constants.Color_Foreground); if (_menuSurfaces == null) { _menuSurfaces = new SurfaceCollection(); _menuRects = new Rectangle[_menuItems.Length]; ImageUtil.CreateStrMenu(_menuItems, Constants.Color_Foreground, ResourceManager.MiddlePFont, ref _menuSurfaces, ref _menuRects, Constants.ScreenWidth); } }
public SpriteSheet(string spriteSheetFilename, Color transparentColor, Size frameSize, int rotationPerFrameDeg, int firstFrameShipDirectionDeg, int rotationAnimationDelay, int cannonBarrelLength, int forwardThrusterEngineLength, int reverseThrusterEngineLength) { this.bitmap = new Bitmap(spriteSheetFilename); this.transparentColor = transparentColor; this.frameSize = frameSize; this.rotationPerFrameDeg = rotationPerFrameDeg; this.firstFrameShipDirectionDeg = firstFrameShipDirectionDeg; this.cannonBarrelLength = cannonBarrelLength; this.reverseThrusterEngineLength = reverseThrusterEngineLength; this.forwardThrusterEngineLength = forwardThrusterEngineLength; SurfaceCollection spriteSheet_SurfaceCollection = new SurfaceCollection(); Surface spriteSheet_Surface = new Surface(this.bitmap).Convert(Video.Screen, true, false); spriteSheet_SurfaceCollection.Add(spriteSheet_Surface, this.frameSize); AnimationCollection animationCollection = new AnimationCollection(); animationCollection.Add(spriteSheet_SurfaceCollection); animationCollection.Delay = rotationAnimationDelay; AnimatedSprite animatedSprite = new AnimatedSprite(animationCollection); animatedSprite.TransparentColor = this.transparentColor; animatedSprite.Transparent = true; this.animatedSprite = animatedSprite; }
public SceneGameOver() { sceneType = SceneType.GameOver; _menuItems = new MenuItem[] { new MenuItem(Key.R, Properties.Resources.MenuItem_RetryStage), new MenuItem(Key.M, Properties.Resources.MenuItem_MapSelect), new MenuItem(Key.T, Properties.Resources.MenuItem_ReturnTitle) }; _keys = new Key[] { Key.UpArrow, Key.DownArrow, Key.Return, Key.Escape, Key.M, Key.R, Key.T }; _cursor = ResourceManager.GetColoredCursorGraphic(_foreColor); _overImgSurface = ResourceManager.LoadSurface(Constants.Filename_GameoverImage); ImageUtil.SetColor(_overImgSurface, _foreColor); _menuSurfaces = new SurfaceCollection(); _menuRects = new Rectangle[_menuItems.Length]; ImageUtil.CreateStrMenu(_menuItems, _foreColor, ref _menuSurfaces, ref _menuRects, Constants.ScreenWidth); }
public base_player() : base() { mTexFrames = new AnimationCollection(); mTexFrames.Add("tex3.bmp", new System.Drawing.Size(64, 64)); //mTexFrames.Add("tex2.bmp", new System.Drawing.Size(64, 64)); mTexture = new AnimatedSprite("player", mTexFrames); }
public e_pillar(Vector2 pos, string tex) : base() { mPosition = pos; mTexFrames = new AnimationCollection(); mTexFrames.Add(tex, new Size(64, 64)); mTexture = new AnimatedSprite("pillar", mTexFrames); }
/// <summary> /// Run the application /// </summary> public void Go() { // Make the particle emitter. emit = new ParticleRectangleEmitter(particles); emit.Frequency = 50000; // 100000 every 1000 updates. emit.LifeFullMin = 20; emit.LifeFullMax = 50; emit.LifeMin = 10; emit.LifeMax = 30; emit.DirectionMin = -2; // shoot up in radians. emit.DirectionMax = -1; emit.ColorMin = Color.DarkBlue; emit.ColorMax = Color.LightBlue; emit.SpeedMin = 5; emit.SpeedMax = 20; emit.MaxSize = new SizeF(5, 5); emit.MinSize = new SizeF(1, 1); // Make the first particle (a pixel) ParticlePixel first = new ParticlePixel(Color.White, 100, 200, new Vector(0, 0, 0), -1); particles.Add(first); // Add it to the system if (File.Exists(Path.Combine(dataDirectory, "marble1.png"))) { filePath = ""; } // Make the second particle (an animated sprite) AnimationCollection anim = new AnimationCollection(); SurfaceCollection surfaces = new SurfaceCollection(); surfaces.Add(Path.Combine(filePath, Path.Combine(dataDirectory, "marble1.png")), new Size(50, 50)); anim.Add(surfaces, 1); AnimatedSprite marble = new AnimatedSprite(anim); marble.Animate = true; ParticleSprite second = new ParticleSprite(marble, 200, 200, new Vector(-7, -9, 0), 500); second.Life = -1; particles.Add(second); // Add it to the system // Add some manipulators to the particle system. ParticleGravity grav = new ParticleGravity(0.5f); particles.Manipulators.Add(grav); // Gravity of 0.5f particles.Manipulators.Add(new ParticleFriction(0.1f)); // Slow down particles particles.Manipulators.Add(vort); // A particle vortex fixed on the mouse particles.Manipulators.Add(new ParticleBoundary(SdlDotNet.Graphics.Video.Screen.Size)); // fix particles on screen. Events.Run(); }
/// <summary> /// Constructs the internal sprites needed for our demo. /// </summary> public ViewportMode() { // Create the fragment marbles SurfaceCollection td = LoadMarble("marble1"); SurfaceCollection td2 = LoadMarble("marble2"); // Load the floor SurfaceCollection floorTiles = LoadFloor(); // Place the floors int rows = 8; int cols = 15; size = new Size(floorTiles[0].Size.Width * cols, floorTiles[0].Size.Height * rows); rect = new Rectangle(new Point(0, 0), size); for (int i = 0; i < cols; i++) { for (int j = 0; j < rows; j++) { // Create the floor tile sprites AnimatedSprite dw = new AnimatedSprite(floorTiles, new Point(i * floorTiles[0].Size.Width, j * floorTiles[0].Size.Height)); Sprites.Add(dw); } } // Load the trigger sprite sprite = new BounceSprite(td2, rect, new Vector(Randomizer.Next(rect.Left, rect.Right - (int)td2.Size.Width), Randomizer.Next(rect.Top, rect.Bottom - (int)td2.Size.Height), 1)); Sprites.Add(sprite); CenterSprite.Add(sprite); // Load the bouncing sprites for (int i = 0; i < 10; i++) { Thread.Sleep(10); BounceSprite bounceSprite = new BounceSprite(td, rect, new Vector(Randomizer.Next(rect.Left, rect.Right - (int)td.Size.Width), Randomizer.Next(rect.Top, rect.Bottom - (int)td.Size.Height), 1)); Sprites.Add(bounceSprite); } }
/// <summary> /// /// </summary> /// <param name="disposing"></param> protected virtual void Dispose(bool disposing) { if (!this.disposed) { if (disposing) { if (this.hero != null) { this.hero.Dispose(); this.hero = null; } } this.disposed = true; } }
public static void DrawSelections(Surface canvas, SurfaceCollection surfaces, Rectangle[] rects, AnimatedSprite cursor, int selectedIndex = -1, MenuItemAlign align = MenuItemAlign.MiddleCenter) { DrawSelections(canvas, surfaces, rects, cursor, Point.Empty, selectedIndex, align); }
public static void DrawSelections(Surface canvas, SurfaceCollection surfaces, Rectangle[] rects, AnimatedSprite cursor, Point offset, int selectedIndex = -1, MenuItemAlign align = MenuItemAlign.MiddleCenter) { DrawSurfaces(canvas, surfaces, rects, offset, align); if (selectedIndex >= 0 && selectedIndex < rects.Length) { Rectangle rect = rects[selectedIndex]; Surface s = surfaces[selectedIndex]; Point p = Point.Empty; switch (align) { case MenuItemAlign.TopLeft: p.X = rect.Left; p.Y = (int)(rect.Top + s.Size.Height / 2.0); break; case MenuItemAlign.TopCenter: p.X = (int)(rect.Left + rect.Width / 2.0 - s.Size.Width / 2.0); p.Y = (int)(rect.Top + s.Size.Height / 2.0); break; case MenuItemAlign.TopRight: p.X = rect.Right - s.Size.Width; p.Y = (int)(rect.Top + s.Size.Height / 2.0); break; case MenuItemAlign.MiddleLeft: p.X = rect.Left; p.Y = (int)(rect.Top + rect.Height / 2.0); break; case MenuItemAlign.MiddleCenter: p.X = (int)(rect.Left + rect.Width / 2.0 - s.Size.Width / 2.0); p.Y = (int)(rect.Top + rect.Height / 2.0); break; case MenuItemAlign.MiddleRight: p.X = rect.Right - s.Size.Width; p.Y = (int)(rect.Top + rect.Height / 2.0); break; case MenuItemAlign.BottomLeft: p.X = rect.Left; p.Y = (int)(rect.Bottom - s.Size.Height / 2.0); break; case MenuItemAlign.BottomCenter: p.X = (int)(rect.Left + rect.Width / 2.0 - s.Size.Width / 2.0); p.Y = (int)(rect.Bottom - s.Size.Height / 2.0); break; case MenuItemAlign.BottomRight: p.X = rect.Right - s.Size.Width; p.Y = (int)(rect.Bottom - s.Size.Height / 2.0); break; } p.X -= cursor.Size.Width; p.Y -= (int)(cursor.Size.Height / 2.0); p.Offset(offset); canvas.Blit(cursor, p); } }
public static AnimatedSprite CreateColored(AnimatedSprite os, Color c) { if (os == null) return null; AnimatedSprite nsprite = new AnimatedSprite(); foreach (KeyValuePair<string, AnimationCollection> kv in os.Animations) { string key = kv.Key; AnimationCollection anim = kv.Value; AnimationCollection nAnim = new AnimationCollection(); foreach (Surface s in anim) { Surface ns = CreateColored(s, c); nAnim.Add(ns); } nAnim.Loop = anim.Loop; nAnim.Delay = anim.Delay; nAnim.FrameIncrement = anim.FrameIncrement; nAnim.Alpha = anim.Alpha; nAnim.AlphaBlending = anim.AlphaBlending; nAnim.AnimateForward = anim.AnimateForward; //nAnim.AnimationTime = anim.AnimationTime; nAnim.Transparent = anim.Transparent; nAnim.TransparentColor = anim.TransparentColor; nsprite.Animations.Add(key, nAnim); } nsprite.AllowDrag = os.AllowDrag; nsprite.Alpha = os.Alpha; nsprite.AlphaBlending = os.AlphaBlending; nsprite.Animate = os.Animate; nsprite.AnimateForward = os.AnimateForward; nsprite.CurrentAnimation = os.CurrentAnimation; nsprite.Frame = os.Frame; nsprite.Transparent = os.Transparent; nsprite.TransparentColor = os.TransparentColor; nsprite.Visible = os.Visible; return nsprite; }
/// <summary> /// Constructs the internal sprites needed for our demo. /// </summary> public MultipleMode() { // Create the fragment marbles SurfaceCollection td = LoadMarble("marble1"); SurfaceCollection td2 = LoadMarble("marble2"); SurfaceCollection td3 = LoadMarble("marble3"); SurfaceCollection td4 = LoadMarble("marble4"); SurfaceCollection td5 = LoadMarble("marble5"); // Load the floor SurfaceCollection floorTiles = LoadFloor(); // Place the floors int rows = 8; int cols = 10; size = new Size(floorTiles[0].Size.Width * cols, floorTiles[0].Size.Height * rows); rect = new Rectangle(new Point(0, 0), size); for (int i = 0; i < cols; i++) { for (int j = 0; j < rows; j++) { // Create the sprite AnimatedSprite dw = new AnimatedSprite(floorTiles, new Point(i * floorTiles[0].Size.Width, j * floorTiles[0].Size.Height)); this.Sprites.Add(dw); } } // Load the bouncing sprites for (int i = 0; i < 10; i++) { BounceSprite d = new BounceSprite(td, rect, new Vector(Randomizer.Next(rect.Left, rect.Right - (int)td.Size.Width), Randomizer.Next(rect.Top, rect.Bottom - (int)td.Size.Height), 1)); this.Sprites.Add(d); } // Only one container may be tickable when they all talk to the // same inner tick manager. // Set up container #1 sprite1 = new BounceSprite(td2, rect, new Vector(Randomizer.Next(rect.Left, rect.Right - (int)td2.Size.Width), Randomizer.Next(rect.Top, rect.Bottom - (int)td2.Size.Height), 1)); this.Sprites.Add(sprite1); // Set up container #2 sprite2 = new BounceSprite(td3, rect, new Vector(Randomizer.Next(rect.Left, rect.Right - (int)td3.Size.Width), Randomizer.Next(rect.Top, rect.Bottom - (int)td3.Size.Height), 1)); this.Sprites.Add(sprite2); // Set up container #3 sprite3 = new BounceSprite(td4, rect, new Vector(Randomizer.Next(rect.Left, rect.Right - (int)td4.Size.Width), Randomizer.Next(rect.Top, rect.Bottom - (int)td4.Size.Height), 1)); this.Sprites.Add(sprite3); // Set up container #4 sprite4 = new BounceSprite(td5, rect, new Vector(Randomizer.Next(rect.Left, rect.Right - (int)td5.Size.Width), Randomizer.Next(rect.Top, rect.Bottom - (int)td5.Size.Height), 1)); this.Sprites.Add(sprite4); surf1 = this.Surface.CreateCompatibleSurface(380, 250); surf2 = this.Surface.CreateCompatibleSurface(380, 250); surf3 = this.Surface.CreateCompatibleSurface(380, 250); surf4 = this.Surface.CreateCompatibleSurface(380, 250); }