How do I Create a Paint Game [SOLVED]

Get help using Construct 2

Post » Tue Jul 04, 2017 1:00 am

Hi, I am trying to create a system similar to MS Paint in Windows. I made this code based on a tutorial, but it does not fill the lines perfectly, nor does it smoothly, does anyone have a solution? Thank you!

Image

Image

I would like to do something like this video in the matter of the smoothness of the drawing...

https://youtube.com/watch?v=9wNqnELALy8
Last edited by willmonteirofx on Tue Jul 04, 2017 3:58 am, edited 1 time in total.
B
15
S
5
G
1
Posts: 36
Reputation: 1,605

Post » Tue Jul 04, 2017 1:42 am

This is all you do to create a smooth line. You could also create dots as well at (mouse.x, mouse.y). It will become slow over time as the number of objects gets higher. You'll probably want to draw it to a paster object or something.

global oldx=0
global oldy=0

left mouse is down
--- create line at (oldx,oldy)
--- line: set width to distance(self.x,self.y,mouse.x,mouse.y)
--- line: set angle toward (mouse.x,mouse.y)

every tick:
--- set oldx to mouse.x
--- set old.y to mouse.y
B
94
S
33
G
118
Posts: 5,394
Reputation: 75,849

Post » Tue Jul 04, 2017 2:29 am

The lines are still flawed... I do not think it will work.

Image

See if I did it right...

Image

I would like to learn how to do with Points instead of Lines...
B
15
S
5
G
1
Posts: 36
Reputation: 1,605

Post » Tue Jul 04, 2017 2:38 am

I tried to do with dots but it also did not work.

Image

Image
B
15
S
5
G
1
Posts: 36
Reputation: 1,605

Post » Tue Jul 04, 2017 2:50 am

Actually it looks like you have the sprite's origin centered. It needs to be on the left.
B
94
S
33
G
118
Posts: 5,394
Reputation: 75,849

Post » Tue Jul 04, 2017 3:30 am

That was it!

Image

Now we have another problem...

When I increase the size of the sprites to make a bigger brush, the defects reappear...

Image

Is there any way to spawn the dots at each end of the line? I think that would solve that question ... What do you think?
B
15
S
5
G
1
Posts: 36
Reputation: 1,605

Post » Tue Jul 04, 2017 3:56 am

It's solved!

Spawn a dot on the left Image Point of the LINE to cover the gap when you sharply change angles.

Image

Also a little performance, but nothing that compromises too much my goals with the application. Thank you very much!

Image

Thank you very much!
B
15
S
5
G
1
Posts: 36
Reputation: 1,605

Post » Thu Jul 13, 2017 5:20 am

R0j0, you're beautiful for this. i've hit a speedbump though. mine spawns dots intermittently, making an effect almost like an on off toggle for the spawn, always evenly spaced, so its odd. however, it could just be my pc, so i'll send a test run through to the arcade and run it through a virtual machine. however, i see that in this you set oldx and oldy every tick, but then never call on them. ive tried adjusting the origin point to the left as well as spawning on both the old and current x,y and it still seems very spotty. i've copied everything above except the dot1 dot2, as those seemingly just change the current position of 'dot1' and 'dot2' rather than spawning them, so every click it would move, unless im wrong there? idk, if you have a moment, help me out lol. thanks ahead of time.
B
25
S
14
G
1
Posts: 138
Reputation: 3,111

Post » Thu Jul 13, 2017 8:26 am

forgive me, im an idiot. fixed.
B
25
S
14
G
1
Posts: 138
Reputation: 3,111

Post » Mon Jul 17, 2017 4:39 pm

B
94
S
33
G
118
Posts: 5,394
Reputation: 75,849


Return to How do I....?

Who is online

Users browsing this forum: gameba and 7 guests