45 lines
1.4 KiB
Python
45 lines
1.4 KiB
Python
from Moon import Moon
|
|
from Praktikumsaufgaben.matrixmania.compute import rot_2D, matmul, transpose
|
|
import pygame
|
|
class Apollo(Moon):
|
|
def __init__(self) -> None:
|
|
super().__init__() #ruft den konstruktor auf vom moon
|
|
|
|
self.position_apollo = (30, 0) #koordinaten sind somit relativ zum moon und nicht zum mittelpunkt
|
|
self.theta_apollo = -2 * self.theta
|
|
self.rot_apollo = rot_2D(self.theta_apollo) #doppelt so schnell und in die ntgegengesetzte richtung
|
|
def update_game(self) -> bool:
|
|
super().update_game()
|
|
point = transpose([list(self.position_apollo)])
|
|
result = matmul(self.rot_apollo, point) #apollo wird mit dr rotationsmatrix gedreht
|
|
self.position_apollo = (result[0][0], result[1][0]) #koordinaten werden gespeichert
|
|
return True
|
|
def draw_content(self):
|
|
super().draw_content()
|
|
|
|
center_x = self.size[0] // 2 #mittelpunkt bestimmen
|
|
center_y = self.size[1] // 2
|
|
|
|
apollo_x = ( #Relative Apollo Position
|
|
center_x
|
|
+ self.position_moon[0]
|
|
+ self.position_apollo[0]
|
|
)
|
|
|
|
apollo_y = (
|
|
center_y
|
|
+ self.position_moon[1]
|
|
+ self.position_apollo[1]
|
|
)
|
|
|
|
pygame.draw.circle(
|
|
self.screen,
|
|
(255, 50, 50),
|
|
(int(apollo_x), int(apollo_y)),
|
|
5
|
|
)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
apollo = Apollo()
|
|
apollo.run() |