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
|
der_test.py
|
||||||
rechner.py
|
rechner.py
|
||||||
data/
|
|
||||||
43
game.py
43
game.py
|
|
@ -1,5 +1,5 @@
|
||||||
import pygame
|
import pygame
|
||||||
import math
|
|
||||||
|
|
||||||
SCREEN_WIDTH = 1280
|
SCREEN_WIDTH = 1280
|
||||||
SCREEN_HEIGHT = 720
|
SCREEN_HEIGHT = 720
|
||||||
|
|
@ -41,12 +41,7 @@ class Game:
|
||||||
self.player_width = 20
|
self.player_width = 20
|
||||||
self.player_height = 20
|
self.player_height = 20
|
||||||
|
|
||||||
self.walls = [
|
#self.circle = pygame.geometry.Circle(self.player_pos[0], self.player_pos[1], 30)
|
||||||
pygame.Rect(100, 100, 20, 50)
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
# self.circle = pygame.geometry.Circle(self.player_pos[0], self.player_pos[1], 30)
|
|
||||||
|
|
||||||
def run(self) -> None:
|
def run(self) -> None:
|
||||||
while self.running:
|
while self.running:
|
||||||
|
|
@ -73,25 +68,12 @@ class Game:
|
||||||
self.speed = 300
|
self.speed = 300
|
||||||
|
|
||||||
# Player-Draw
|
# Player-Draw
|
||||||
# self.flashlight = pygame.draw.circle(self.display, (255, 255, 255, 0), self.flashlight_rect[0], self.flashlight_rect[1])
|
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)
|
|
||||||
|
|
||||||
pygame.draw.rect(self.display, self.color_item, self.item_rect)
|
pygame.draw.rect(self.display, self.color_item, self.item_rect)
|
||||||
|
|
||||||
pygame.draw.rect(self.display, (255, 0, 0), self.player_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
|
# Smooth Movement
|
||||||
keys = pygame.key.get_pressed()
|
keys = pygame.key.get_pressed()
|
||||||
|
|
||||||
|
|
@ -154,16 +136,19 @@ class Game:
|
||||||
|
|
||||||
return distance <= circle_r
|
return distance <= circle_r
|
||||||
|
|
||||||
def calculate_flashlight_radiate(self, degrees, start_pos, length):
|
# def ausserhalb_des_bildschirms(self, x, y, width, height):
|
||||||
angle_deg = degrees # Angle in degrees
|
# if x > width:
|
||||||
|
# return False
|
||||||
|
# if x < 0:
|
||||||
|
# return False
|
||||||
|
|
||||||
# Convert degrees to radians for math functions
|
# if y > height:
|
||||||
angle_rad = math.radians(angle_deg)
|
# return False
|
||||||
end_x = start_pos[0] + length * math.cos(angle_rad)
|
# if y < 0:
|
||||||
end_y = start_pos[1] - length * math.sin(angle_rad) # Minus because y increases downward in Pygame
|
# return False
|
||||||
end_pos = (int(end_x), int(end_y))
|
|
||||||
|
# return True
|
||||||
|
|
||||||
return end_pos
|
|
||||||
|
|
||||||
game = Game()
|
game = Game()
|
||||||
game.run()
|
game.run()
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue