public SimpleBullet(Ship parent, double x, double y, double angle, double magnitude, Arena arena) : base(parent, x, y, true, arena, 4, 4) { bulletSprite = new Sprite(parent.GameRef.Resources.GetSpriteDescriptor("bullet"), parent.GameRef.Resources); this.angle = angle; this.magnitude = magnitude; }
public void AddSprite(Sprite sprite) { // If new texture is different from previous texture, draw and // change to new texture. if (sprite.Texture.Id != current.Texture.Id) { Draw(); Gl.glBindTexture(Gl.GL_TEXTURE_2D, sprite.Texture.Id); } current = sprite; //If the batch is full, draw it, empty and start again. if (sprite.VertexPositions.Length + batchSize > MaxVertexNumber) { Draw(); } // Add the current sprite vertices to the batch. for (int i = 0; i < sprite.VertexPositions.Length; i++) { vertexPositions[batchSize + i] = sprite.VertexPositions[i]; vertexColors[batchSize + i] = sprite.VertexColors[i]; vertexUVs[batchSize + i] = sprite.VertexUVs[i]; } batchSize += sprite.VertexPositions.Length; }
internal Tile CreateTile() { Sprite sprite = new Sprite(); sprite.Texture = _texture; Tile tile = new Tile(sprite); return tile; }
public Block(TextureManager textureManager, Engine.Color color, int gridPosX, int gridPosY) { sprite = new Sprite(); sprite.Texture = textureManager.Get("block"); sprite.SetScale(0.625, 0.625); sprite.SetColor(color); this.gridPosX = gridPosX; this.gridPosY = gridPosY; }
public Icon CreateIcon(string sprite, double scaling) { Sprite iconSprite = new Sprite(game.Resources.GetSpriteDescriptor(sprite), game.Resources); Dictionary<string, Sprite> dict = new Dictionary<string, Sprite>(); dict["icon"] = iconSprite; iconSprite.Scaling = scaling; return new Icon(game, dict); }
public void DrawBoundingBox(Sprite sprite) { RectangleF rect = sprite.GetBoundingBox(); Gl.glBegin(Gl.GL_LINE_LOOP); { Gl.glVertex2f(rect.Left, rect.Top); Gl.glVertex2f(rect.Right, rect.Top); Gl.glVertex2f(rect.Right, rect.Bottom); Gl.glVertex2f(rect.Left, rect.Bottom); } Gl.glEnd(); }
public void LoadContent(ContentManager content) { _unitPointerTile = new Engine.Sprite(content.Load <Texture2D>("Units/Misc/PointerTile")) { Layer = 0.20f, }; _targetPointerTile = new Engine.Sprite(content.Load <Texture2D>("Units/Misc/PointerTile")) { Layer = 0.20f, }; _unitPointer = new UnitPointer(content.Load <Texture2D>("Units/Misc/Pointer")); }
public void DrawSprite(Sprite sprite) { if (sprite.Texture.Id == _currentTextureId) { _batch.AddSprite(sprite); } else { _batch.Draw(); // Draw all with current texture // Update texture info _currentTextureId = sprite.Texture.Id; Gl.glBindTexture(Gl.GL_TEXTURE_2D, _currentTextureId); _batch.AddSprite(sprite); } }
public void AddSprite(Sprite sprite) { // If the batch is full, draw it, empty and start again. if (sprite.VertexPositions.Length + _batchSize > MaxVertexNumber) { Draw(); } // Add the current sprite vertices to the batch. for (int i = 0; i < sprite.VertexPositions.Length; i++) { _vertexPositions[_batchSize + i] = sprite.VertexPositions[i]; _vertexColors[_batchSize + i] = sprite.VertexColors[i]; _vertexUVs[_batchSize + i] = sprite.VertexUVs[i]; } _batchSize += sprite.VertexPositions.Length; }
public CharacterSprite CreateSprite(char c) { CharacterData charData = _characterData[c]; Sprite sprite = new Sprite(); sprite.Texture = _texture; // Setup UVs Point topLeft = new Point((float)charData.X / (float)_texture.Width, (float)charData.Y / (float)_texture.Height); Point bottomRight = new Point(topLeft.X + ((float)charData.Width / (float)_texture.Width), topLeft.Y + ((float)charData.Height / (float)_texture.Height)); sprite.SetUVs(topLeft, bottomRight); sprite.SetWidth(charData.Width); sprite.SetHeight(charData.Height); sprite.SetColor(new Color(1, 1, 1, 1)); return new CharacterSprite(sprite, charData); }
public SimpleGunTurret(Ship parent, double x, double y, Arena arena) : base(parent, x, y, false, arena, 16, 16) { turretSprite = new Sprite(parent.GameRef.Resources.GetSpriteDescriptor("turret"), parent.GameRef.Resources); }
public Tile(Sprite sprite) { _sprite = sprite; }
public void DrawSprite(Sprite sprite) { batch.AddSprite(sprite); }
public Engine(EngineSetup setup = null) { XmlConfigurator.Configure(); _loaded = false; _setup = new EngineSetup(); if (setup != null) { _setup = setup; } _gEngine = this; var d3d = new Direct3D(); var enumeration = new DeviceEnumeration(d3d); if (enumeration.ShowDialog() != DialogResult.OK) { ReleaseCom(d3d); return; } Window = new FpsForm { Name = "WindowClass", Text = _setup.Name, FormBorderStyle = enumeration.Windowed ? FormBorderStyle.FixedSingle : FormBorderStyle.None, Size = new Size(800, 600) }; var pp = new PresentParameters { BackBufferWidth = enumeration.SelectedDisplayMode.Width, BackBufferHeight = enumeration.SelectedDisplayMode.Height, BackBufferFormat = enumeration.SelectedDisplayMode.Format, BackBufferCount = _setup.TotalBackBuffers, SwapEffect = SwapEffect.Discard, DeviceWindowHandle = Window.Handle, Windowed = enumeration.Windowed, EnableAutoDepthStencil = true, AutoDepthStencilFormat = Format.D24S8, FullScreenRefreshRateInHertz = enumeration.SelectedDisplayMode.RefreshRate, PresentationInterval = enumeration.VSync ? PresentInterval.Default : PresentInterval.Immediate, Multisample = MultisampleType.None, MultisampleQuality = 0, PresentFlags = PresentFlags.None }; enumeration.Dispose(); _device = new Device(d3d, 0, DeviceType.Hardware, Window.Handle, CreateFlags.MixedVertexProcessing, pp); ReleaseCom(d3d); _device.SetSamplerState(0, SamplerState.MagFilter, TextureFilter.Anisotropic); _device.SetSamplerState(0, SamplerState.MinFilter, TextureFilter.Anisotropic); _device.SetSamplerState(0, SamplerState.MipFilter, TextureFilter.Linear); var proj = Matrix.PerspectiveFovLH( (float) (Math.PI/4), (float)pp.BackBufferWidth/pp.BackBufferHeight, 0.1f/_setup.Scale, 1000.0f/_setup.Scale ); _device.SetTransform(TransformState.Projection, proj); _displayMode = new SlimDX.Direct3D9.DisplayMode { Width = pp.BackBufferWidth, Height = pp.BackBufferHeight, RefreshRate = pp.FullScreenRefreshRateInHertz, Format = pp.BackBufferFormat }; _currentBackBuffer = 0; _sprite = new Sprite(_device); Window.Show(); Window.Activate(); _states = new List<State>(); CurrentState = null; ScriptManager = new ResourceManager<Script>(); Input = new Input(Window); if (_setup.StateSetup != null) { _setup.StateSetup(); } _loaded = true; _running = true; }
public CharacterSprite(Sprite sprite, CharacterData data) { Data = data; Sprite = sprite; }
static Dictionary<string, Sprite> SpriteToDictionary(string key, Sprite s) { Dictionary<string, Sprite> dict = new Dictionary<string, Sprite>(); dict[key] = s; return dict; }
public PlayerShipBody(Ship parent, double x, double y, Arena arena) : base(parent, x, y, false, arena, 32, 48) { bodySprite = new Sprite(parent.GameRef.Resources.GetSpriteDescriptor("playership"), parent.GameRef.Resources); }