summaryrefslogtreecommitdiff
path: root/player.py
diff options
context:
space:
mode:
authoryuzu-eva <stevenhu@web.de>2024-09-20 18:25:40 +0200
committeryuzu-eva <stevenhu@web.de>2024-09-20 18:25:40 +0200
commita00f4cf1eb4217483408dde11d9d0c7e763ab0a2 (patch)
treed765011d7ef9ac82936493aadac40d67b351e148 /player.py
parent220e57f42fca7bd241041e5c808f62a3fa7cfa2a (diff)
added ability to shoot
Diffstat (limited to 'player.py')
-rw-r--r--player.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/player.py b/player.py
index 339b8d1..9b7f4bc 100644
--- a/player.py
+++ b/player.py
@@ -1,6 +1,7 @@
import pygame
from constants import *
from circleshape import *
+from shot import *
class Player(CircleShape):
def __init__(self, x, y):
@@ -32,8 +33,13 @@ class Player(CircleShape):
self.move(dt)
if keys[pygame.K_DOWN]:
self.move(-dt)
+ if keys[pygame.K_SPACE]:
+ self.shoot(self.position)
def move(self, dt):
forward = pygame.Vector2(0, 1).rotate(self.rotation)
self.position += forward * PLAYER_SPEED * dt
+ def shoot(self, position):
+ shot = Shot(position.x, position.y, SHOT_RADIUS)
+ shot.velocity = pygame.Vector2(0, 1).rotate(self.rotation) * PLAYER_SHOOT_SPEED