Unbewohnte
4 years ago
5 changed files with 53 additions and 38 deletions
@ -1,22 +1,23 @@ |
|||||||
import pygame |
import pygame |
||||||
import random |
import random |
||||||
|
from math import pow |
||||||
|
|
||||||
bullets_on_screen = [] |
bullets_on_screen = [] |
||||||
enemy_bul_on_screen = [] |
enemy_bul_on_screen = [] |
||||||
|
|
||||||
class Bullet: |
class Bullet: |
||||||
def __init__(self, bullet_x, bullet_y): |
def __init__(self, bullet_x, bullet_y): # y = ax^2 + bx + c __maybe ?) |
||||||
self.bullet_x = bullet_x + random.randint(-9,9) # -8 -- 8 |
self.bullet_x = bullet_x + random.randint(-9,9) # -8 -- 8 |
||||||
self.bullet_y = bullet_y |
self.bullet_y = bullet_y |
||||||
self.bullet_width = 4 |
self.bullet_width = 4 |
||||||
self.bullet_height = 12 |
self.bullet_height = 12 |
||||||
self.bullet_vel = random.randint(16,28) #12 -- 22 |
self.bullet_vel = random.randint(16,28) #12 -- 22 |
||||||
self.bullet_rect = pygame.Rect(self.bullet_x,self.bullet_y, self.bullet_width,self.bullet_height) |
|
||||||
|
self.bullet_rect = pygame.Rect(self.bullet_x,self.bullet_y,self.bullet_width,self.bullet_height) |
||||||
def draw(self,window,start_color,bullet_image): |
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)) |
pygame.draw.rect(window,start_color,self.bullet_rect) |
||||||
window.blit(bullet_image,(self.bullet_x, self.bullet_y)) |
window.blit(bullet_image,(self.bullet_rect[0],self.bullet_rect[1])) |
||||||
def move(self): |
def move(self): |
||||||
self.bullet_y -= self.bullet_vel |
self.bullet_rect[1] -= self.bullet_vel |
||||||
def movedwn(self): |
def movedwn(self): |
||||||
self.bullet_y += self.bullet_vel |
self.bullet_rect[1] += self.bullet_vel |
||||||
|
@ -0,0 +1,24 @@ |
|||||||
|
import pygame |
||||||
|
from random import randint |
||||||
|
|
||||||
|
particles_on_screen = [] |
||||||
|
|
||||||
|
class Particle: |
||||||
|
def __init__(self,x,y): |
||||||
|
self.x = x |
||||||
|
self.y = y |
||||||
|
self.width = 4 |
||||||
|
self.height = self.width |
||||||
|
self.vel = int(randint(0,3)/5) |
||||||
|
self.timer = 200 |
||||||
|
def draw(self,window): |
||||||
|
for i in range(10): |
||||||
|
pygame.draw.rect(window,(255,255,255),(self.x + randint(-30,30), self.y + randint(-30,30), self.width, self.height)) |
||||||
|
def update(self): |
||||||
|
for particle in particles_on_screen: |
||||||
|
self.timer -= 1 |
||||||
|
#self.x += self.vel - randint(1,2) |
||||||
|
self.y += self.vel |
||||||
|
if particle.timer <= 0: |
||||||
|
particles_on_screen.remove(particle) |
||||||
|
#print('Particles :',str(len(particles_on_screen))) |
Loading…
Reference in new issue