delete angle property

This commit is contained in:
s464947 2022-04-28 18:43:15 +02:00
parent eec3b64849
commit ab4b404ba4
2 changed files with 8 additions and 8 deletions

View File

@ -1,11 +1,12 @@
import pygame as pg import pygame as pg
import math
from settings import *
vec = pg.math.Vector2 vec = pg.math.Vector2
class aiPlayer(): class aiPlayer():
def __init__(self, player, game): def __init__(self, player, game):
self.player = player self.player = player
self.game = game self.game = game
self.angle = 0
def rotateAiPlayer(self, d: str): def rotateAiPlayer(self, d: str):
if d == 'left': if d == 'left':
@ -16,7 +17,7 @@ class aiPlayer():
def moveAiPlayer(self): def moveAiPlayer(self):
for i in range(64 * 1): for i in range(64 * 1):
self.player.pos += vec(1, 0).rotate(self.angle) self.player.pos += vec(1, 0).rotate(self.player.rot)
self.player.rect.center = self.player.pos self.player.rect.center = self.player.pos
# print(f'START COORDS: {x_s, x_bias}; CURRENT AGENT COORDS: {self.player.get_actual_coords()}') # print(f'START COORDS: {x_s, x_bias}; CURRENT AGENT COORDS: {self.player.get_actual_coords()}')
self.game.update() self.game.update()
@ -28,19 +29,18 @@ class aiPlayer():
def turn_left(self): def turn_left(self):
self.player.rot -= 90 self.player.rot -= 90
self.angle -= 90
def turn_right(self): def turn_right(self):
self.player.rot += 90 self.player.rot += 90
self.angle += 90
def startAiController(self, actions): def startAiController(self, actions):
for action in actions: for action in actions:
if action == 'forward': if action == 'forward':
self.moveAiPlayer() self.moveAiPlayer()
print(f'ROT IS {self.player.rot}') # print(f'ROT IS {self.player.rot}')
if action == 'right': if action == 'right':
self.turn_right() self.turn_right()
if action == 'left': if action == 'left':
self.turn_left() self.turn_left()
print(f'ROT: {self.player.rot}')
print("Agent pos: ", math.floor(self.player.pos[0] / TILESIZE), math.floor(self.player.pos[1] / TILESIZE))

View File

@ -24,7 +24,7 @@ class Game():
self.init_game() self.init_game()
# because dont work without data.txt # because dont work without data.txt
# self.init_bfs() # self.init_bfs()
self.init_a_star() # self.init_a_star()
self.dt = self.clock.tick(FPS) / 1000.0 self.dt = self.clock.tick(FPS) / 1000.0