forked from JVMergulho/jogo_IP
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprojectile.py
More file actions
48 lines (31 loc) · 1.4 KB
/
projectile.py
File metadata and controls
48 lines (31 loc) · 1.4 KB
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
import pygame as pg
from pathlib import Path
import math
#Essa é a classe responsável pelos projéteis
class Projectile():
def __init__(self, player):
xcursor, ycursor = pg.mouse.get_pos() #pega as coordenadas do cursor
angulo = math.atan2(ycursor - player.y, xcursor - player.x) #pega o angulo para o cursor
self.dx = math.cos(angulo) * 8 #relaciona o cosseno do angulo adquirido a direção do eixo x
self.dy = math.sin(angulo) * 8 #relaciona o seno do angulo adquirido a direção do eixo y
self.x = player.x + 10 #adequa a saida do gas ao inseticida
self.y = player.y - 7
self.image = pg.image.load(Path('assets','gas0.png'))
self.image = pg.transform.scale(self.image, (20,20))
#self.rect = self.image.get_rect()
self.rect = pg.Rect(player.x, player.y, 15, 15)
# Quando a bala sumir do mapa
self.destroy = False
def projectile_move(self): #movimento do gas em direção ao clique
self.x = self.x + self.dx
self.y = self.y + self.dy
self.rect.x = int(self.x)
self.rect.y = int(self.y)
def trace(self, screen): #desenho do gas
screen.blit(self.image, self.rect)
def cooldown(player,cooldown,energy):
if energy == False:
cooldown=12
elif energy == True:
cooldown = -1
return cooldown