Skip to content

Commit

Permalink
Merge pull request Diapolo10#5 from Diapolo10/nightly
Browse files Browse the repository at this point in the history
Nightly
  • Loading branch information
Diapolo10 authored Apr 4, 2022
2 parents 2cd3052 + 9dbcea9 commit a9e27f0
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 41 deletions.
19 changes: 3 additions & 16 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name: Bug report
about: Create a report to help us improve
title: ''
labels: ''
labels: 'bug'
assignees: ''

---
Expand All @@ -13,34 +13,21 @@ A clear and concise description of what the bug is.

## To Reproduce

Steps to reproduce the behavior:
Steps to reproduce the behaviour:

1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error

## Expected behavior
## Expected behaviour

A clear and concise description of what you expected to happen.

## Screenshots

If applicable, add screenshots to help explain your problem.

## Desktop (please complete the following information)

- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- Version [e.g. 22]

## Smartphone (please complete the following information)

- Device: [e.g. iPhone6]
- OS: [e.g. iOS8.1]
- Browser [e.g. stock browser, safari]
- Version [e.g. 22]

## Additional context

Add any other context about the problem here.
31 changes: 30 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ Lorem Ipsum dolor sit amet.
<!--
_______________________________________________________________________________
## [0.1.1] - YYYY-MM-DD
## [0.1.2] - YYYY-MM-DD
In-progress update goes here.
Expand All @@ -66,6 +66,35 @@ In-progress update goes here.

_______________________________________________________________________________

## [0.2.0] - 2022-04-04

This version adds a mostly-working simulation nearly ready for prime-time.
The simulation includes a working vehicle, with laser sensors that track
the walls of the road, and working physics.

### Added

- Player vehicle
- Physics
- Laser sensors
- Track "hitboxes"
- Visible intersection points for the lasers and hitboxes
- Rudimentary displays for vehicle velocity and angle
- Basic documentation for installing and running the project

### Changed

- Updated dependencies
- Updated localisation files

### Fixed

- Linter complaints

-->

_______________________________________________________________________________

## [0.1.0] - 2021-03-24

This is the initial version of the project.
Expand Down
9 changes: 7 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,14 @@ per-file-ignores = """\
# F403: Ignore star imports
# F405: Ignore names from star imports
# E303: Ignore too many blank lines
__init__.py:F401,F403,F405\
__init__.py:F401,F403,F405 \
game.py:F401 \
"""


[tool.poetry]
name = 'rl_car'
version = '0.1.0'
version = '0.2.0'
description = "A template Poetry project structure."

authors = ["Lari Liuhamo <lari.liuhamo+pypi@gmail.com>",]
Expand Down Expand Up @@ -86,11 +87,15 @@ tox-gh-actions = '^2.9.1'

[tool.pylint.'MESSAGES CONTROL']
max-line-length = 120
max-locals = 20
disable = [
# https://vald-phoenix.github.io/pylint-errors/
'R0902', # Too many instance attributes
'R0901', # Too many ancestors
'W0223', # Abstract method not overridden
'W0511', # TO-DO -messages
'W0611', # Unused import
'E0401', # Import error
]


Expand Down
37 changes: 15 additions & 22 deletions rl_car/game.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import arcade
from PIL import Image # type: ignore
from shapely.geometry import LineString, Point, MultiPoint, MultiLineString # type: ignore
from shapely.ops import nearest_points
from shapely.ops import nearest_points # type: ignore

from config_file import ( # type: ignore
WINDOW_WIDTH,
Expand All @@ -24,7 +24,6 @@
ROOT_DIR = Path(__file__).parent
IMAGE_DIR = ROOT_DIR / 'images'
CAR_SPRITE = IMAGE_DIR / 'car.png'
# TRACK_SPRITE = IMAGE_DIR / 'track.png'
TRACK_TP_SPRITE = IMAGE_DIR / 'track_tp.png'
TRACK_BARE_SPRITE = IMAGE_DIR / 'track_bare.png'
TRACK_BORDER_SPRITE = IMAGE_DIR / 'track_border.png'
Expand Down Expand Up @@ -118,6 +117,8 @@ def __init__(self, width: int, height: int, title: str):
self.track_border_outer_sprite: Optional[arcade.Sprite] = None
self.track_inner_hitbox: arcade.PointList = []
self.track_outer_hitbox: arcade.PointList = []
self.track_inner_linestring: Optional[LineString] = None
self.track_outer_linestring: Optional[LineString] = None

# Track the current state of what key is pressed
self.left_pressed = False
Expand Down Expand Up @@ -202,42 +203,34 @@ def on_draw(self):
)
)

## OVER CONSTRUCTION ##

hitbox = MultiLineString(
(
LineString(self.track_inner_hitbox),
LineString(self.track_outer_hitbox)
)
)

for a, b in zip(laser_lines[::2], laser_lines[1::2]):
line = LineString((a, b))
x, y = b[0], b[1]
for start, stop in zip(laser_lines[::2], laser_lines[1::2]):

line = LineString((start, stop))
coord_x, coord_y = stop[0], stop[1]
colour = arcade.color.WHITE

if line.intersects(hitbox):
point = line.intersection(hitbox)

if isinstance(point, Point):
x, y = point.x, point.y
coord_x, coord_y = point.x, point.y
elif isinstance(point, LineString):
(x, y), *_ = point.coords
(coord_x, coord_y), *_ = point.coords
elif isinstance(point, MultiPoint):
points = point.geoms
# dests = nearest_points(Point(orig_x, orig_y), points)
x, y = points[0].x, points[0].y
# x, y = point[0], point[1]
colour = arcade.color.BLUE
# elif line.intersects(self.track_outer_linestring):
# point = line.intersection(self.track_inner_linestring)
# if isinstance(point, Point):
# x, y = point.x, point.y
# # print(point)
# # x, y = point[0], point[1]
# colour = arcade.color.BLUE
coord_x, coord_y = points[0].x, points[0].y

arcade.draw_circle_filled(x, y, radius=5, color=colour)
colour = arcade.color.BLUE

## UNDER CONSTRUCTION ##
arcade.draw_circle_filled(coord_x, coord_y, radius=5, color=colour)

arcade.draw_lines(laser_lines, arcade.color.RED)
arcade.draw_lines(self.track_inner_hitbox, arcade.color.YELLOW)
Expand Down Expand Up @@ -330,7 +323,7 @@ def hitbox_from_image(image_path: FilePath, hit_box_detail: float = 4.5) -> arca
hitbox.extend(hitbox[:1])
for idx in range(len(hitbox)-3, 0, -1):
hitbox.insert(idx, hitbox[idx])

return hitbox


Expand Down

0 comments on commit a9e27f0

Please sign in to comment.