예제 #1
0
    def setup_background(self):
        self.background_image = pygame.image.load(u'.\\res\\garage.png')
        self.screen = pygame.display.get_surface()
        self.screen.fill(BLACK)
        self.screen.blit(self.background_image, (116, 108))

        self.wall_sprites = pygame.sprite.Group()
        self.wall = collider.Collider(0, 0, 640, 150)
        self.wall_sprites.add(self.wall)
        self.wall = collider.Collider(0, 0, 140, 480)
        self.wall_sprites.add(self.wall)
        self.wall = collider.Collider(500, 0, 140, 480)
        self.wall_sprites.add(self.wall)
        self.wall = collider.Collider(0, 370, 640, 150)
        self.wall_sprites.add(self.wall)
예제 #2
0
    def __init__(self, world):
        self.world = world

        # physical variables

        self.jump_height = 1.25
        self.flying = False

        self.position = [0, 80, 0]
        self.rotation = [-math.tau / 4, 0]

        self.old_position = tuple(self.position)
        self.old_rotation = tuple(self.rotation)

        self.step = 1

        self.velocity = [0, 0, 0]
        self.accel = [0, 0, 0]

        # collision variables

        self.width = 0.6
        self.height = 1.8

        self.collider = collider.Collider()
        self.grounded = False
예제 #3
0
 def make_colliders(self, direction, door_spot, size):
     """
     Makes invisible sprites in front of doors so that
     walls can't spawn in front of them.
     """
     collider_dict = {
         "left": ((door_spot[0] + size[0]), door_spot[1]),
         "right": ((door_spot[0] - size[0]), door_spot[1]),
         "up": (door_spot[0], (door_spot[1] + size[1])),
         "down": (door_spot[0], (door_spot[1] - size[1]))
     }
     collider.Collider(collider_dict[direction], size,
                       self.collider_container)
예제 #4
0
	def __init__(self, contour):
		self.contour = contour
		# self.rotatedRect =
		self.boundingRect = cv2.boundingRect(contour)
		self.x, self.y, self.w, self.h = self.boundingRect
		self.area = self.w*self.h
		self.centerX = (self.x*2+self.w)/2
		self.centerY = (self.y*2+self.h)/2
		self.diagonalSize = math.sqrt(self.w**2+self.h**2)
		self.aspectRatio = float(self.w)/float(self.h)
		self.collider = col.Collider(self)
		self.index = -1
		self.score = 0
		self.identity = Character.identity_generated
		self.isLastChar = False
		Character.identity_generated += 1
예제 #5
0
 def make_door_locked_collider(self, group):
     self.door_locked_collider = collider.Collider(self.topleft, self.size,
                                                   group)
 def add_rect_collider(self):
     self.colliders.append(collider.Collider(self.sprite))
예제 #7
0
    def __init__(self,
                 texture_manager,
                 name="unknown",
                 block_face_textures={"all": "cobblestone"},
                 model=models.cube):
        self.name = name
        self.block_face_textures = block_face_textures
        self.model = model

        # create members based on model attributes

        self.transparent = model.transparent
        self.is_cube = model.is_cube
        self.glass = model.glass
        self.translucent = model.translucent

        # create colliders

        self.colliders = []

        for _collider in model.colliders:
            self.colliders.append(collider.Collider(*_collider))

        # replace data contained in numbers.py with model specific data

        self.vertex_positions = model.vertex_positions
        self.tex_coords = model.tex_coords  # to deprecate
        self.tex_indices = [0] * len(self.tex_coords)
        self.shading_values = model.shading_values

        def set_block_face(face, texture):
            # make sure we don't add inexistent face
            if face > len(self.tex_coords) - 1:
                return
            self.tex_indices[face] = texture

        for face in block_face_textures:
            texture = block_face_textures[face]
            texture_manager.add_texture(texture)

            texture_index = texture_manager.textures.index(texture)

            if face == "all":
                for i in range(len(self.tex_coords)):
                    set_block_face(i, texture_index)

            elif face == "sides":
                set_block_face(0, texture_index)
                set_block_face(1, texture_index)
                set_block_face(4, texture_index)
                set_block_face(5, texture_index)

            elif face == "x":
                set_block_face(0, texture_index)
                set_block_face(1, texture_index)

            elif face == "y":
                set_block_face(2, texture_index)
                set_block_face(3, texture_index)

            elif face == "z":
                set_block_face(4, texture_index)
                set_block_face(5, texture_index)

            else:
                set_block_face(
                    ["right", "left", "top", "bottom", "front",
                     "back"].index(face), texture_index)