43 lines
1.1 KiB
Python
43 lines
1.1 KiB
Python
from game import Game
|
|
from compute import *
|
|
import pygame
|
|
WHITE = (255, 255, 255)
|
|
BLACK = (0,0,0)
|
|
EARTH_RADIUS = 100
|
|
MOON_RADIUS = 20
|
|
AP_RADIUS = 5
|
|
BLUE = (0,0, 255)
|
|
|
|
class Moon(Game):
|
|
def __init__(self, title= "Moon", fps = 60, size= (640,400)):
|
|
super().__init__(title, fps, size)
|
|
self.position_moon = (0, -500)
|
|
self.theta_1 = 0.01
|
|
self.rot_moon = rot_2D(self.theta_1)
|
|
|
|
def update_game(self):
|
|
new_position = matmul(self.rot_moon, transpose([list(self.position_moon)]))
|
|
self.position_moon = (new_position[0][0], new_position[1][0])
|
|
return True
|
|
|
|
def draw_game(self):
|
|
self.screen.fill(BLACK)
|
|
self.draw_circles()
|
|
pygame.display.flip()
|
|
|
|
def draw_circles(self):
|
|
self.draw_circle((0,0), EARTH_RADIUS, BLUE)
|
|
self.draw_circle(self.position_moon, MOON_RADIUS, WHITE)
|
|
|
|
|
|
|
|
def draw_circle(self, position, radius, color):
|
|
x = int(position[0] + self.size[0] //2)
|
|
y = int(position[1] + self.size[1] //2)
|
|
pygame.draw.circle(self.screen, color,(x,y), radius)
|
|
|
|
if __name__ == "__main__":
|
|
game = Moon()
|
|
game.run()
|
|
|