public override void Draw(RenderTexture tex, Vector2f scroll, bool shadow) { base.Draw(tex, scroll, shadow); if (active) { text.Font = TextureMan.Font; text.CharacterSize = 8; text.Position = new Vector2f(320 / 2.0f, 20); FloatRect textRect = text.GetLocalBounds(); text.Origin = new Vector2f(textRect.Left + textRect.Width / 2.0f, textRect.Top + textRect.Height / 2.0f); text.DisplayedString = InfoString; if (shadow) { text.Color = new Color(20, 20, 20, 40); text.Position = new Vector2f(text.Position.X - 1, text.Position.Y - 1); } else { int d; if (c * 10 > 255) d = 255; else d = c * 10; text.Color = new Color(255, 255, 255, (byte)(d)); } tex.Draw(text); } }
public MapGraphicsComponent(TmxMap Map) { var tileWidth = Map.Tilesets.Single().TileWidth; var tileHeight = Map.Tilesets.Single().TileHeight; var tileSpacing = Map.Tilesets.Single().Spacing; var tileMargins = Map.Tilesets.Single().Margin; texture = new RenderTexture((uint)(Map.Width * tileWidth), (uint)(Map.Height * tileHeight)); foreach (var layer in Map.Layers) { foreach (var tile in layer.Tiles) { var columns = (int)tileset.Texture.Size.X / (tileWidth + tileSpacing); int x = (tile.Gid - 1) % columns, y = (tile.Gid - 1) / columns; tileset.TextureRect = new IntRect(x * (tileWidth + tileSpacing) + tileMargins, y * (tileHeight + tileSpacing) + tileMargins, tileWidth, tileHeight); tileset.Position = new Vector2f(tile.X * tileWidth, tile.Y * tileHeight); texture.Draw(tileset); } } texture.Display(); Sprite = new Sprite(texture.Texture); }
public void Draw(RenderTexture texture) { Vertex[] lines = new Vertex[(endAngle - startAngle) * 2]; for(int i = startAngle; i < endAngle; i+=2) { Vector2f heading = new Vector2f((float)Math.Cos(i), (float)Math.Sin(i)); lines[i] = new Vertex(position, new Color(color.R, color.G, color.B, 255)); lines[i+1] = new Vertex(position + (heading * radius), new Color(color.R, color.G, color.B, 0)); } texture.Draw(lines, 0, (uint)(endAngle - startAngle) * 2, PrimitiveType.Lines, new RenderStates(BlendMode.Multiply)); /* VertexArray shape = new VertexArray(PrimitiveType.Points, (uint)(endAngle - startAngle) * 2); shape.Append(new Vertex(position)); for(int i = startAngle; i < endAngle; i++) { Vector2f heading = new Vector2f((float)Math.Cos(i), (float)Math.Sin(i)); heading = Util.Vector.norm(heading); shape.Append(new Vertex(position + (heading * radius))); } shape.Append(new Vertex(position)); texture.Draw(shape, new RenderStates(BlendMode.None));*/ }
private void SetupGrid(Vector2u mapSize) { const int gridSize = 16; _gridTexture = new RenderTexture(2000, 2000); var col = new Color(120, 120, 120); var verticies = new List<Vertex>(); for (int x = 0; x < mapSize.X; x += gridSize) { verticies.Add(new Vertex(new Vector2f(x, 0), col)); verticies.Add(new Vertex(new Vector2f(x, mapSize.Y), col)); } for (int y = 0; y < mapSize.Y; y += gridSize) { verticies.Add(new Vertex(new Vector2f(0, y), col)); verticies.Add(new Vertex(new Vector2f(mapSize.X, y), col)); } _gridlines = verticies.ToArray(); _gridTexture.Clear(new Color(190, 190, 190)); //_view = new View(new FloatRect(0,0,displaySize.X, displaySize.Y)); _view = new View(new FloatRect(0, 0, DisplayView.Size.X, DisplayView.Size.Y)); DisplayView = _view; //_gridTexture.SetView(_view); _gridTexture.Draw(_gridlines, PrimitiveType.Lines); _gridTexture.Display(); _grid = new Sprite(_gridTexture.Texture); AddItemToDraw(_grid, 0); }
public static bool CreateShadows() { Image img = spriteSheet.Texture.CopyToImage(); for (uint k = 0; k < img.Size.X; k++) for (uint j = 0; j < img.Size.Y; j++) { Color c = img.GetPixel(k, j); if (c.A == 255) { Color d = new Color(); d.A = 40; d.R = d.G = d.B = 0; img.SetPixel(k, j, d); } } Texture tex = new Texture(img); Sprite tempsprite = new Sprite(); tempsprite.Texture = tex; shadowSpriteSheet = new RenderTexture(textureSize, textureSize); shadowSpriteSheet.Draw(tempsprite); shadowSpriteSheet.Display(); shadowSprite.Texture = shadowSpriteSheet.Texture; img.Dispose(); tempsprite.Dispose(); tex.Dispose(); return true; }
private void GenerateSprite() { texture = new RenderTexture((uint)box.Width, (uint)box.Height); drawText = new Text(text, font); drawText.Color = foreground; texture.Draw(drawText); sprite = new Sprite(texture.Texture); }
public override void Draw(RenderTexture tex, Vector2f scroll, bool shadow) { base.Draw(tex, scroll, shadow); if (shadow) { line.Size = new Vector2f(2, hookPosY); line.Position = new Vector2f(hookPosX + 31 + Position.X - 2, Position.Y - 72 - 2); line.Position -= scroll; line.FillColor = new Color(0, 0, 0, 40); line.OutlineColor = new Color(20, 20, 20); tex.Draw(line); } for (int i = 0; i < 5; i++) { DrawSegment("cranesegment", new Vector2f(Position.X, Position.Y - i * 16 - 16), scroll, tex, shadow); } for (int i = 0; i < 7; i++) { DrawSegment("cranesegment", new Vector2f(Position.X + i * 16 + 16, Position.Y - (16 * 5)), scroll, tex, shadow); } DrawSegment("cranehook", new Vector2f(Position.X + 32 + hookPosX, Position.Y - 64 + hookPosY), scroll, tex, shadow); if (!shadow) { line.Size = new Vector2f(2, hookPosY); line.Position = new Vector2f(hookPosX + 31 + Position.X, Position.Y - 72); line.Position -= scroll; line.FillColor = new Color(20, 20, 20); line.OutlineColor = new Color(20, 20, 20); tex.Draw(line); } }
public FastTextureAtlas(TextureAtlas atlas) { TextureAtlas = atlas; _atlas = new Sprite(TextureAtlas.Texture); RenderTexture = new RenderTexture(atlas.Size, atlas.Size); RenderTexture.Draw(_atlas); RenderTexture.Display(); _replace = new RenderStates(BlendMode.None, Transform.Identity, null, null); }
private void RenderBuggy() { shapeTwo.Position = new Vector2f(Mouse.GetPosition(window).X, Mouse.GetPosition(window).Y); textureTwo.Clear(); textureTwo.Draw(shapeTwo); textureTwo.Display(); window.Clear(); var renderSprite = new Sprite(textureTwo.Texture); window.Draw(renderSprite); }
private Texture getBackgroundTexture() { var sprBack = new Sprite(Root.Singleton.Material("img/map/map_back.png")); var sprSectorBackground = new Sprite(Root.Singleton.Material(Sector.Background)); var sprMask = new Sprite(Root.Singleton.Material("img/map/map_zonemask_white.png")); var sprOverlay = new Sprite(Root.Singleton.Material("img/map/map_overlay.png")); sprBack.Position += new Vector2f(0, 28); sprSectorBackground.Position += new Vector2f(0, 28); sprMask.Position += new Vector2f(0, 28); sprOverlay.Position += new Vector2f(0, 28); var rt = new RenderTexture(1000, 1000); rt.Draw(sprBack); rt.Draw(sprSectorBackground); rt.Draw(sprMask, new RenderStates(BlendMode.Multiply)); rt.Draw(sprOverlay); rt.Display(); return new Texture(rt.Texture); }
protected void DrawSegment(string name, Vector2f pos, Vector2f scroll, RenderTexture tex, bool shadow) { Spr = TextureMan.GetSprite(name, shadow); Spr.Position = pos; if (shadow) Spr.Position = new Vector2f(pos.X - 2, pos.Y - 2); Spr.Position -= scroll; Spr.Origin = new Vector2f(8, 8); Spr.Scale = new Vector2f(1 * scaleX, 1 * scaleY); tex.Draw(Spr); }
/// <summary> /// Funkcja generuje teksture przycisku. /// </summary> /// <param name="width">Dlugosc przycisku</param> /// <param name="height">Wysokosc przycisku</param> /// <param name="color">Color przycisku</param> /// <returns>Wygenerowana tekstura</returns> public static Texture ButtonTexture(uint width, uint height, Color color) { RenderTexture renderTexture = new RenderTexture(height, width); renderTexture.Clear(Color.Transparent); RectangleShape fill = new RectangleShape(new Vector2f(height-4, width-4)) { FillColor = color, Position = new Vector2f(2, 2), OutlineThickness = 2, OutlineColor = Color.Black, }; renderTexture.Draw(fill); return new Texture(renderTexture.Texture) { Smooth = true }; }
private void RenderMoreBuggy() { textureThree.Clear(new Color( (byte)(DateTime.Now.Millisecond % 128), (byte)(DateTime.Now.Millisecond % 64), (byte)(DateTime.Now.Millisecond % 255) )); textureThree.Display(); shapeThree.Position = new Vector2f(Mouse.GetPosition(window).X, Mouse.GetPosition(window).Y); shapeThree.Rotation = 0.36f * DateTime.Now.Millisecond; textureThree.Draw(shapeThree); window.Clear(); var renderSprite = new Sprite(textureThree.Texture); window.Draw(renderSprite); }
public static bool LoadTextures() { textures = new Dictionary<string, Texture>(); spriteSheet = new RenderTexture(textureSize, textureSize); spriteSheetLocation = new Dictionary<string,Vector2i>(); spriteSheet.Clear(new Color(0, 0, 0, 0)); font = new Font(assembly.GetManifestResourceStream("TrainBox.8bit16.ttf")); textures.Add("player", new Texture(assembly.GetManifestResourceStream("TrainBox.gfx.player.png"))); textures.Add("playerwalk1", new Texture(assembly.GetManifestResourceStream("TrainBox.gfx.playerwalk1.png"))); textures.Add("playerwalk2", new Texture(assembly.GetManifestResourceStream("TrainBox.gfx.playerwalk2.png"))); textures.Add("block", new Texture(assembly.GetManifestResourceStream("TrainBox.gfx.block.png"))); textures.Add("box", new Texture(assembly.GetManifestResourceStream("TrainBox.gfx.box.png"))); textures.Add("cranebottom", new Texture(assembly.GetManifestResourceStream("TrainBox.gfx.crane1.png"))); textures.Add("cranesegment", new Texture(assembly.GetManifestResourceStream("TrainBox.gfx.crane2.png"))); textures.Add("cranehook", new Texture(assembly.GetManifestResourceStream("TrainBox.gfx.crane3.png"))); textures.Add("ladderbottom", new Texture(assembly.GetManifestResourceStream("TrainBox.gfx.ladder1.png"))); textures.Add("laddersegment", new Texture(assembly.GetManifestResourceStream("TrainBox.gfx.ladder2.png"))); textures.Add("conv1", new Texture(assembly.GetManifestResourceStream("TrainBox.gfx.conv1.png"))); textures.Add("conv2", new Texture(assembly.GetManifestResourceStream("TrainBox.gfx.conv2.png"))); textures.Add("convrail", new Texture(assembly.GetManifestResourceStream("TrainBox.gfx.conv3.png"))); textures.Add("wagon", new Texture(assembly.GetManifestResourceStream("TrainBox.gfx.wagon.png"))); textures.Add("key", new Texture(assembly.GetManifestResourceStream("TrainBox.gfx.key.png"))); textures.Add("keylock", new Texture(assembly.GetManifestResourceStream("TrainBox.gfx.keylock.png"))); textures.Add("keyblock", new Texture(assembly.GetManifestResourceStream("TrainBox.gfx.keyblock.png"))); textures.Add("dynamite", new Texture(assembly.GetManifestResourceStream("TrainBox.gfx.dynamite.png"))); textures.Add("detonator", new Texture(assembly.GetManifestResourceStream("TrainBox.gfx.detonatorbox.png"))); textures.Add("detonatorhandle", new Texture(assembly.GetManifestResourceStream("TrainBox.gfx.detonatorhandle.png"))); textures.Add("infobox", new Texture(assembly.GetManifestResourceStream("TrainBox.gfx.infobox.png"))); textures.Add("star", new Texture(assembly.GetManifestResourceStream("TrainBox.gfx.star.png"))); textures.Add("star2", new Texture(assembly.GetManifestResourceStream("TrainBox.gfx.star2.png"))); textures.Add("star3", new Texture(assembly.GetManifestResourceStream("TrainBox.gfx.star3.png"))); textures.Add("starblock", new Texture(assembly.GetManifestResourceStream("TrainBox.gfx.starblock.png"))); textures.Add("starblock2", new Texture(assembly.GetManifestResourceStream("TrainBox.gfx.starblock2.png"))); textures.Add("exit", new Texture(assembly.GetManifestResourceStream("TrainBox.gfx.exit.png"))); textures.Add("exit1", new Texture(assembly.GetManifestResourceStream("TrainBox.gfx.exit1.png"))); float x = 0; float y = 0; Sprite temp = new Sprite(); foreach (KeyValuePair<string,Texture> a in textures ) { temp.Position = new Vector2f(x, y); temp.Texture = a.Value; spriteSheet.Draw(temp); spriteSheetLocation.Add(a.Key, new Vector2i((int)x,(int)y)); x += 16; if (x > textureSize - 16) { x = 0; y += 16; } } spriteSheet.Display(); sprite.Texture = spriteSheet.Texture; textures = null; return true; }
/// <summary> /// Draw the Surface. /// </summary> /// <param name="x">The X position offset.</param> /// <param name="y">The Y position offset.</param> public override void Render(float x = 0, float y = 0) { Display(); SFMLDrawable = RenderShaders(); base.Render(x, y); if (saveNextFrame) { saveNextFrame = false; var saveTarget = new RenderTexture((uint)Width, (uint)Height); saveTarget.Draw(SFMLDrawable, states); saveTarget.Display(); saveTarget.Texture.CopyToImage().SaveToFile(saveNameFramePath); saveTarget.Dispose(); } if (AutoClear) Clear(); }
public void StartTrainBoxApp() { Level.PrepareEntityTypes(); bool quit = false; TextureMan.LoadTextures(); TextureMan.CreateShadows(); bufferSpr = new Sprite(); buffer = new RenderTexture(320, 120); buffer.Clear(Color.Black); menu.Active = true; menu.State = Menu.MenuState.Intro; menu.CounterReset(); menu.LoadLevelInfo(); while (true) { if (fullScreen) { screenSizeX = 1366; screenSizeY = 768; } else { screenSizeX = 960; screenSizeY = 540; } if (fullScreen) window = new RenderWindow(new VideoMode(screenSizeX, screenSizeY), "Super Starbox", Styles.Fullscreen); else window = new RenderWindow(new VideoMode(screenSizeX, screenSizeY), "Super Starbox", Styles.Titlebar); window.SetMouseCursorVisible(!fullScreen); window.SetVisible(true); window.Closed += new EventHandler(OnClosed); window.SetFramerateLimit(60); window.LostFocus += new EventHandler(OnLostFocus); window.GainedFocus += new EventHandler(OnGainedFocus); bool editorButtonTrigger = false; SoundMan.PlayMusic(); while (true) { buffer.Clear(Color.Black); if (!menu.Active) { level.DrawLevel(buffer); } if (fadeOut != 0) { RectangleShape rect = new RectangleShape(); rect.Position = new Vector2f(0,0); rect.Size = new Vector2f(320, 120); rect.FillColor = new Color(0, 0, 0, (byte)fadeOut); buffer.Draw(rect); } if (menu.Active) menu.Draw(buffer); if (editor.Active) editor.Draw(buffer); buffer.Display(); bufferSpr.Texture = buffer.Texture; bufferSpr.Scale = new Vector2f((screenSizeX / 320f) * screenScale, (screenSizeY / 120f) * screenScale); bufferSpr.Origin = new Vector2f(160, 60); bufferSpr.Position = new Vector2f(screenSizeX/2, screenSizeY/2); if (screenShake > 0) { bufferSpr.Position = new Vector2f(bufferSpr.Position.X + (float)new Random().Next(-200,200)/75, bufferSpr.Position.Y + (float)new Random().Next(-200,200)/75); } if (gameState == GameState.ResetFadeOut) { bufferSpr.Rotation = gameStateC / 2; screenScale = 1f + (float)gameStateC / 50f; } if (gameState == GameState.LevelFinished) { bufferSpr.Rotation = gameStateC / 2; screenScale = 1f + (float)gameStateC / 25f; } if (gameState == GameState.ResetFadeIn) { bufferSpr.Rotation = (50-gameStateC) / 2; screenScale = 1f + (float)(50 - gameStateC) / 50f; } if (gameState == GameState.GamePlay || menu.Active) { screenScale = 1; bufferSpr.Rotation = 0; } window.DispatchEvents(); window.Clear(Color.Black); window.Draw(bufferSpr); window.Display(); if (Keyboard.IsKeyPressed(Keyboard.Key.F4)) { fullScreen = !fullScreen; break; } if (Keyboard.IsKeyPressed(Keyboard.Key.F10) && false) { if (!menu.Active) if (!editorButtonTrigger) { editor.Active = !editor.Active; if (editor.Active) { editor.LevelName = levelName; level.ResetLevel(); level.ResetScrollBounds(); CollisionMan.Entities = level.GetEntities(); EntityFinder.Entities = level.GetEntities(); editor.Level = level; } else { levelName = editor.LevelName; level = editor.Level; level.FindScrollBounds(); gameState = GameState.StartLevel; } } editorButtonTrigger = true; } else editorButtonTrigger = false; if (!editor.Active && !menu.Active) { GameLoop(); } if (editor.Active) if (windowHasFocus) editor.Loop(window); if (menu.Active) { if (windowHasFocus) menu.Loop(window); if (menu.State == Menu.MenuState.Quit) { quit = true; break; } if (menu.State == Menu.MenuState.StartLevel) { levelName = menu.LevelName; menu.Active = false; level.LoadLevel(levelName); gameStateC = 0; gameState = GameState.ResetFadeIn; fadeOut = 255; CollisionMan.Entities = level.GetEntities(); EntityFinder.Entities = level.GetEntities(); } } } window.Dispose(); if (quit) break; } menu.SaveLevelInfo(); }
public virtual void Draw(RenderTexture tex, Vector2f scroll, bool shadow) { Spr = TextureMan.GetSprite(CurrentTex, shadow); Spr.Position = Position - scroll; if (shadow) { Spr.Position = new Vector2f(Spr.Position.X - 2, Spr.Position.Y - 2); } Spr.Origin = new Vector2f(8, 8 - bounceC / 3); if (Flipped) { Spr.Scale = new Vector2f(-1 * scaleX, 1 * scaleY); } else { Spr.Scale = new Vector2f(1 * scaleX, 1 * scaleY); } tex.Draw(Spr); }
/// <summary> /// Load the images for Layers and Tilesets /// </summary> public void loadImages() { tilesets.Sort(); // Sort the tileset based on his FirstGID // Loads the tilesets images from disk to memory foreach (Tileset tset in tilesets) { tset.ImageSFML = new Image(tset.ImageSource); tset.TextureSFML = new Texture(tset.ImageSFML); } // Build the image for each layer foreach (Layer layer in layers) { RenderTexture layerTexture = new RenderTexture((uint) (layer.Width*this.TileWidth), (uint) (layer.Height*this.TileHeight)); layerTexture.SetView(new View( new Vector2f((layer.Width*this.TileWidth)/2, (layer.Height*this.TileHeight)/2), new Vector2f((layer.Width*this.TileWidth), -(layer.Height*this.TileHeight)))); Sprite auxSprite; // The (x,y) coordinates IN THE LAYER, not in the spritesheet int xLoc = 0; int yLoc = 0; foreach (int data in layer.Data) { // data is the number referering a tile if(xLoc > layer.Width - 1) { xLoc = 0; yLoc += 1; } // Select the matching tileset Tileset selectedTileset = null; foreach (Tileset tset in tilesets) { if (data >= tset.FirstGID) selectedTileset = tset; else break; } if(selectedTileset != null) { // coordinates on the spritesheet int x = 1; int y = 1; int target = 1; while (target < data) { // finds the coordinate x += 1; target += 1; if(x > selectedTileset.Width) { x = 1; y += 1; } } //IntRect rect = new IntRect((x*this.TileWidth)-1, (y* this.TileHeight)-1, this.TileWidth, this.TileHeight); IntRect rect = new IntRect((x-1)* this.TileWidth, (y-1) * this.TileHeight, selectedTileset.TileWidth, selectedTileset.TileHeight); auxSprite = new Sprite(selectedTileset.TextureSFML, rect); auxSprite.Position = new Vector2f(xLoc * this.TileWidth, yLoc * this.TileHeight); //auxSprite.Scale = new Vector2f(1, -1); layerTexture.Draw(auxSprite); } xLoc += 1; // Increase the location } layer.LayeredSprite = new Sprite(layerTexture.Texture); // Add a sprite to the layer layer.LayeredSprite.Position = new Vector2f(0, 0); // Configure position } }
void DrawBackground(RenderTexture buffer) { background.Position = new Vector2f(-scroll.X % 320, -scroll.Y % 120); buffer.Draw(background); background.Position = new Vector2f(background.Position.X + 320, background.Position.Y); buffer.Draw(background); background.Position = new Vector2f(background.Position.X - 640, background.Position.Y); buffer.Draw(background); background.Position = new Vector2f(-scroll.X % 320, -scroll.Y % 120 + 120); buffer.Draw(background); background.Position = new Vector2f(background.Position.X + 320, background.Position.Y); buffer.Draw(background); background.Position = new Vector2f(background.Position.X - 640, background.Position.Y); buffer.Draw(background); background.Position = new Vector2f(-scroll.X % 320, -scroll.Y % 120 - 120); buffer.Draw(background); background.Position = new Vector2f(background.Position.X + 320, background.Position.Y); buffer.Draw(background); background.Position = new Vector2f(background.Position.X - 640, background.Position.Y); buffer.Draw(background); }
static void Main(string[] args) { RenderWindow window = new RenderWindow(new SFML.Window.VideoMode(800, 600), "Title"); RenderTexture treeTexture = new RenderTexture(800, 600); Sprite treeSprite = new Sprite(treeTexture.Texture); // List of tree nodes. List<Node> nodes = new List<Node>(); List<Node> dividedNodes = new List<Node>(); DateTime timeOfLastDraw = DateTime.Now; // Create root node. Node root = new Node(new SFML.Window.Vector2f(5, 2)); root.Origin = new SFML.Window.Vector2f(1, 0); root.Position = new SFML.Window.Vector2f(400, 600); root.FillColor = new Color(0, 200, 50); root.Generation = 1; nodes.Add(root); DateTime timeOfLastUpdate = DateTime.Now; // Loop while (window.IsOpen()) { window.Clear(Color.White); for (int i = 0; i < nodes.Count; i++) { treeTexture.Draw(nodes[i]); if (nodes[i].Divided) { dividedNodes.Add(nodes[i]); nodes.RemoveAt(i); continue; } // Grow the node until it meets its max size. else if (nodes[i].Size.Y > -25) { nodes[i].Size += new SFML.Window.Vector2f(0, -100 * (float)(Utilities.GetTimeDifference(timeOfLastUpdate))); } else // Node reached maximum size and can be cloned. { // Mark current node as divided, meaning it won't get any more branches and will be ignored by the loop. nodes[i].Divided = true; // Decide if current branch will extend. if (rnd.Next(0, 101) > 20) { nodes.Add(AddBranch(nodes[i])); } // Devide if the branch will split. if (rnd.Next(0, 101) > 40) { nodes.Add(AddBranch(nodes[i], true)); } } } timeOfLastUpdate = DateTime.Now; treeTexture.Display(); window.Draw(treeSprite); foreach (Node node in dividedNodes) { treeTexture.Draw(node); } window.Display(); } }
/// <summary> /// Funkcja generujaca pole planszy. /// </summary> /// <param name="screenSize">Rozmiar pola</param> /// <param name="color">Color pola</param> /// <returns>Wygenerowana tekstura</returns> public static Texture GenerateMapTexture(uint screenSize, Color color) { RenderTexture renderTexture = new RenderTexture(screenSize, screenSize); renderTexture.Clear(Color.Transparent); RectangleShape box = new RectangleShape(new Vector2f(screenSize-1, screenSize-1)) { Position = new Vector2f(1, 1), FillColor = color, OutlineThickness = 1, OutlineColor = Color.Black, }; renderTexture.Draw(box); return new Texture(renderTexture.Texture) { Smooth = true, }; }
void renderPoints() { points_of_all_blockdomino = new RenderTexture(image_of_blockdomino.Size.X * 7, image_of_blockdomino.Size.Y / 2); points_of_all_blockdomino.Clear(Color.Transparent); Shape circle = new CircleShape(3); //circle.Position = new Vector2f(10, 4); circle.FillColor = Color.Black; //drawable { for (int i = 1; i < 7; i++) { for (int j = 0; j < i; j++) { if (i <= 3) { circle.Position = new Vector2f(image_of_blockdomino.Size.X * (i) + image_of_blockdomino.Size.X * j / i + 5, image_of_blockdomino.Size.Y / 4 - 5); } else { if (j < (i / 2)) { circle.Position = new Vector2f(image_of_blockdomino.Size.X * (i) + image_of_blockdomino.Size.X * j / i + 7, image_of_blockdomino.Size.Y / 4 - 10); } else { circle.Position = new Vector2f(image_of_blockdomino.Size.X * (i) + image_of_blockdomino.Size.X * (j - 2) / i + 7, image_of_blockdomino.Size.Y / 4); } } points_of_all_blockdomino.Draw(circle); } } } points_of_all_blockdomino.Display(); }
private void generate_texture() { buttons = new RenderTexture(button.Size.X, button.Size.Y); buttons.Draw(new Sprite(new Texture(button))); text_on_button.Position += new Vector2f(10, button.Size.Y / 4 - 10); buttons.Draw(text_on_button); text_on_button.Position += new Vector2f(5, button.Size.Y / 2 + 3); buttons.Draw(text_on_button); buttons.Display(); }
private void renderTextures() { texture_of_all_blockdomino = new RenderTexture(image_of_blockdomino.Size.X * 7, image_of_blockdomino.Size.Y * 7); Texture block_domino = new Texture(image_of_blockdomino); block_domino.Repeated = true; Sprite newSprite = new Sprite(block_domino, new IntRect(0, 0, (int)image_of_blockdomino.Size.X * 7, (int)image_of_blockdomino.Size.Y * 7)); texture_of_all_blockdomino.Draw(newSprite); // for(int i=0 ; i<=6; i++) for (int j = 0; j <= 6; j++) { Sprite upSprite = get_point(i); upSprite.Position += new Vector2f(image_of_blockdomino.Size.X * j, image_of_blockdomino.Size.Y * i); Sprite downSprite = get_point(j); downSprite.Position += new Vector2f(image_of_blockdomino.Size.X * j, image_of_blockdomino.Size.Y * i + image_of_blockdomino.Size.Y/2); texture_of_all_blockdomino.Draw(upSprite); texture_of_all_blockdomino.Draw(downSprite); } texture_of_all_blockdomino.Display(); }
/// <summary> /// Pres the render and draw background and tiles. /// </summary> void PreRenderAndDrawBackground(RenderWindow context, Controller c) { if (PreRenderTexture == null || c.ResetGraphics) { c.ResetGraphics = false; PreRenderTexture = new RenderTexture ((uint)Game.Width, (uint)Game.Height, false); PreRenderTexture.Draw (DAO.GetSprite (Element.HDOcean)); foreach (Tile tile in c.LevelMap.CollisionTiles.Values) { tile.UpdatePosition (); PreRenderTexture.Draw (tile.DstSprite); } PreRenderTexture.Display (); BackgroundAndTilesSprite = new Sprite (PreRenderTexture.Texture); } else { context.Draw (BackgroundAndTilesSprite); } }
private Texture GetHullMeterTexture() { var sprOverlay = new Sprite(Root.Singleton.Material((100 * PlayerShip.Hull / PlayerShip.MaxHull > 25) ? "img/statusUI/top_hull.png" : "img/warnings/top_hull_red.png")); var sprMask = new Sprite(Root.Singleton.Material("img/statusUI/top_hull_bar_mask.png")); sprMask.Position = new Vector2f(11, 0); var shpBars = new RectangleShape(new Vector2f(sprMask.Texture.Size.X * PlayerShip.Hull / PlayerShip.MaxHull, sprMask.Texture.Size.Y)); shpBars.Position = new Vector2f(11, 0); shpBars.FillColor = Color.Green; var rt = new RenderTexture(sprOverlay.Texture.Size.X, sprOverlay.Texture.Size.Y); rt.Draw(shpBars); rt.Draw(sprMask, new RenderStates(BlendMode.Multiply)); rt.Draw(sprOverlay); rt.Display(); return new Texture(rt.Texture); }
/// <summary> /// Funkcja generujaca teksture istot zywych na planszy, jako figure foremna. /// </summary> /// <param name="screenSize">Rozmiar pola planzy</param> /// <param name="color">Kolor istoty</param> /// <param name="pointCount">Liczba bokow wygenerowanej figory foremnej (domyslnie - 30)</param> /// <returns>Wygenerowana tekstura</returns> public static Texture GenerateBeeingTexture(uint screenSize, Color color, uint pointCount = 30) { RenderTexture renderTexture = new RenderTexture(screenSize, screenSize); renderTexture.Clear(Color.Transparent); CircleShape circle = new CircleShape((screenSize / 2) -1, pointCount) { FillColor = color, Position = new Vector2f(1, 1), OutlineThickness = 1, OutlineColor = Color.Black, }; renderTexture.Draw(circle); return new Texture(renderTexture.Texture) { Smooth = true }; }
private static void DrawLine(RenderTexture target, Vector2f a, Vector2f b, Color col, int thickness = 1) { var shpLine = new RectangleShape(); shpLine.Size = new Vector2f((float)Math.Sqrt((b.X - a.X) * (b.X - a.X) + (b.Y - a.Y) * (b.Y - a.Y)), thickness); shpLine.Origin = shpLine.Size * 0.5f; shpLine.Position = (a + b) * 0.5f; shpLine.Rotation = (float)(Math.Atan2(b.Y - a.Y, b.X - a.X) * 180.0 / Math.PI); shpLine.FillColor = col; target.Draw(shpLine); }
public static Texture GenerateConstructTexture(uint screenSizeX, uint screenSizeY, Color color) { if ( !textures_.Keys.Contains(color) ) { RenderTexture renderTexture = new RenderTexture(screenSizeX, screenSizeY); renderTexture.Clear(Color.Transparent); RectangleShape rect = new RectangleShape(new Vector2f(screenSizeX, screenSizeY)) { FillColor = color, Position = new Vector2f(1, 1), OutlineThickness = 1, OutlineColor = Color.Black, }; renderTexture.Draw(rect); textures_[color] = new Texture(renderTexture.Texture) { Smooth = true }; } return textures_[color]; }
private static void DrawQuad(RenderTexture target, Vector2f a, Vector2f b, Color col) { var shpLine = new RectangleShape(); shpLine.Size = b - a; shpLine.Origin = shpLine.Size * 0.5f; shpLine.Position = (a + b) * 0.5f; shpLine.Rotation = 0.0f; shpLine.FillColor = col; target.Draw(shpLine); }
public void Draw(RenderTexture buffer) { buffer.Clear(new Color(0, 0, 0)); txt.Origin = new Vector2f(0, 0); if (State == MenuState.GameWon) { DrawGameWonScreen(buffer); } if (State == MenuState.LevelWon) { DrawLevelWonScreen(buffer); } if (State == MenuState.PlayMenu) { DrawPlayMenuScreen(buffer); } if (State == MenuState.MainMenu) { DrawMainMenuScreen(buffer); } if (State == MenuState.Intro) { DrawIntroScreen(buffer); } if (menuC < 25) { RectangleShape rect = new RectangleShape(); rect.Position = new Vector2f(0, 0); rect.Size = new Vector2f(320, 120); rect.FillColor = new Color(0, 0, 0, (byte)(255 - menuC * 10)); buffer.Draw(rect); } }
public void Draw(RenderTexture buffer) { cursorShape.Position = CursorPosF - Level.Scroll; cursorShape.Position = new Vector2f(cursorShape.Position.X, cursorShape.Position.Y - 16); cursorShape.Size = new Vector2f(16, 16); cursorShape.Origin = new Vector2f(0, 0); cursorShape.FillColor = new Color(0, 0, 0, 0); cursorShape.OutlineColor = new Color(255, 0, 0,128); cursorShape.OutlineThickness = 1; if (counter % 10 < 5 && !showTextWindow) { cursorEnt.Draw(buffer, Level.Scroll, false); buffer.Draw(cursorShape); } if (showTextWindow) { windowShape.Position = new Vector2f(120, 45); windowShape.Size = new Vector2f(80, 30); windowShape.FillColor = windowShape.OutlineColor = new Color(128,64,64); windowShape.OutlineThickness = 1; if (counter % 10 < 5) { text.DisplayedString = textInputString + "|"; } else text.DisplayedString = textInputString; text.Font = TextureMan.Font; text.CharacterSize = 8; text.Position = new Vector2f(123, 57); if (textInputOperation == TextInputOperation.InfoBox) text.Position = new Vector2f(0, 57); buffer.Draw(windowShape); buffer.Draw(text); if (textInputOperation == TextInputOperation.Save) { text.DisplayedString = "SAVE TO:"; } if (textInputOperation == TextInputOperation.Load) { text.DisplayedString = "LOAD FROM:"; } if (textInputOperation == TextInputOperation.InfoBox) { text.DisplayedString = "INFO BOX TEXT:"; } text.Position = new Vector2f(123, 47); buffer.Draw(text); } }