import pygame

class Submarine:
    
    def __init__(self,ms_game):
        self.screen = ms_game.screen
        self.settings = ms_game.settings
        self.screen_rect = ms_game.screen.get_rect()
        self.image = pygame.image.load('submarine.bmp')
        self.rect = self.image.get_rect()
        self.rect.centerx = self.screen_rect.centerx
        self.rect.centery = self.screen_rect.centery
        self.x = float(self.rect.x)
        self.y = float(self.rect.y)
        """movement flags"""
        self.moving_left = False
        self.moving_right = False
        self.moving_up = False
        self.moving_down = False


    def movement(self):
        if self.moving_left and self.rect.left>0:
            self.x-=self.settings.sub_speed
        if self.moving_right and self.rect.right<self.screen_rect.right:
            self.x +=self.settings.sub_speed
        if self.moving_up and self.rect.top > 0:
            self.y -=self.settings.sub_speed
        if self.moving_down and self.rect.bottom < self.screen_rect.bottom:
            self.y +=self.settings.sub_speed
        self.rect.x = self.x
        self.rect.y = self.y

    def blitme(self):
        self.screen.blit(self.image,self.rect)
        
        
