public void updateScreen() { SFML.Graphics.Texture texture = new SFML.Graphics.Texture(Core.beakWindow.screen); SFML.Graphics.Sprite sprite = new SFML.Graphics.Sprite(texture); sprite.Scale = new SFML.System.Vector2f(2, 2); drawCanvas.drawFrame(sprite); }
/// <summary> /// Creates a new texture from a copy of another texture. No cache option for this. /// </summary> /// <param name="copy">The texture to copy from.</param> public Texture(Texture copy) { texture = new SFML.Graphics.Texture(copy.SFMLTexture); Source = copy.Source; texture.Smooth = DefaultSmooth; }
/// <summary> /// Sets the color of a specific pixel on the texture. /// </summary> /// <param name="x">The x coordinate of the pixel.</param> /// <param name="y">The y coordinate of the pixel.</param> /// <param name="color">The Color to set the pixel to.</param> public void SetPixel(int x, int y, Color color) { if (x < 0) { throw new ArgumentException("X must be greater than 0."); } if (y < 0) { throw new ArgumentException("Y must be greater than 0."); } if (x > Width) { throw new ArgumentException("X must be within the texture width."); } if (y > Height) { throw new ArgumentException("Y must be within the texture width."); } CreateImage(); image.SetPixel((uint)x, (uint)y, color.SFMLColor); texture = new SFML.Graphics.Texture(image); needsUpdate = true; }
public void StartLoad() { if (nativeTexture != null) { Unload(); } LoadState = LoadStates.Loading; try { if (IsRenderTex) { Path = ""; // render textures expect size already set here. nativeTexture = new SFML.Graphics.Texture((uint)Size.X, (uint)Size.Y); } else { nativeTexture = new SFML.Graphics.Texture(Path); } nativeTexture.Smooth = true; nativeTexture.Repeated = true; Size = new Int2((int)nativeTexture.Size.X, (int)nativeTexture.Size.Y); } catch (Exception) { // pokemon exception catching :P LoadState = LoadStates.Failed; } LoadState = LoadStates.Active; }
public Apple() : base() { texture = new SFML.Graphics.Texture("Resources\\apple.png"); sprite = new SFML.Graphics.Sprite(texture, new SFML.Graphics.IntRect(0, 0, 30, 30)); Points = 1; //Console.WriteLine((random.Next() % 30) * 29); Position = new Vector2f(((random.Next() % 28) + 1) * 30, ((random.Next() % 18) + 1) * 30); }
public GeneralTexture(string texture, Vector2D position) { this.position = position; this.texture = GeneralTextureManager.GetTexture(texture); this.sprite = new SFML.Graphics.Sprite(this.texture); this.sprite.Position = this.position.InternalVector; }
public static void AddTexture(string name, string imagePath) { ExceptionHelper.AssertFileExists(imagePath, "TextureManager.AddTexture()"); ExceptionHelper.AssertIsNotInDictionary<SFML.Graphics.Texture>(textures, name, "TextureManager.AddTexture()"); SFML.Graphics.Texture texture = new SFML.Graphics.Texture(imagePath); textures.Add(name, texture); }
public static void AddTexture(string name, string imagePath) { ExceptionHelper.AssertFileExists(imagePath, "TextureManager.AddTexture()"); ExceptionHelper.AssertIsNotInDictionary <SFML.Graphics.Texture>(textures, name, "TextureManager.AddTexture()"); SFML.Graphics.Texture texture = new SFML.Graphics.Texture(imagePath); textures.Add(name, texture); }
public Obstacle() { obstacle = new SFML.Graphics.RectangleShape(new SFML.System.Vector2f(100, 300)); obstacleTexture = new SFML.Graphics.Texture(100, 300); obstacle.Position = new SFML.System.Vector2f(500, 0); // obstacle.Texture = obstacleTexture; obstacle.FillColor = SFML.Graphics.Color.Red; }
public PixelCollider(Texture texture, params int[] tags) { this.texture = texture.SFMLTexture; collideImage = this.texture.CopyToImage(); Width = this.texture.Size.X; Height = this.texture.Size.Y; AddTag(tags); }
public byte GetPixel(byte[] mask, ref SFML.Graphics.Texture tex, int x, int y) { if (x > tex.Size.X || y > tex.Size.Y) { return(0); } return(mask[x + y * tex.Size.X]); }
public Texture(Stream stream) { if (!stream.CanSeek || !stream.CanRead) { throw new ArgumentException("Stream must be read and seekable.", nameof(stream)); } SFMLTexture = new STexture(stream); }
/// <summary> /// Creates a pixel collider. /// </summary> /// <param name="source">The source image to create the collider from.</param> /// <param name="tags">The tags to register the collider with.</param> public PixelCollider(string source, params int[] tags) { texture = Textures.Load(source); collideImage = texture.CopyToImage(); Width = texture.Size.X; Height = texture.Size.Y; AddTag(tags); }
public void CopyPixels(Texture from, int fromX, int fromY, int fromWidth, int fromHeight, int toX, int toY) { CreateImage(); from.CreateImage(); image.Copy(from.image, (uint)toX, (uint)toY, new SFML.Graphics.IntRect(fromX, fromY, fromWidth, fromHeight)); texture = new SFML.Graphics.Texture(image); needsUpdate = true; }
public Player() { // texture = new SFML.Graphics.Texture() do uzupełnienia gravityForce = new SFML.System.Vector2f(0f, 0.00005f); texture = new SFML.Graphics.Texture(800, 800); shape = new SFML.Graphics.CircleShape(30f); shape.Position = new SFML.System.Vector2f(20, 400); // shape.Texture = texture; shape.FillColor = SFML.Graphics.Color.Cyan; }
internal Texture(int width, int height, Ur.Color color) { this.Path = ""; this.nativeTexture = null; this.nativeRenderTexture = new SFML.Graphics.RenderTexture((uint)width, (uint)height, false); this.nativeRenderTexture.Clear(color.ToSFMLColor()); this.Size = new Int2(width, height); IsRenderTex = true; StartLoad(); }
public override void Init() { s.Start(); cooldown = 1000; Moving = true; Texture = new SFML.Graphics.Texture("Resources/Final.png"); Scale = new SFML.System.Vector2f(0.1f, 0.1f); Position = new SFML.System.Vector2f(0, 0); Origin = new SFML.System.Vector2f(Texture.Size.X / 2, Texture.Size.Y / 2); Collided += FinalBoss_Collided; }
public static bool Add(string name, SFMLTexture image) { if (_textures.Contains(name)) { return(true); } _textures.Add(name, new SFMLTexture(image)); return(true); }
/// <summary> /// Load a texture from a file path. /// </summary> /// <param name="source">The file path to load from.</param> /// <param name="useCache">Determines if the cache should be checked first.</param> public Texture(string source, bool useCache = true) { if (useCache) { texture = Textures.Load(source); } else { texture = new SFML.Graphics.Texture(source); } Source = source; texture.Smooth = DefaultSmooth; }
/// <summary> /// Create a texture from a stream of bytes. /// </summary> /// <param name="stream">The stream to load from.</param> /// <param name="useCache">Determines if the cache should be checked first.</param> public Texture(Stream stream, bool useCache = true) { if (useCache) { texture = Textures.Load(stream); } else { texture = new SFML.Graphics.Texture(stream); } Source = "stream"; texture.Smooth = DefaultSmooth; }
/// <summary> /// Creates a new texture from a copy of another texture. No cache option for this. /// </summary> /// <param name="copy">The texture to copy from.</param> public Texture(Texture copy) { texture = new SFML.Graphics.Texture(copy.SFMLTexture); Source = copy.Source; if (Game.Instance != null) { texture.Smooth = Game.Instance.SmoothAll; } }
public SFML.Graphics.Texture GetTexture(string path) { SFML.Graphics.Texture tex = new SFML.Graphics.Texture(@"img\default.png"); if (textures.TryGetValue(path, out tex)) { return(tex); } else { return(tex); } }
public void Attack(GameObject player) { SFML.Graphics.Texture texture = new SFML.Graphics.Texture("Pictures/chest_attack.png"); _parent.GetComponent <RenderComponent>().Sprite.Texture = texture; Vector2D TargetPosition = player.transform.Position + player.Parent.transform.Position; double angle = (TargetPosition - (_parent.transform.Position + _parent.Parent.transform.Position)).GetAngleBetween(Vector2D.Up()); _parent.transform.Rotation = angle; //new Factory().CreateMimic(_parent.transform.Position, angle); }
public Button(string textToShow, SFML.Graphics.Font font, SFML.System.Vector2f position, SFML.Graphics.Texture normal, SFML.Graphics.Texture highlighted, SFML.Graphics.Texture pressed) { text = textToShow; sfmlText = new SFML.Graphics.Text(text, font); sfmlText.OutlineThickness = 1; sfmlText.OutlineColor = SFML.Graphics.Color.Black; normalTXT = normal; highlightedTXT = highlighted; pressedTXT = pressed; sprite = new SFML.Graphics.Sprite(normalTXT); sprite.Position = position; }
public horse(string Color) { if (Color == "White") { im = new SFML.Graphics.Image(WhiteImagePath); } else { im = new SFML.Graphics.Image(BlackImagePath); } text = new SFML.Graphics.Texture(im); sp = new SFML.Graphics.Sprite(text); }
protected virtual void Dispose(bool disposing) { if (!Disposed) { if (disposing) { // No managed resources to dispose of. } SfmlTexture.Dispose(); SfmlImage.Dispose(); Disposed = true; } }
public override void Update(double elapsedTime) { if (Program.windowState == Program.WindowState.GameOver) { return; } bool targetFound = false; double minDist = _viewRange; foreach (GameObject player in _players) { double dist = _parent.transform.Position.GetDistance(player.transform.Position); if (dist < minDist) { _target = player;// player.transform.Position + player.Parent.transform.Position; minDist = dist; targetFound = true; } } if (targetFound) { State = States.attack; SFML.Graphics.Texture texture = new SFML.Graphics.Texture("Pictures/chest_attack.png"); _parent.GetComponent <RenderComponent>().Sprite.Texture = texture; //_parent.GetScripts<EnemyLookScript>()[0].TargetPosition = _target.transform.Position + _target.Parent.transform.Position; Vector2D TargetPosition = _target.transform.Position + _target.Parent.transform.Position; double angle = (TargetPosition - (_parent.transform.Position + _parent.Parent.transform.Position)).GetAngleBetween(Vector2D.Up()); if (_parent.transform.Position.Y + _parent.Parent.transform.Position.Y < TargetPosition.Y) { angle = 180 - angle; } _parent.transform.Rotation = angle; Program.windowState = Program.WindowState.GameOver; } else { State = States.idle; //_parent.GetScripts<EnemyLookScript>()[0].IsActive = false; } }
/// <summary> /// Create a texture from a stream of bytes. /// </summary> /// <param name="stream">The stream to load from.</param> /// <param name="useCache">Determines if the cache should be checked first.</param> public Texture(Stream stream, bool useCache = true) { if (useCache) { texture = Textures.Load(stream); } else { texture = new SFML.Graphics.Texture(stream); } Source = "stream"; if (Game.Instance != null) { texture.Smooth = Game.Instance.SmoothAll; } }
/// <summary> /// Load a texture from a file path. /// </summary> /// <param name="source">The file path to load from.</param> /// <param name="useCache">Determines if the cache should be checked first.</param> public Texture(string source, bool useCache = true) { if (useCache) { texture = Textures.Load(source); } else { texture = new SFML.Graphics.Texture(source); } Source = source; if (Game.Instance != null) { texture.Smooth = Game.Instance.SmoothAll; } }
private void buttonSolidTexture_Click(object sender, EventArgs e) { OpenFileDialog od = new OpenFileDialog(); od.Filter = "JPEG files (Portable Network Graphic (*.png)|*.png|*.jpg)|*.jpg"; if (m_mapTextureDirectory != null && m_mapTextureDirectory != String.Empty) { od.InitialDirectory = m_mapTextureDirectory; } if (od.ShowDialog() == DialogResult.OK) { try { Image img = Image.FromFile(od.FileName); m_platformTexture = (Image)(new Bitmap(img, new Size(img.Width / scale, img.Height / scale))); //loop through existing nodes and update image foreach (Panel p in panelEditorInner.Controls) { NodeData nd = (NodeData)p.Tag; if (nd.type == Node.BodyType.Solid) { p.BackgroundImage = m_platformTexture; } } m_platformFileName = Path.GetFileName(od.FileName); m_modified = true; //update existing drawables SFML.Graphics.Texture t = m_textureResource.Get(od.FileName); t.Repeated = true; foreach (var d in m_previewLayers[(int)Layer.Solid]) { d.Texture = t; d.FillColor = SFML.Graphics.Color.White; d.TextureRect = new SFML.Graphics.IntRect((int)d.Position.X, (int)d.Position.Y, (int)d.Size.X, (int)d.Size.Y); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Failed opening file"); } } }
/// <summary> /// Creates an empty texture of width and height. This does not use the cache. /// </summary> /// <param name="width">The width of the texture.</param> /// <param name="height">The height of the texture.</param> public Texture(int width, int height) { if (width < 0) { throw new ArgumentException("Width must be greater than 0."); } if (height < 0) { throw new ArgumentException("Height must be greater than 0."); } texture = new SFML.Graphics.Texture((uint)width, (uint)height); Source = width + " x " + height + " texture"; texture.Smooth = DefaultSmooth; }
public Texture(SFML.Graphics.Texture texture) { this.texture = texture; this.drawColor = SFML.Graphics.Color.White; }
/// <summary> /// Creates an empty texture of width and height. This does not use the cache. /// </summary> /// <param name="width">The width of the texture.</param> /// <param name="height">The height of the texture.</param> public Texture(int width, int height) { if (width < 0) throw new ArgumentException("Width must be greater than 0."); if (height < 0) throw new ArgumentException("Height must be greater than 0."); texture = new SFML.Graphics.Texture((uint)width, (uint)height); Source = width + " x " + height + " texture"; texture.Smooth = DefaultSmooth; }
/// <summary> /// Load a texture from an SFML texture. /// </summary> /// <param name="texture"></param> internal Texture(SFML.Graphics.Texture texture) { this.texture = texture; }
/// <summary> /// Sets the color of a specific pixel on the texture. /// </summary> /// <param name="x">The x coordinate of the pixel.</param> /// <param name="y">The y coordinate of the pixel.</param> /// <param name="color">The Color to set the pixel to.</param> public void SetPixel(int x, int y, Color color) { if (x < 0) throw new ArgumentException("X must be greater than 0."); if (y < 0) throw new ArgumentException("Y must be greater than 0."); if (x > Width) throw new ArgumentException("X must be within the texture width."); if (y > Height) throw new ArgumentException("Y must be within the texture width."); CreateImage(); image.SetPixel((uint)x, (uint)y, color.SFMLColor); texture = new SFML.Graphics.Texture(image); needsUpdate = true; }
public ITexture LoadTexture(byte[] data) { using (MemoryStream stream = new MemoryStream()) { stream.Write(data, 0, data.Length); SFML.Graphics.Texture sfTexture = new SFML.Graphics.Texture(stream); sfTexture.Smooth = true; Texture texture = new Texture(sfTexture); return texture; } }
private void LoadTexture(string path) { SFML.Graphics.Texture tex = new SFML.Graphics.Texture(path); if (tex.Size.X <= 2048 && tex.Size.Y <= 2048) { m_aniSprite = new AnimatedSprite(tex); m_sfmlControl.UpdateDelegates.Clear(); m_sfmlControl.UpdateDelegates.Add(m_aniSprite.Update); ResetControls(); m_aniSprite.FrameRate = (uint)numericUpDownFrameRate.Value; m_aniSprite.FrameCount = (uint)numericUpDownFrameCount.Value; m_aniSprite.FrameSize = new SFML.Window.Vector2i((int)numericUpDownFrameWidth.Value, (int)numericUpDownFrameHeight.Value); this.Text = Path.GetFileName(path); m_modified = true; } else { MessageBox.Show("Maximum texture size is 2048 x 2048", "Texture Too Big"); } }
/// <summary> /// Create a texture from a byte array. /// </summary> /// <param name="bytes">The byte array to load from.</param> /// <param name="useCache">Determines if the cache should be checked first.</param> public Texture(byte[] bytes, bool useCache = true) { if (useCache) { using (MemoryStream ms = new MemoryStream(bytes)) { texture = Textures.Load(ms); } } else { using (MemoryStream ms = new MemoryStream(bytes)) { texture = new SFML.Graphics.Texture(ms); } } Source = "byte array"; texture.Smooth = DefaultSmooth; }
public ITexture LoadTextureDirect(string fullFilePath) { SFML.Graphics.Texture sfTexture = new SFML.Graphics.Texture(fullFilePath); sfTexture.Smooth = true; Texture texture = new Texture(sfTexture); return texture; }