Jump to content

Problem with line drawing and moving along coordinates


przemoo83
 Share

Recommended Posts

Hi
I have these two pretty basic problems (since I'm a beginner at programming). I'm building this simple game (basic framework is hosted here: http://klimat-test.ct8.pl/).

The idea is:

1. When holding "S" key and moving a mouse around I draw the path.

2. After drawing a path I press "A" key and send player along the coordinates of the path.

 

The problems I encounter are:

1. When I draw a line fast it doesn't cover the path properly but instead it draws separated dots. I want the line to be solid

2. I don't know how to send the player along the drawn line. I want him to move slowly along from the beginning to the end. As for now the only thing what he does it to jump straight to the end of path.

 

I don't provide the code here but you can easily find it in Game.js file if you follow the link. Any feedback greatly appreciated :)

Link to comment
Share on other sites

  • 9 months later...

You're going to have to interpolate the mouse positions into a line yourself. Even when it looks solid it isn't; it's a bunch of separate points drawn very close together.

What you should do is accumulate the points of the input device into an array until the player presses A. You can then make them all into a line or a series of tweens or whatever it is.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...