Repository: openai/gym

Issue:
[Bug Report] CarRacing environment - Change of SCALE (car_racing.py) results to shifted initial position 
release 0.23.1

**Describe the bug**
Trying to run the car_racing.py with different values on track scale parameter SCALE leads to shifted starting position of the car.
While the camera starts at the expected starting position on the track, the car initial position is shifted.
 
The only parameters modified is ZOOM, reduced to 0.2 in order to make the bug visible, and SCALE in order to achieve larger tracks.

default value of SCALE: 6.0
example value of SCALE: 10.0

Below there are two examples that show the car position for 
default value of SCALE 

![281891809_420748906224647_7156620405392163796_n](https://user-images.githubusercontent.com/37153597/169799908-19bfc106-5dbe-495c-8a09-53acef7f658f.png)

and example value of SCALE.
![281920040_717363976074899_6156146512703631858_n](https://user-images.githubusercontent.com/37153597/169800078-a80babed-ef7a-40af-ba91-ff95d7152e61.png)


The initial angle position of the car is specified here:
`self.car = Car(self.world, *self.track[0][1:4])`

and it is related to first tile of the track that is generated but the visual result is different.

**System Info**
 * Anaconda environment
 * MacOS Monterey 12.3
 * Python 3.9.12

**Desired solution**
The desired behaviour would be that regardless the SCALE, the initial position of the car should match the first track tile.

I think in the previous version of CarRacing env, with pyglet, this was not an issue.


### Checklist

- [x] I have checked that there is no similar [issue](https://github.com/openai/gym/issues) in the repo (**required**)



Discussion:
Thanks for your PR, we will investigate and try to solve the issue. 
Do you have any ideas about what is going wrong in the code? 

Resolving patch:
diff --git a/gym/envs/box2d/car_dynamics.py b/gym/envs/box2d/car_dynamics.py
--- a/gym/envs/box2d/car_dynamics.py
+++ b/gym/envs/box2d/car_dynamics.py
@@ -45,9 +45,6 @@
 WHEEL_WHITE = (77, 77, 77)
 MUD_COLOR = (102, 102, 0)
 
-SCALE = 6.0  # Track scale
-PLAYFIELD = 2000 / SCALE  # Game over boundary
-
 
 class Car:
     def __init__(self, world, init_angle, init_x, init_y):
@@ -267,10 +264,7 @@ def draw(self, surface, zoom, translation, angle, draw_particles=True):
 
         if draw_particles:
             for p in self.particles:
-                poly = [
-                    (coords[0] + PLAYFIELD, coords[1] + PLAYFIELD) for coords in p.poly
-                ]
-                poly = [pygame.math.Vector2(c).rotate_rad(angle) for c in poly]
+                poly = [pygame.math.Vector2(c).rotate_rad(angle) for c in p.poly]
                 poly = [
                     (
                         coords[0] * zoom + translation[0],
@@ -286,9 +280,7 @@ def draw(self, surface, zoom, translation, angle, draw_particles=True):
             for f in obj.fixtures:
                 trans = f.body.transform
                 path = [trans * v for v in f.shape.vertices]
-                path = [
-                    (coords[0] + PLAYFIELD, coords[1] + PLAYFIELD) for coords in path
-                ]
+                path = [(coords[0], coords[1]) for coords in path]
                 path = [pygame.math.Vector2(c).rotate_rad(angle) for c in path]
                 path = [
                     (
@@ -323,10 +315,7 @@ def draw(self, surface, zoom, translation, angle, draw_particles=True):
                 ]
                 white_poly = [trans * v for v in white_poly]
 
-                white_poly = [
-                    (coords[0] + PLAYFIELD, coords[1] + PLAYFIELD)
-                    for coords in white_poly
-                ]
+                white_poly = [(coords[0], coords[1]) for coords in white_poly]
                 white_poly = [
                     pygame.math.Vector2(c).rotate_rad(angle) for c in white_poly
                 ]
diff --git a/gym/envs/box2d/car_racing.py b/gym/envs/box2d/car_racing.py
--- a/gym/envs/box2d/car_racing.py
+++ b/gym/envs/box2d/car_racing.py
@@ -513,8 +513,8 @@ def render(self, mode: str = "human"):
         angle = -self.car.hull.angle
         # Animating first second zoom.
         zoom = 0.1 * SCALE * max(1 - self.t, 0) + ZOOM * SCALE * min(self.t, 1)
-        scroll_x = -(self.car.hull.position[0] + PLAYFIELD) * zoom
-        scroll_y = -(self.car.hull.position[1] + PLAYFIELD) * zoom
+        scroll_x = -(self.car.hull.position[0]) * zoom
+        scroll_y = -(self.car.hull.position[1]) * zoom
         trans = pygame.math.Vector2((scroll_x, scroll_y)).rotate_rad(angle)
         trans = (WINDOW_W / 2 + trans[0], WINDOW_H / 4 + trans[1])
 
@@ -549,10 +549,10 @@ def render(self, mode: str = "human"):
     def _render_road(self, zoom, translation, angle):
         bounds = PLAYFIELD
         field = [
-            (2 * bounds, 2 * bounds),
-            (2 * bounds, 0),
-            (0, 0),
-            (0, 2 * bounds),
+            (bounds, bounds),
+            (bounds, -bounds),
+            (-bounds, -bounds),
+            (-bounds, bounds),
         ]
 
         # draw background
@@ -562,8 +562,8 @@ def _render_road(self, zoom, translation, angle):
 
         # draw grass patches
         grass = []
-        for x in range(0, 40, 2):
-            for y in range(0, 40, 2):
+        for x in range(-20, 20, 2):
+            for y in range(-20, 20, 2):
                 grass.append(
                     [
                         (GRASS_DIM * x + GRASS_DIM, GRASS_DIM * y + 0),
@@ -580,7 +580,7 @@ def _render_road(self, zoom, translation, angle):
         # draw road
         for poly, color in self.road_poly:
             # converting to pixel coordinates
-            poly = [(p[0] + PLAYFIELD, p[1] + PLAYFIELD) for p in poly]
+            poly = [(p[0], p[1]) for p in poly]
             color = [int(c) for c in color]
             self._draw_colored_polygon(self.surf, poly, color, zoom, translation, angle)
 


Test patch: