Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Shadowblitz16

Pages: [1]
1
Graphics / Re: sf::LineShape() and sf::EllipseShape()?
« on: October 23, 2019, 03:15:59 am »
this still is inconvenient for something that is suppose to be simple and fast.
also vertices don't have collision properties so they shouldn't be used as a tutorial for a line shape.

2
Graphics / sf::LineShape() and sf::EllipseShape()?
« on: October 23, 2019, 01:33:43 am »
why isn't there a sf::LineShape() and sf::EllipseShape() in the sfml graphics library?
these are really basic shapes that should be added for ease of use.

I come from love2d where drawing a line is as simple as love.graphics.line(x1,y1,x2,y2) and a ellipse is as simple as love.graphics.ellipse(drawmode,x,y,xr,yr); and setting the width of a line shape is as easy as.. love.graphics.setlinewidth(width);

anyways missing these just doesn't sound simple or fast can they be added?

3
Graphics / Re: SFML.net How do I create a custom drawable shape?
« on: September 18, 2018, 09:31:55 pm »
I was going to make my own like lines and arcs however I wanted to test it out on a custom rectangle first

4
Graphics / SFML.net How do I create a custom drawable shape?
« on: September 16, 2018, 11:10:19 pm »
can anybody tell me how I create a custom drawable shape?
SetPoint does not exists and the GetPoint and GetPointCount are not implemented in base

Code: [Select]
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using SFML.Graphics;
using SFML.System;

namespace SFMLTest.Library.GraphicsHelpers
{
    public class RectShape : Shape, Drawable
    {
        public Vector2f Offset { get; set; } = new Vector2f(0, 0);

        public RectShape(float x, float y, float w, float z) : base()
        {
            //This method does not exist?
            SetPoint(0, x);
            SetPoint(1, y);
            SetPoint(2, x + w);
            SetPoint(3, y + h);

        }

        //WTF do i do in these methods? can't call base because its abstract
        public override uint GetPointCount()
        {
        }

        public override Vector2f GetPoint(uint index)
        {
        }
    }
}


ok so I came up with
Code: [Select]
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using SFML.Graphics;
using SFML.System;

namespace SFMLTest.GraphicsHelpers
{
    public class RectShape : Drawable
    {

        protected Vertex[] vertices;
        protected Transform transform;


        public Vector2f Pos    { get; set; } = new Vector2f(0,0);
        public Vector2f Size   { get; set; } = new Vector2f(0,0);
        public Vector2f Scale  { get; set; } = new Vector2f(1,1);
        public Vector2f Origin { get; set; } = new Vector2f(0,0);
        public float    Angle  { get; set; } = 0.0f;
        public Color    Color  { get; set; } = Color.White;


        public RectShape() : base()
        {
            vertices = new Vertex[4];
        }

        void Drawable.Draw(RenderTarget target, RenderStates states)
        {
            float x1 = Pos.X;
            float y1 = Pos.Y;
            float x2 = Pos.X + Size.X;
            float y2 = Pos.X + Size.Y;

            transform.Scale (Scale, Origin);
            transform.Rotate(Angle, Origin);

            vertices[0].Position = transform.TransformPoint(x1, y1);
            vertices[1].Position = transform.TransformPoint(x1, y2);
            vertices[2].Position = transform.TransformPoint(x2, y2);
            vertices[3].Position = transform.TransformPoint(x2, y1);
            vertices[0].Color    = Color;
            vertices[1].Color    = Color;
            vertices[2].Color    = Color;
            vertices[3].Color    = Color;
            target.Draw(vertices, PrimitiveType.Quads);
        }
       
        public uint     GetPointCount()
        {
            return (uint)vertices.Length;
        }
        public Vector2f GetPoint(uint index)
        {
            return vertices[index].Position;
        }
    }
}


however the vertices seems to always be 0,0 even though I apply the properties

5
Graphics / help drawing line in static class (SFML.Net)
« on: September 15, 2018, 09:18:32 pm »
can someone tell me why my line is not showing up in my window?
I made a graphics class that has a line drawing function
Code: [Select]
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SFML.Graphics;
using SFML.System;

namespace SFMLTest.Library
{
    struct Graphics
    {
        static RenderWindow RenderWindow;
        static RectangleShape RectangleShape;

        static public void Init(RenderWindow renderWindow)
        {
            RenderWindow = renderWindow;
            RectangleShape = new RectangleShape();
        }

        static public void Line(Color color, int x1,int y1,int x2, int y2, int thickness)
        {
            float rx1 = x1;
            float rx2 = x2;
            float ry1 = y1 - thickness;
            float ry2 = y2 + thickness;

            float rw1 = rx2 - rx1;
            float rh1 = ry2 - ry1;

            float rr1 = (float)Math.Atan2(rx2 - rx1, ry2 - ry1);

            RectangleShape.Position  = new Vector2f(rx1, ry1);
            RectangleShape.Size      = new Vector2f(rw1, rh1);
            RectangleShape.Rotation  = rr1;
            RectangleShape.Origin    = new Vector2f(x2-x1, y2-y1);
            RectangleShape.FillColor = color;
            RenderWindow.Draw(RectangleShape);
        }
    }
}

I also have this as my main window
Code: [Select]
sing System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SFML.Graphics;
using SFML.Window;

using SFMLTest.Library;

namespace SFMLTest
{
    public class Program
    {
        static RenderWindow window;

        [STAThread]
        static void Main(string[] args)
        {
            window = new RenderWindow(new VideoMode(480, 432), "MyWindow");
            window.SetActive();
            window.Closed += OnClose;

            Graphics.Init(window);

            while (window.IsOpen)
            {
                window.Clear(Color.Black);
                window.DispatchEvents();

                Graphics.Line(Color.White, 0, 0, 640, 144, 1);

                window.Display();
            }
        }

        static void OnClose(object sender, EventArgs e)
        {
            RenderWindow renderWindow = (RenderWindow)sender;
            renderWindow.Close();
        }
    }
}



however its not drawing anything

6
DotNet / Re: sfml.net compiles but doesn't let me use it in a user control
« on: February 20, 2018, 02:20:39 am »
I shouldn't have to add sfml to my path variables

this is obviously a conflict between sfml and winforms if you would like to link a sfml render window control I would be glad to try it.

7
no but I found what the issue is partially.
you can't use external libraries like smfl.net during design time.

I fixed it with the sfmlCanvas by doing..
Code: [Select]
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using SFML.Graphics;
using SFML.Window;

namespace Zelda_2_Editor
{
    public partial class SFMLCanvas : UserControl
    {
        public RenderWindow renderwindow;
        //public SFML.Graphics.Color DrawColor;
        public SFMLCanvas()
        {
            InitializeComponent();
        }

        protected override void OnLoad(EventArgs e)
        {
            if (!DesignMode)
            {
                renderwindow = new RenderWindow(this.Handle);
                //DrawColor = SFML.Graphics.Color.Black;
            }
            base.OnLoad(e);
        }

        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);
            if (!DesignMode)
            {
                Application.DoEvents();
                renderwindow.DispatchEvents();
                renderwindow.Clear(SFML.Graphics.Color.Black);
                renderwindow.Display();
            }
        }
        protected override void OnPaintBackground(PaintEventArgs pevent)
        {
            base.OnPaintBackground(pevent);
        }
    }
}
sadly it still crashes when I add that userControl to another userControl and then add that in the designer.

for example this code doesn't work because it has a sfmlCanvas in it.
Code: [Select]
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using SFML.Graphics;

namespace Zelda_2_Editor.Controls
{
    public partial class SFMLButton : UserControl
    {
        public SFMLButton()
        {
            InitializeComponent();
            //Text = "";
        }

        protected override void OnLoad(EventArgs e)
        {
            if (!DesignMode)
            {
                //sfmlCanvas.DrawColor = new SFML.Graphics.Color(BackColor.R, BackColor.G, BackColor.B);
                sfmlCanvas.Enabled = false;
            }
            base.OnLoad(e);
        }
    }
}

8
thats not much help since I have all the dlls copied to the bin/Debug folder

here is the project if you don't believe me.
https://drive.google.com/open?id=0B16wNFPwi_2kQnpINFIwVnpjWmc

9
does anybody know why my project compiles but when I try to add my SFMLCanvas to my form it throws an error?

I have don't the following..
-added sfmlnet-audio-2 to references
-added sfmlnet-graphics-2 to references
-added sfmlnet-system-2 to references
-added sfmlnet-window-2 to references

-added all extlibs to root of project and set output directory to "Copy id newer"

and this is my code..
Code: [Select]
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using SFML.Graphics;
using SFML.Window;

namespace Zelda_2_Editor
{
    public partial class SFMLCanvas : UserControl
    {
        public RenderWindow renderwindow;
        public SFMLCanvas()
        {
            InitializeComponent();
            renderwindow = new RenderWindow(this.Handle);
        }

        protected override void OnPaint(PaintEventArgs e)
        {
            System.Windows.Forms.Application.DoEvents();
            renderwindow.DispatchEvents();
            renderwindow.Clear(SFML.Graphics.Color.Green);
            renderwindow.Display();
        }
        protected override void OnPaintBackground(PaintEventArgs pevent)
        {

        }
    }
}

here is what it looks like when it happens


can somebody tell me whats wrong and how to fix it?

10
Window / Re: Static Universal input class?
« on: June 03, 2017, 11:44:05 pm »
can you provide some example code?
keyboards and gamepads have different function and do not support held down keys directly.
I need a way to tell if a key or button is pressed, held, or released and what direction and what axis the joypad and arrow keys are being held.

11
Window / Static Universal input class?
« on: May 23, 2017, 11:27:57 pm »
does anybody know how I would go about making a universal input class that is static?
I want it to auto detect whether the input is from the keyboard or from the joystick and what joystick

I wanted the syntax to work kinda like this..
Code: [Select]
Input::SetButton(ButtonType t) // << button type is the action it is getting mapped to (a, b  up, down, left, right, start, select) returns void.
Input::GetButton(ButtonType t,  ButtonState s) // << same here but takes a button state which is (down, held and up) returns bool.

ButtonType and ButtonState would be defined in the class.

does anybody know if this is possible?

12
DotNet / SFML on Custom WinForms User Control?
« on: May 06, 2017, 01:08:25 am »
can someone explain how to render a sfml canvas on a custom winforms user control?

I am trying to make so that it renders correctly when scaling, resizing, and positioning inside the vs winforms editor.

of course I want it to have a 1x, 2x, 3x, and 4x scaling options inside the editor.

this is my current code but it doesn't draw properly
Code: [Select]
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

using SFML;
using SFML.System;
using SFML.Window;
using SFML.Graphics;


namespace TileEditor1.Classes
{
    public partial class TileMap : Control
    {

        private VideoMode mode;
        private RenderWindow window;
        protected uint tileScale = 1;
        protected uint tileWidth = 16;
        protected uint tileHeight = 16;
        protected uint tileCols = 10;
        protected uint tileRows = 9;

        public TileMap()
        {
            InitializeComponent();

            mode = new VideoMode(tileCols * (tileWidth * tileScale), tileRows * (tileHeight * tileScale));
            window = new RenderWindow(mode, "SFML Editor");

            TileMap_Resize();
            TileMap_Update();

        }

        #region Properties
        public uint TileScale
        {
            get { return tileScale; }
            set { tileScale = value; TileMap_Resize(); }
        }

        public uint TileWidth
        {
            get { return tileWidth; }
            set { tileWidth= value; TileMap_Resize(); }
        }

        public uint TileHeight
        {
            get { return tileHeight ; }
            set { tileHeight = value; TileMap_Resize(); }
        }
        public uint TileColumns
        {
            get { return tileCols; }
            set { tileCols = value; TileMap_Resize(); }
        }
        public uint TileRows
        {
            get { return tileRows; }
            set { tileRows = value; TileMap_Resize(); }
        }
        #endregion

        #region Methods

        public void TileMap_Update()
        {
            while(Visible)
            {
                System.Windows.Forms.Application.DoEvents();
                window.DispatchEvents();
                window.Clear(SFML.Graphics.Color.Black);
                window.Display();
            }
        }

        public void TileMap_Resize()
        {
            Size = new Size((int)(tileCols * (tileWidth * TileScale)), (int)(tileRows * (tileHeight * tileScale)));
            window.Size = new Vector2u((tileCols * (tileWidth * TileScale)), (tileRows * (tileHeight * tileScale)));
        }

        #endregion

        #region Events

        protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
        {
            // don't call base.OnPaint(e) to prevent forground painting
            // base.OnPaint(e);
        }
        protected override void OnPaintBackground(System.Windows.Forms.PaintEventArgs pevent)
        {
            // don't call base.OnPaintBackground(e) to prevent background painting
            //base.OnPaintBackground(pevent);
        }
    }

    #endregion
}




13
Feature requests / small sf::rect suggestion
« on: May 02, 2017, 10:17:24 pm »
can the sfml devs add support "bottom" "right" and "touching()"

bottom and right would return the x2 and y2.
touching() would return true if two objects are right beside each other. but not if they are intersecting.

Pages: [1]
anything