-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathobjects.py
54 lines (43 loc) · 1.44 KB
/
objects.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# -*- coding: utf-8 -*-
"""
Created on Wed Sep 28 18:09:50 2022
@author: lepas
"""
import pygame
import pytmx
def collision_objects(tmx_data):
"""
Return a list of the objects that are colliders
tmx_data: (class: pytmx.pytmx.TiledMap)
The attribute that contains the data from your tmx map.
"""
colliders = []
counter = 0
for obj in tmx_data.objects:
if obj.name != "dirt":
colliders.append(pygame.Rect(obj.x, obj.y,
obj.width, obj.height))
counter += 1
# print(obj)
# print(colliders)
return colliders
# =============================================================================
# Still draft...
# =============================================================================
# def check_collision(self, group):
# """
# Check collision and move back if there is one.
# group: (group of sprite)
# Group of sprites to check the collision for.
# """
# for sprite in group.sprites():
# if sprite.feet.collidelist(self.colliders):
# return sprite.move_back()
# # Créer fenêtre du jeu
# screen = pygame.display.set_mode((800, 600))
# pygame.display.set_caption("Pygame - first game")
# tmx_data = pytmx.util_pygame.load_pygame("ecosys_map.tmx")
# for obj in tmx_data.objects:
# if obj.name == "water":
# obj.type = "collision"
# print(obj.type)