Browse Source

Added cooldown mechanic

master
Unbewohnte 4 years ago
parent
commit
67bcf927ef
  1. 7
      Main.py
  2. 4
      enemy.py
  3. 20
      player.py
  4. 4
      surfaces.py

7
Main.py

@ -7,7 +7,7 @@ from bullets import *
from player import *
from enemy import *
from surfaces import Surface
######## Set up things that will not change
pygame.init()
pygame.display.set_caption('Healthless')
windowX = 640
@ -16,12 +16,11 @@ window = pygame.display.set_mode((windowX,windowY))
icon = pygame.image.load('pics/logo.png')
pygame.display.set_icon(icon)
######## Load Images
bullet_image = pygame.image.load('pics/second_bullet.png')
enemy_image = pygame.image.load('pics/32x64.png')
player_image = pygame.image.load('pics/32x64.png')
########
#rand_color = (int(random.randint(0,254)),int(random.randint(0,254)) ,int(random.randint(0,254)))
################################################################
def play():
@ -52,7 +51,7 @@ def play():
enemy.draw(window,start_color,enemy_image)
enemy.update()
if player.y == 0: #Just to try a "death"
if player.y <= 0: #Just to try a "death"
break
clock.tick(FPS)

4
enemy.py

@ -8,7 +8,7 @@ class Enemy:
def __init__(self):
self.enemy_x = 100
self.enemy_y = 100
self.en_width = 32
self.en_width = 32
self.en_height = 64
def draw(self,window,en_color,en_image):
@ -18,5 +18,5 @@ class Enemy:
self.enemy_x += 3
if self.enemy_x >= 600:
self.enemy_x = 1
def enemy_shoot(self):
def enemy_shoot(self): #Have NO IDEA how it`ll work
pass

20
player.py

@ -9,9 +9,12 @@ import sys
windowX = 640
windowY = 640
bullets_on_screen = []
clock = pygame.time.Clock()
class Player:
def __init__(self):
self.bul_cooldown = 50
self.tp_cooldown = 100
self.x = 300
self.y = 300
self.vel = 10
@ -38,10 +41,14 @@ class Player:
def shoot(self,window,start_color,bul_image):
# if self.bul_cooldown >= 1: #With cooldown the game looks not so spicy.
# self.bul_cooldown -= 2 #Maybe it will be the matter of upgrades ?
keys = pygame.key.get_pressed()
if keys[pygame.K_z]:
if keys[pygame.K_z]: # and self.bul_cooldown == 0
new_bullet = Bullet(self.x + self.width/2, self.y + 10)
bullets_on_screen.append(new_bullet)
#self.bul_cooldown = 20
if int(len(bullets_on_screen)) > 0:
for bullet in bullets_on_screen:
@ -52,7 +59,12 @@ class Player:
print('Bullets: ' + str(len(bullets_on_screen)))
def teleportation(self):
self.vel = 10
if self.tp_cooldown >= 1:
self.tp_cooldown -= 2
print('teleportation cooldown : '+ str(self.tp_cooldown))
keys = pygame.key.get_pressed()
if keys[pygame.K_d]:
self.x = randint(10,550)
self.y = randint(10,550)
if keys[pygame.K_d] and self.tp_cooldown == 0:
self.y -= 64
self.tp_cooldown = 100

4
surfaces.py

@ -2,10 +2,10 @@ import pygame
class Surface:
def __init__(self):
self.width = 64
self.width = 64
self.height = 64
def killsurf(self):
def killsurf(self): #Don`t quite understand what I`ll do with these
pass
def place(self,window,surf_x,surf_y):

Loading…
Cancel
Save