Compare commits
No commits in common. "215d2c486580801b2d45a449faa1c202c48d824c" and "88ead565ba3faa3751d628d5614825fa27199656" have entirely different histories.
215d2c4865
...
88ead565ba
2 changed files with 15 additions and 31 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -222,4 +222,3 @@ __marimo__/
|
|||
|
||||
der_test.py
|
||||
rechner.py
|
||||
data/
|
||||
41
game.py
41
game.py
|
|
@ -1,5 +1,5 @@
|
|||
import pygame
|
||||
import math
|
||||
|
||||
|
||||
SCREEN_WIDTH = 1280
|
||||
SCREEN_HEIGHT = 720
|
||||
|
|
@ -41,11 +41,6 @@ class Game:
|
|||
self.player_width = 20
|
||||
self.player_height = 20
|
||||
|
||||
self.walls = [
|
||||
pygame.Rect(100, 100, 20, 50)
|
||||
]
|
||||
|
||||
|
||||
#self.circle = pygame.geometry.Circle(self.player_pos[0], self.player_pos[1], 30)
|
||||
|
||||
def run(self) -> None:
|
||||
|
|
@ -73,25 +68,12 @@ class Game:
|
|||
self.speed = 300
|
||||
|
||||
# Player-Draw
|
||||
# self.flashlight = pygame.draw.circle(self.display, (255, 255, 255, 0), self.flashlight_rect[0], self.flashlight_rect[1])
|
||||
for i in range(360):
|
||||
end_pos = self.calculate_flashlight_radiate(i, self.player_pos, 50)
|
||||
|
||||
# rect = pygame.Rect(self.player_pos[0], self.player_pos[1], end_pos[0], end_pos[1])
|
||||
|
||||
# pygame.draw.rect(self.display, (255, 255, 130), rect)
|
||||
|
||||
pygame.draw.line(self.display, (255, 255, 130), self.player_pos, end_pos, width=3)
|
||||
self.flashlight = pygame.draw.circle(self.display, (255, 255, 255, 0), self.flashlight_rect[0], self.flashlight_rect[1])
|
||||
|
||||
pygame.draw.rect(self.display, self.color_item, self.item_rect)
|
||||
|
||||
pygame.draw.rect(self.display, (255, 0, 0), self.player_rect)
|
||||
|
||||
|
||||
|
||||
for wall in self.walls:
|
||||
pygame.draw.rect(self.display, "grey", wall)
|
||||
|
||||
# Smooth Movement
|
||||
keys = pygame.key.get_pressed()
|
||||
|
||||
|
|
@ -154,16 +136,19 @@ class Game:
|
|||
|
||||
return distance <= circle_r
|
||||
|
||||
def calculate_flashlight_radiate(self, degrees, start_pos, length):
|
||||
angle_deg = degrees # Angle in degrees
|
||||
# def ausserhalb_des_bildschirms(self, x, y, width, height):
|
||||
# if x > width:
|
||||
# return False
|
||||
# if x < 0:
|
||||
# return False
|
||||
|
||||
# Convert degrees to radians for math functions
|
||||
angle_rad = math.radians(angle_deg)
|
||||
end_x = start_pos[0] + length * math.cos(angle_rad)
|
||||
end_y = start_pos[1] - length * math.sin(angle_rad) # Minus because y increases downward in Pygame
|
||||
end_pos = (int(end_x), int(end_y))
|
||||
# if y > height:
|
||||
# return False
|
||||
# if y < 0:
|
||||
# return False
|
||||
|
||||
# return True
|
||||
|
||||
return end_pos
|
||||
|
||||
game = Game()
|
||||
game.run()
|
||||
|
|
|
|||
Loading…
Reference in a new issue