From a00f4cf1eb4217483408dde11d9d0c7e763ab0a2 Mon Sep 17 00:00:00 2001 From: yuzu-eva Date: Fri, 20 Sep 2024 18:25:40 +0200 Subject: added ability to shoot --- player.py | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'player.py') 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 -- cgit v1.2.3