import config
import random
import pygame

from polygon import *
from point import *


class Ship(Polygon):
    def __init__(self, position, rotation, color):
        shape = [Point(0,0), Point(30,10), Point(0,20)]
        Polygon.__init__(self, shape, position, rotation, color)

    def game_logic(self, keys, newkeys):
        if self.is_active():
            if pygame.K_LEFT in keys:
                self.rotate(-1*config.SHIP_ROTATION_RATE)

            if pygame.K_RIGHT in keys:
                self.rotate(config.SHIP_ROTATION_RATE)
            
            if pygame.K_UP in keys:
                self.accelerate(config.SHIP_ACCELERATION_RATE + 1)

            if pygame.K_DOWN in keys:
                self.accelerate(config.SHIP_ACCELERATION_RATE - 1)

            self.move()


        
