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 - Jackieryder

Pages: [1]
1
DotNet / Re: (Help) User draw/paint pixels by pixels?
« on: April 10, 2015, 06:10:30 am »
Sorry, I think I need a little bit more clarification. By erase/draw on top of the layer, do you mean the eraser is basically the background color drawing on top of the image, or it actually remove the vertex at that point?

I get what you are trying to do with the 2 triangle thing (or atleast I think I do). What you are trying to do is creating a rectangle (or square) that will draw things in the shape of a square that take more than one pixel. I think I can do that. However I'm still not sure about what i just asked above, as far as I understand, by doing what you said I'm just drawing the color white in the shape of a square over them, which in turn of course erase the bottom layer. But that isn't what I'm looking for however. When I erase something, I want the pixel at that location to be gone, as oppose to being recolored.

2
DotNet / Re: (Help) User draw/paint pixels by pixels?
« on: April 03, 2015, 04:14:06 pm »
Would that erase at specific spot and not the whole thing? Like the eraser from Paint or Photoshop/GIMP?

What kind of primitive wuld I switch it to?

3
DotNet / Re: (Help) User draw/paint pixels by pixels?
« on: April 03, 2015, 05:19:17 am »
I didn't do what he suggested because I wasn't sure if I would be able to erase pixel by pixel if the user wanted to.

If I was to do what Nexus said, how would I click and erase whatever was at the location my mouse clicked on?

4
DotNet / Re: (Help) User draw/paint pixels by pixels?
« on: April 03, 2015, 01:04:19 am »
Update: This is what I came up with, somehow it's still not draw like i expected:

private void OnMouseMove(object sender, MouseMoveEventArgs e)
        {
            RenderWindow window = (RenderWindow)sender;
            if (Mouse.IsButtonPressed(Mouse.Button.Left))
            {
                Vector2i pos = Mouse.GetPosition(DrawWindow);
                if (pos.X >= 0 && pos.Y > 0 && pos.X < 635 && pos.Y < 635)
                {
                    distanceX = curX - pos.X;
                    distanceY = curY - pos.Y;
                    float len = (float)Math.Sqrt(distanceX * distanceX + distanceY * distanceY);
                    Console.WriteLine("\nCurX :" + curX + " CurY: " + curY + " posX: " + pos.X + " posY: " + pos.Y);
                    Console.WriteLine("Distance X: " + distanceX + " Distance Y: " + distanceY);
                    Console.WriteLine("Length: " + len);

                    rectLine.Size = new Vector2f(len, 10);
                    if (distanceX != 0)
                    {
                        rectLine.Rotation = (float)(Math.Atan2(distanceY, distanceX) * (180 / Math.PI));
                        Console.WriteLine("Rotation: " + rectLine.Rotation);
                    }
                    rectLine.Position = new Vector2f(curX, curY);

                    for (int i = 0; i < rectLine.GetPointCount(); i++)
                    {
                        imagePixels[(int)(rectLine.GetPoint((uint)i).Y * 635 + rectLine.GetPoint((uint)i).X) * 4] = MainViewer.Instance.PickedColor[0].R;
                        imagePixels[(int)(rectLine.GetPoint((uint)i).Y * 635 + rectLine.GetPoint((uint)i).X) * 4 + 1] = MainViewer.Instance.PickedColor[0].G;
                        imagePixels[(int)(rectLine.GetPoint((uint)i).Y * 635 + rectLine.GetPoint((uint)i).X) * 4 + 2] = MainViewer.Instance.PickedColor[0].B;
                        imagePixels[(int)(rectLine.GetPoint((uint)i).Y * 635 + rectLine.GetPoint((uint)i).X) * 4 + 3] = MainViewer.Instance.PickedColor[0].A;
                    }

                    drawnImage.Update(imagePixels);

                    // Definitely don't change these with every move
                    /*curX = Mouse.GetPosition(DrawWindow).X;
                    curY = Mouse.GetPosition(DrawWindow).Y;*/

                }
            }
        }


private void OnMousePress(object sender, MouseButtonEventArgs e)
        {
            RenderWindow window = (RenderWindow)sender;
            curX = Mouse.GetPosition(DrawWindow).X;
            curY = Mouse.GetPosition(DrawWindow).Y;
           
        }
 


I am not sure where the problem is. I checked my math multiple time, i'm fairly positive that it's right. The software do not draw a line at all, it still draw pixel by pixel of sort and for some reason, only draw at the very first line (y = 0) of the render window.

5
DotNet / Re: (Help) User draw/paint pixels by pixels?
« on: March 31, 2015, 12:46:50 am »
Dabbestore, you took my quote out of context

I said that when I was asking if that is how I should do the line, not for drawing pixels.

I had tried drawing/updating pixel every frame (60 frame every second) AND draw 1000 frames per second, same result. It is the input not taking the information fast enough (that why i asked about drawing lines afterward).

I'm still relatively new to SFML, so I'm not sure about VertexArray or RenderTexture, etc

6
DotNet / Re: (Help) User draw/paint pixels by pixels?
« on: March 30, 2015, 10:56:15 pm »
So if I was to draw line, I would do something kinda like:

while MouseDown, update every second (or half a second while mouse down)

get coordinate of starting point
get coordinate of the mouse after half a second or a second.
Draw a line betwene those 2 location

if mouse goes up before those time, get coordinate of the pixel at the mouse up time and draw line?

7
DotNet / Re: (Help) User draw/paint pixels by pixels?
« on: March 30, 2015, 10:43:50 pm »
I tried to use Texture.Update(byte[] pixel);

They still don't seem to draw every single pixel that I move my mouse to. For example if i was to move my mouse over a distance of 20 pixels, the software only draw the pixel at 1, 3, 5, 7, 9, 11, go on etc. And sometime this can be very sporadic.

Any other suggestion?

8
DotNet / Re: (Help) User draw/paint pixels by pixels?
« on: March 30, 2015, 09:28:50 am »
So how does Microsoft Paint or other drawing software do their drawing method?

I can't come up with any idea of how to do this efficiently at all

9
DotNet / (Help) User draw/paint pixels by pixels?
« on: March 30, 2015, 09:19:18 am »
Hi, I'm trying to create a paint software of sort. I was able to do it with the following code, however it proved to be super slow and seem to be very very inefficient; do you guys have any suggestion on how to improve it or to make it faster?

In Constructor:
 
imagePixels = new byte[1612900]; // 1612900 = 635 * 635 * 4

drawn = new SFML.Graphics.Image(635, 635, imagePixels);
drawnImage = new Texture(drawn);



In drawing loop: (toDraw is a sprite)

 
DrawWindow.DispatchEvents();
DrawWindow.Clear(SFML.Graphics.Color.Black);
ToDraw.Texture = drawnImage;
DrawWindow.Draw(ToDraw);
DrawWindow.Display();
 


In MouseMove:

 
private void OnMouseMove(object sender, MouseMoveEventArgs e)
        {
            RenderWindow window = (RenderWindow)sender;
            if (Mouse.IsButtonPressed(Mouse.Button.Left))
            {
                if (Mouse.GetPosition(DrawWindow).X >= 0 && Mouse.GetPosition(DrawWindow).Y > 0 && Mouse.GetPosition(DrawWindow).X < 635 && Mouse.GetPosition(DrawWindow).Y < 635)
                {
                    imagePixels[(Mouse.GetPosition(DrawWindow).Y * 635 + Mouse.GetPosition(DrawWindow).X) * 4] = MainViewer.Instance.PickedColor[0].R; // R?
                    imagePixels[(Mouse.GetPosition(DrawWindow).Y * 635 + Mouse.GetPosition(DrawWindow).X) * 4 + 1] = MainViewer.Instance.PickedColor[0].G; // G?
                    imagePixels[(Mouse.GetPosition(DrawWindow).Y * 635 + Mouse.GetPosition(DrawWindow).X) * 4 + 2] = MainViewer.Instance.PickedColor[0].B; // B?
                    imagePixels[(Mouse.GetPosition(DrawWindow).Y * 635 + Mouse.GetPosition(DrawWindow).X) * 4 + 3] = MainViewer.Instance.PickedColor[0].A; // A?
                    drawn = new SFML.Graphics.Image(635, 635, imagePixels);
                    drawnImage = new Texture(drawn);
                }
            }
        }
 

10
DotNet / Re: New to SFML .NET -- Some questions.
« on: March 23, 2015, 02:39:32 am »
Laurent, I'm pretty sure that's not it.

I'm having the exact problem, I can't create a user control by dragging it into the form.

The csfml-window are in both my debug folder and in the source folder. And like Fernando said: i am able to run SFML normally on the form just fine/able to create sfml RenderWindow on its own without using form just fine.

11
General / Re: Scrollable chatbox/log box
« on: April 24, 2014, 03:37:13 am »
Why would that be terrible? It sounds valid to me.

I thought because of the longer the length of the message, the longer it would take to divide it into boxes

But nevermind I was wrong, it work perfectly. What i thought is illogical since no matter what method you use the longer the message the more box is needed to  be generated lol.

Yeah nevermind

12
General / Re: Scrollable chatbox/log box
« on: April 24, 2014, 01:36:31 am »
I don't think the SFGUI isn't what I was looking for. I just wanted to be able to create a text field given the width and height, then as I type in any string, it will be wrapped according to the width of the text field.

Musn't there be any other way?

EDIT:

im using SFML.net version and notice that there is a FindCharacterPos(uint index) which apparently return a vector2f of the character at that index. Is there a way to reverse doing this? Like FindPositionCharacter(vector2f loc) which return the index of the character instead

Edit 2:

I guess I could just loop through the string (start at the index 0 of the string) and loop through, add 1 to the i everytime if the FindCharacterPos.X is less than the length. and if it is bigger than the length I could create a new string based off the substring (the index, string.length)

That would work but Imo that is a terrible way of doing it. But since I don't have any other way so while im waiting for a reply im going to test it out

13
General / Scrollable chatbox/log box
« on: April 23, 2014, 05:52:24 am »
I'm trying to code a scrollable chatbox which include the up arrow, down arrow, and obviously a scroll inbetween the 2 to scroll the chat. Let put the detail of how I'm going to set up it aside, I'm running into a few problem on how to render the text and doing text wrap to new line.

So far I have in mind is that:

Pseudo code:

class LogMessage
public LogMessage(string msg)
{
CutMessageIntoABunchOfListBasedOnMaximumLength() // this will cut the log message into individual smaller string which is just long enough to fit in a text of the same width.
}

Draw(); // draw all the string in the list of string

I'm not so sure how to code the CutMessageIntoABunchOfListBasedOnMaximumLength at all

is there a specific way to get the amount of character in a string given a font and charactersize and the width?

THis is the first time I ever tried to recreate a scroll chatbox so my structure might be terribly bad, if you have any suggestion on how to code this, please do so

Thank you

14
DotNet / Handling event in c#
« on: July 28, 2013, 05:28:00 am »
As the title said, hwo do I handle event in c#? The C# pollevent is inaccessible due to its protection level, and the only thing available is DispatchEvent, which i dont know what to do

15
General / Draw speed
« on: July 24, 2013, 09:46:36 am »
Hi guy, I am making a RPG with SFML and window forms + C#'s picturebox toolbox. So umh, at the moment all my code run properly, they work as intended, but they are really slow;

Im not sure if it because of the way I code it, but my Tile Engine's Tile placement is extremely slow. Sometime it take up to 3 sec of unresponsive before the tile is actually placed. Sometime the program even crash from "not enough memory" and also crash my facebook messager skype and chrome. I am not an expert programmer, just a hobbyist so I do not have any knowledge on code optimization and such, so dont judge me on that. Here is the 2 functions that I think should have something to deal with the speed issue:


//The MapViewer class (which is abbreviated mv)

public void Render()
        {
            _mapWindow.Clear();

            foreach (TileLayer tl in _map.myLayer)
            {
                foreach (Tile t in tl.myTile)
                {                

                    Texture tx = new Texture(Editor.Instance.curGame.GM.myResource[Editor.Instance.curGame.TM.myTileset[t.TS].ID].myTexture);
                    Sprite sp = new Sprite(tx, new IntRect(t.srcX * Editor.Instance.curGame.TileX, t.srcY * Editor.Instance.curGame.TileY, t.Width, t.Height));
                    sp.Position = new Vector2f(t.plcX * Editor.Instance.curGame.TileX, t.plcY * Editor.Instance.curGame.TileY);
                    _mapWindow.Draw(sp);


                }
            }

            _mapWindow.Display();
        }



//In the actual form:

private void picMapViewer_Click(object sender, EventArgs e)
        {
            if (Map.myLayer.Count <= 0)
                return;

            //Editor.Instance.tilesetPick
            int pickedX = mv.getMouseLoc.X + mv.xOffSet;
            int pickedY = mv.getMouseLoc.Y + mv.yOffSet;
            if (pickedX >= Map.maxX * 32)
                pickedX = Map.maxX * 32 - 1;
            if (pickedY >= Map.maxY * 32)
                pickedY = Map.maxX * 32 - 1;

            pickedX /= 32;
            pickedY /= 32;

            Tile _newTile = new Tile(Editor.Instance.tilesetPick.PickedX, Editor.Instance.tilesetPick.PickedY, pickedX, pickedY, Editor.Instance.tilesetPick.CurTS, Editor.Instance.curGame.TileX, Editor.Instance.curGame.TileY, 100);
           
            if ((int)available[lstLayer.SelectedIndex].GetValue(pickedX, pickedY) < 0)
                Map.myLayer[lstLayer.SelectedIndex].addTile(_newTile);
            else
                Map.myLayer[lstLayer.SelectedIndex].addTile(_newTile, (int)available[lstLayer.SelectedIndex].GetValue(pickedX, pickedY));

            available[lstLayer.SelectedIndex].SetValue(Map.myLayer[lstLayer.SelectedIndex].myTile.Count - 1, pickedX, pickedY);

            mv.Render();

        }


 

Here is the program without the source code, try it and see it for yourself:

https://www.dropbox.com/s/3zw1jv7kag59ztq/Debug.rar

Thank you all

Pages: [1]
anything