<commit_before>import Entity
import pygame
import Tile
import Keyboard
import random


class Animal(Entity.Entity):


	def __init__(self,level, x, y):
		super(Animal,self).__init__(level,x,y)
		self.x = x
		self.y = y
		self.isSwimming = False
		self.isMoving = False
		self.img = pygame.image.load("animals/crab.png")
		self.basicFont = pygame.font.SysFont(None, 32)

	def hasCollided(self,xa, ya):
		xMin = 32
		xMax = 38
		yMin = 48
		yMax = 60


		for x in range(xMin,xMax):
			if self.isSolidTile(xa, ya, x, yMin):
				return True

		for x in range(xMin,xMax):
			if self.isSolidTile(xa, ya, x, yMax):
				return True

		for y in range(yMin,yMax):
			if self.isSolidTile(xa, ya, xMin, y):
				return True

		for y in range(yMin,yMax):
			if self.isSolidTile(xa, ya, xMax, y):
				return True
		return False



	def tick(self):
		global x,y
                super(Animal,self).tick()
		xa = 0
		ya = 0
		self.centreX= self.x+31
		self.centreY= self.y+63
		xx = self.centreX >>5
		yy = self.centreY >>5

                if self.ticks%random.randint(1,100)==0:
                        xa = random.randint(-4,4)

                else:
                        xa = 0

		if xa != 0 or ya != 0:
			self.isMoving = not self.move(xa, ya)
		else:
			self.isMoving = False


		if self.getTileUnder().getId() == Tile.water.getId():
			self.isSwimming = True
		else:
			self.isSwimming = False



	def render(self,screen,xoff,yoff):

                if self.isSwimming:
                        source_area = pygame.Rect((0,0), (self.img.get_width(), self.img.get_height()/2))
                        screen.blit(self.img,(self.x-xoff+16,self.y-yoff+48),source_area)
                else:
                        screen.blit(self.img, (self.x-xoff+16,self.y-yoff+16))<commit_msg>Documented Animal fixes #44<commit_after>import Entity
import pygame
import Tile
import Keyboard
import random


class Animal(Entity.Entity):


	def __init__(self,level, x, y):
		super(Animal,self).__init__(level,x,y)
		self.x = x
		self.y = y
		self.isSwimming = False
		self.isMoving = False
		self.img = pygame.image.load("animals/crab.png")
		self.basicFont = pygame.font.SysFont(None, 32)

        """Determins if the entity has collided
        @Params:
                None
        @Return:
                hasCollided(boolean): if the entity has collided
        """
	def hasCollided(self,xa, ya):
		xMin = 32
		xMax = 38
		yMin = 48
		yMax = 60


		for x in range(xMin,xMax):
			if self.isSolidTile(xa, ya, x, yMin):
				return True

		for x in range(xMin,xMax):
			if self.isSolidTile(xa, ya, x, yMax):
				return True

		for y in range(yMin,yMax):
			if self.isSolidTile(xa, ya, xMin, y):
				return True

		for y in range(yMin,yMax):
			if self.isSolidTile(xa, ya, xMax, y):
				return True
		return False


         """Updates logic associated with entity
        @Params:
                None
        @Retrun:
                None
        """
	def tick(self):
		global x,y
                super(Animal,self).tick()
		xa = 0
		ya = 0
		self.centreX= self.x+31
		self.centreY= self.y+63
		xx = self.centreX >>5
		yy = self.centreY >>5

                if self.ticks%random.randint(1,100)==0:
                        xa = random.randint(-4,4)

                else:
                        xa = 0

		if xa != 0 or ya != 0:
			self.isMoving = not self.move(xa, ya)
		else:
			self.isMoving = False


		if self.getTileUnder().getId() == Tile.water.getId():
			self.isSwimming = True
		else:
			self.isSwimming = False


        """Renders the entity to the screen
        @Params:
                screen(pygame.Surface): suface to draw to
                xoff(int): x offset of screen
                yoff(int): y offset of screen
        @Return:
                None
                
        """
	def render(self,screen,xoff,yoff):

                if self.isSwimming:
                        source_area = pygame.Rect((0,0), (self.img.get_width(), self.img.get_height()/2))
                        screen.blit(self.img,(self.x-xoff+16,self.y-yoff+48),source_area)
                else:
                        screen.blit(self.img, (self.x-xoff+16,self.y-yoff+16))
{'fraction_non_alphanumeric': 0.12352231604342581, 'fraction_numerical': 0.019300361881785282, 'mean_word_length': 1.9870317002881845, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3557124', 'n_tokens_mistral': 1691, 'n_tokens_neox': 1439, 'n_words': 342}