Skip to content

Commit a13c6fb

Browse files
committed
collisions images
1 parent 68d8135 commit a13c6fb

File tree

7 files changed

+21
-0
lines changed

7 files changed

+21
-0
lines changed

pygame/collisions/README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
2+
# Collisions
3+
4+
Example of collisons.
5+
6+
![Collisions #1](collisions-0.png?raw=true)
7+
8+
![Collisions #1](collisions-1.png?raw=true)
9+
10+
![Collisions #1](collisions-2.png?raw=true)
11+
12+
![Collisions #1](collisions-3.png?raw=true)
13+
14+
![Collisions #1](collisions-4.png?raw=true)
15+

pygame/collisions/collisions-0.png

15.3 KB
Loading

pygame/collisions/collisions-1.png

17.3 KB
Loading

pygame/collisions/collisions-2.png

18.6 KB
Loading

pygame/collisions/collisions-3.png

20.7 KB
Loading

pygame/collisions/collisions-4.png

21.2 KB
Loading

pygame/collisions/main_5_mouse.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/usr/bin/env python
22
#-*- coding: utf-8 -*-
33

4+
# First version for stackoverflow.com
45
# http://stackoverflow.com/questions/20180594/pygame-collision-by-sides-of-sprite
56
# https://pl.python.org/forum/index.php?topic=5727.msg24549#msg24549
67

@@ -55,9 +56,11 @@ def __init__(self, name="A", x=0, y=0, width=150, height=150, keyboard=None, mou
5556
self.keyboard = keyboard
5657
self.mouse = mouse
5758
self.mouse_move = False
59+
5860

5961
def set_center(self, screen):
6062
self.rect.center = screen.get_rect().center
63+
6164

6265
def event_handler(self, event):
6366
if self.keyboard:
@@ -95,13 +98,15 @@ def event_handler(self, event):
9598
#~ self.rect.center = event.pos
9699

97100
print event
101+
98102

99103
def update(self):
100104
# przesuwanie wszystkich kwadratow
101105
self.rect.x += self.move_x
102106
self.rect.y += self.move_y
103107
self.rect_75.center = self.rect.center
104108
self.rect_50.center = self.rect.center
109+
105110

106111
def draw(self, screen):
107112

@@ -130,6 +135,7 @@ def draw_point(self, screen, pos, collision):
130135
pygame.draw.circle(screen, GREEN, pos, 5)
131136
else:
132137
pygame.draw.circle(screen, RED, pos, 5)
138+
133139

134140
def check_collision(self, sprite):
135141
# sprawdzanie kolizji punktow w pelnym kwadracie

0 commit comments

Comments
 (0)