Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
1.6 kB
2
Indexable
Never
###Levels.py#####




####imports####
import pygame
import time
import random


##### functions #####

#this allows us to make an entity move towards a target


# class Entities():
#         def __init__(self,surface,rectangle):
#             self.surf = surface
#             self.rect = rectangle


#         def running(self,target,speed=2):
#             self.pos = pygame.Vector2(self.rect.center)
#             self.target = pygame.Vector2(target)
#             self.dt = speed
#             events = pygame.event.get()
#             for event in events:
#                 if event.type == pygame.QUIT:
#                     quitgame()

#             self.pos = self.pos.move_towards(target, self.dt)
#             self.rect.center = self.pos

#             gameDisplay.blit(self.surf,self.rect)



def running(surface,rectangle,target,speed=2):
            pos = pygame.Vector2(rectangle.center)
            target = pygame.Vector2(target)
            dt = speed
            events = pygame.event.get()
            for event in events:
                if event.type == pygame.QUIT:
                    quitgame()

            pos = pos.move_towards(target, dt)
            rectangle.center = pos

            gameDisplay.blit(surface,rectangle)









##### Checkpoints #####







##### Tier 1 Entities #####
speed = 2





#### basic functions and veriables ####
def quitgame():
    pygame.quit()
    quit()




size = display_width,display_height = 1080,600
gameDisplay = pygame.display.set_mode((display_width,display_height))