{"action":"created","issue":{"url":"https://api.github.com/repos/Reiex/Endless-caves/issues/2","labels_url":"https://api.github.com/repos/Reiex/Endless-caves/issues/2/labels{/name}","comments_url":"https://api.github.com/repos/Reiex/Endless-caves/issues/2/comments","events_url":"https://api.github.com/repos/Reiex/Endless-caves/issues/2/events","html_url":"https://github.com/Reiex/Endless-caves/issues/2","id":102602533,"number":2,"title":"[enhancement] class Hitbox, classes.py","user":{"login":"Loodoor","id":10694085,"avatar_url":"https://avatars.githubusercontent.com/u/10694085?v=3","gravatar_id":"","url":"https://api.github.com/users/Loodoor","html_url":"https://github.com/Loodoor","followers_url":"https://api.github.com/users/Loodoor/followers","following_url":"https://api.github.com/users/Loodoor/following{/other_user}","gists_url":"https://api.github.com/users/Loodoor/gists{/gist_id}","starred_url":"https://api.github.com/users/Loodoor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Loodoor/subscriptions","organizations_url":"https://api.github.com/users/Loodoor/orgs","repos_url":"https://api.github.com/users/Loodoor/repos","events_url":"https://api.github.com/users/Loodoor/events{/privacy}","received_events_url":"https://api.github.com/users/Loodoor/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-08-23T09:22:11Z","updated_at":"2015-08-23T15:19:55Z","closed_at":null,"body":"hello :D \r\n\r\nta class hitbox pourrait etre optmisée pour rendre plus facile la detection des collisions :) apres tu prends ou pas, c'est juste pour te montrer comment je ferais (c'est ce que j'utilisais en C avec la SDL, mais sous une forme un peu différente, ok ^^)\r\n\r\n```python\r\nclass Hitbox:\r\n    def __init__(self):\r\n        self.x = 0\r\n        self.y = 0\r\n        self.w = 0\r\n        self.h = 0\r\n\r\n    def set_hibox(self, new_x, new_y, new_w, new_h):\r\n        #j'utilise des accesseurs pour modifier mes variables perso :D \r\n        self.x = new_x\r\n        self.y = new_y\r\n        self.w = new_w\r\n        self.h = new_h\r\n\r\n    def move_hitbox(self, new_x, new_y):\r\n        self.x = new_x\r\n        self.y = new_y\r\n\r\n    def collide(self, hitbox):\r\n        if self.x <= hitbox.x <= self.x + self.w and self.y <= hitbox.y <= self.y + self.h:\r\n            return True\r\n        if hitbox.x <= self.x <= hitbox.x + hitbox.w and hitbox.y <= self.y <= hitbox.y + hitbox.h:\r\n            return True\r\n        return False\r\n```\r\n\r\ndans la fonction collide, ca dois te paraitre bizarre je pense.\r\nen fait je regarde si moi, je collide avec la hitbox passée en paramètre (si elle me rentre dedans). si oui, je return True pour dire : je collide !\r\npuis je regarde si la hotbox passée en paramètre collide avec moi, donc si JE suis dans cette hitbox, je fais l'inverse (sinon tu vas louper quelques collisions :/ ). si oui je return True.\r\nenfin, si aucun des 2 tests n'a renvoyé True, donc terminé la fonction, je return False, tu peux passer, il n'y a pas de collisions :)"},"comment":{"url":"https://api.github.com/repos/Reiex/Endless-caves/issues/comments/133861905","html_url":"https://github.com/Reiex/Endless-caves/issues/2#issuecomment-133861905","issue_url":"https://api.github.com/repos/Reiex/Endless-caves/issues/2","id":133861905,"user":{"login":"Reiex","id":13711225,"avatar_url":"https://avatars.githubusercontent.com/u/13711225?v=3","gravatar_id":"","url":"https://api.github.com/users/Reiex","html_url":"https://github.com/Reiex","followers_url":"https://api.github.com/users/Reiex/followers","following_url":"https://api.github.com/users/Reiex/following{/other_user}","gists_url":"https://api.github.com/users/Reiex/gists{/gist_id}","starred_url":"https://api.github.com/users/Reiex/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Reiex/subscriptions","organizations_url":"https://api.github.com/users/Reiex/orgs","repos_url":"https://api.github.com/users/Reiex/repos","events_url":"https://api.github.com/users/Reiex/events{/privacy}","received_events_url":"https://api.github.com/users/Reiex/received_events","type":"User","site_admin":false},"created_at":"2015-08-23T15:19:55Z","updated_at":"2015-08-23T15:19:55Z","body":"Pour l'instant, les méthodes de class sont un peu obscures pour moi, donc je prefere faire ça avec des fonctions, meme si c'est un peu moins lisible et ensuite... le système de hitbox, j'ai du le refaire beaucoup de fois et je suis toujours pas sûre du résultat final, bref c'est le bordel... Mais je garde ton code dans un coin de ma tete si jamais je décide de tout refaire manière POO ^^"}}