diff --git a/Main.py b/Main.py index a4f093c..0b7b665 100644 --- a/Main.py +++ b/Main.py @@ -3,11 +3,12 @@ import pygame_menu import sys import random import time -from bullets import * -from player import * -from enemy import * +from bullets import Bullet +from player import Player +from enemy import Enemy from surfaces import Surface -######## Set up things that will not change + +######## Set up things that will not change pygame.init() pygame.display.set_caption('Healthless') windowX = 640 @@ -41,7 +42,7 @@ def play(): window.fill((41, 64, 59)) # (41,64,59) - test_surface.place(window,352,352) + test_surface.place(window,100,100) player.teleportation() player.shoot(window,start_color,bullet_image) @@ -50,8 +51,14 @@ def play(): enemy.draw(window,start_color,enemy_image) enemy.update() + enemy.collision(enemy) + + if player.out_of_area(): + print(player.x, player.y) + break - if player.y <= 0: #Just to try a "death" + if enemy.out_of_area(): + print('Random is on our side') break clock.tick(FPS) diff --git a/bullets.py b/bullets.py index 650fc2c..8c98a78 100644 --- a/bullets.py +++ b/bullets.py @@ -7,7 +7,7 @@ class Bullet: self.bullet_y = bullet_y self.bullet_width = 4 self.bullet_height = 12 - self.bullet_vel = random.randint(12,22) #12 -- 22 + self.bullet_vel = random.randint(16,28) #12 -- 22 def draw(self,window,start_color,bullet_image): self.rect = pygame.draw.rect(window,start_color,(self.bullet_x,self.bullet_y,self.bullet_width,self.bullet_height)) window.blit(bullet_image,(self.bullet_x, self.bullet_y)) diff --git a/enemy.py b/enemy.py index ab11939..05aef49 100644 --- a/enemy.py +++ b/enemy.py @@ -1,8 +1,10 @@ import pygame from player import * from bullets import Bullet +from random import randint - +windowX = 640 +windowY = 640 class Enemy: def __init__(self): @@ -20,3 +22,15 @@ class Enemy: self.enemy_x = 1 def enemy_shoot(self): #Have NO IDEA how it`ll work pass + + def out_of_area(self): + if self.enemy_x > windowX or self.enemy_x < 0 or self.enemy_y > windowY or self.enemy_y < 0: + return True + else: + return False + + def collision(self,enemy): + for bullet in bullets_on_screen: + if bullet.bullet_x + bullet.bullet_width/2 >= enemy.enemy_x and bullet.bullet_x + bullet.bullet_width/2 <= enemy.enemy_x + enemy.en_width and bullet.bullet_y <= enemy.enemy_y: + enemy.enemy_x += randint(-50,50) + enemy.enemy_y += randint(-50,50) diff --git a/player.py b/player.py index 7518463..16a484a 100644 --- a/player.py +++ b/player.py @@ -64,7 +64,7 @@ class Player: print('teleportation cooldown : '+ str(self.tp_cooldown)) keys = pygame.key.get_pressed() - if keys[pygame.K_d] and keys[pygame.K_UP] and self.tp_cooldown == 0: #front-dash + if keys[pygame.K_d] and keys[pygame.K_UP] and self.tp_cooldown == 0: #forward-dash self.y -= self.height*2 self.tp_cooldown = 100 @@ -76,6 +76,17 @@ class Player: self.x += self.height*2 self.tp_cooldown = 100 - if keys[pygame.K_d] and keys[pygame.K_DOWN] and self.tp_cooldown == 0: #back-dash + if keys[pygame.K_d] and keys[pygame.K_DOWN] and self.tp_cooldown == 0: #backward-dash self.y += self.height*2 self.tp_cooldown = 100 + + # if keys[pygame.K_d] and keys[pygame.K_DOWN] and keys[pygame.K_RIGHT] and self.tp_cooldown == 0: #back-right-dash + # self.y += self.height*2 + # self.x += self.height*2 + # self.tp_cooldown = 100 + + def out_of_area(self): + if self.x > windowX or self.x < 0 or self.y > windowY or self.y < 0: + return True + else: + return False