diff --git a/racer/tracks/__init__.py b/racer/tracks/__init__.py index d011005..ba4d252 100644 --- a/racer/tracks/__init__.py +++ b/racer/tracks/__init__.py @@ -1,7 +1,13 @@ from . import track1 from . import track2 +from . import track4 +from . import track5 +from . import track6 all_tracks = [ track1, track2, + track4, + track5, + track6, ] diff --git a/racer/tracks/stars.webp b/racer/tracks/stars.webp new file mode 100644 index 0000000..3db599c Binary files /dev/null and b/racer/tracks/stars.webp differ diff --git a/racer/tracks/track4.py b/racer/tracks/track4.py new file mode 100644 index 0000000..64bd95f --- /dev/null +++ b/racer/tracks/track4.py @@ -0,0 +1,15 @@ +# Path: coding-challenge-racer/extract_svg_path +import os.path + +import pygame + +name = 'Square' +background = pygame.image.load(os.path.dirname(__file__) + '/stars.webp') +scale = 1 +track_width = 30 +lines = [ + (200, 880), + (880, 880), + (880, 200), + (200, 200), +] diff --git a/racer/tracks/track5.py b/racer/tracks/track5.py new file mode 100644 index 0000000..9ffba7a --- /dev/null +++ b/racer/tracks/track5.py @@ -0,0 +1,18 @@ +# Path: coding-challenge-racer/extract_svg_path +import os.path + +import pygame + +name = 'Rectangle' +background = pygame.image.load(os.path.dirname(__file__) + '/stars.webp') +scale = 1 +track_width = 30 + +(w, h) = background.get_size() + +lines = [ + (200, 880), + (w - 200, 880), + (w - 200, 680), + (200, 680), +] diff --git a/racer/tracks/track6.py b/racer/tracks/track6.py new file mode 100644 index 0000000..937995a --- /dev/null +++ b/racer/tracks/track6.py @@ -0,0 +1,17 @@ +# Path: coding-challenge-racer/extract_svg_path +import os.path +from math import sin, cos + +import numpy as np +import pygame + +name = 'Circle' +background = pygame.image.load(os.path.dirname(__file__) + '/stars.webp') +scale = 1 +track_width = 30 + +r = (1080 - 200) / 2 +cx = r + 300 +cy = 1080 - r - 100 + +lines = [(cx + r * cos(t), cy + r * sin(t)) for t in np.linspace(0, 2 * np.pi, 40)[:-1]]