marcoshmendes / final-lap

Control your car by coding over a virtual ECU (McLaren) framework and make the best lap your algorithm can do
MIT License
0 stars 0 forks source link

Road Draw #6

Open marcoshmendes opened 2 years ago

marcoshmendes commented 2 years ago

1 Step

OBS. Must be developed on road-draw branch https://github.com/marcoshmendes/final-lap/tree/road-draw

Create the brute road, only the cement area. This is in progress, we have a rect, but we need to draw curves right now. Current Work

scren6

This code live inside renderTrack() function. This is just for draft, after a first prototype of this step, code must be moved to a separate module, future work, just let the code where it lives right now and get focus on building the course.

The road was built using lineTo and fill from canvas api. This is just a first thinking, not the best one. So if you have a better ideia, let's share with us.

To make curves, maybe we can think about Bezier: https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/bezierCurveTo

2 Step

After create the cement area, the road must be like that:

screen1

3 Step

When we have a full track cement area, we have to build a way to determine where course starts, like a lap point like this:

screen2

We must be able to count how many laps the car did or anything like that, it is crucial have a lap point to know that it starts in this location, i don't know yet how we can get this approach, i'm open to ideas

4 Step

The road must have "separator" lines in the middle of its entire route. Like this:

screen3

An Idea is to measure the track height, and get it middle value. A way to determine where is its middle, so we can draw dashed lines

5 Step

Last but not least, The curbs, around it, just some curves, not in the entire track. The curbs in the real world has the objective of: Prevent unauthorized short-cuts and keep the racers safely on the track.

screen4

scren5