Exemple #1
0
 def generate(self):
     if not self.running:
         return
     window = system.get_window()
     interface = window.current_interface
     projectiles = randint(0, self.projectile_per_attack)
     for i in range(projectiles):
         # Generate projectiles right above the player
         x = randint(int(interface.border.x),
                     int(interface.border.x + interface.border.width))
         y = window.height - 100
         projectile = Projectile(src=join('images', 'meteor_sequence.png'),
                                 x=x,
                                 y=y,
                                 damage=self.base_damage,
                                 speed=self.base_speed,
                                 acceleration=self.base_acceleration,
                                 batch=self.batch,
                                 animated=True,
                                 animation_rows=1,
                                 animation_columns=4,
                                 animation_item_width=202,
                                 animation_item_height=103,
                                 animation_main_frame=0,
                                 animation_period=.25)
         # Rotate it so it points right below
         projectile.rotate(3 * pi / 2)
         self.projectiles.append(projectile)
Exemple #2
0
    def generate(self):
        window: Window = system.get_window()
        player = system.get_player()
        max_range = min(window.width // 2, window.height // 2)
        diameter = randint(300, max_range)
        degrees = randint(0, 359)
        for i in range(self.projectile_per_attack):
            theta = radians(degrees) + (
                (2 * pi) / self.projectile_per_attack) * i
            x = player.x + cos(theta) * diameter
            y = player.y + sin(theta) * diameter
            projectile = Projectile(
                src=join('images', 'staryu.png'),
                x=x,
                y=y,
                damage=self.base_damage,
                speed=self.base_speed,
                acceleration=self.base_acceleration,
                batch=self.batch,
            )
            projectile.point(player.x, player.y)
            self.set_movement(projectile, diameter)

            self.projectiles.append(projectile)
        sword_sharpen.play()
Exemple #3
0
 def attack(self):
     laser.play()
     print(system.get_enemy())
     if system.get_enemy():
         damage = config.get_config('damage') or 5
         self.projectile = Projectile(src=join('images', 'laser-04.png'),
                                      x=self.x,
                                      y=self.y,
                                      damage=damage,
                                      speed=5,
                                      acceleration=50)
         self.projectile.point(system.get_enemy().x, system.get_enemy().y)
Exemple #4
0
 def generate(self):
     window: Window = system.get_window()
     for i in range(self.projectile_per_attack):
         # Generate a projectile anywhere on the right side of the window
         x = randint(window.width // 2, window.width)
         y = randint(window.height // 2, window.height)
         projectile = Projectile(src=join('images', 'bonus-11.png'),
                                 x=x,
                                 y=y,
                                 damage=self.base_damage,
                                 speed=self.base_speed,
                                 acceleration=self.base_acceleration,
                                 batch=self.batch)
         player = system.get_player()
         projectile_generate_one.play()
         if player:
             projectile.point(player.x, player.y)
             self.projectiles.append(projectile)
Exemple #5
0
import pyglet
import time

from math import sqrt, sin, cos, acos, pi, radians

from pyglet.window import get_platform

from widgets.event_window import EventWindow
from game_objects.projectile import Projectile

platform = get_platform()
display = platform.get_default_display()
screen = display.get_default_screen()
window = pyglet.window.Window(width=screen.width, height=screen.height)
window.maximize()
projectile = Projectile(src='images/candy_cane.png')
projectile.move(window.width / 2, window.height / 2 + 100)
print(projectile.x, projectile.y)
center_x, center_y = window.width / 2, window.height / 2
radius = sqrt((projectile.x - center_x)**2 + (projectile.y - center_y)**2)
initial_x, initial_y = center_x + radius, center_y
start = time.time()
acceleration = 1


@window.event
def on_draw():
    window.clear()
    projectile.draw()

Exemple #6
0
from game_objects.projectile import Projectile
from matplotlib import pyplot as plt
from math import pi

if __name__ == '__main__':
    p = Projectile(src='images/meteor_1.png')
    images = 24
    divisor = 6
    ratio = pi/divisor
    for i in range(images):
        plt.subplot(6, 4, i+1)
        p.rotate(ratio)
        plt.imshow(p.np)
        plt.title(f'{i+1}pi/{images/2}')
        plt.xticks([])
        plt.yticks([])
    plt.show()
Exemple #7
0
import pyglet
from game_objects.projectile import Projectile
from shapes.rectangle import Rectangle

# image = cv2.imread('projectiles/minecraft_sword.png')
window = pyglet.window.Window(fullscreen=True)
projectile = Projectile(src='projectiles/minecraft_sword.png')
projectile.x = window.width / 2
projectile.y = window.height / 2
rectangle = Rectangle(x=projectile.x,
                      y=projectile.y,
                      width=projectile.width,
                      height=projectile.height,
                      color=(255, 255, 255, 255))
rectangle.x -= rectangle.width / 2
rectangle.y -= rectangle.height / 2


@window.event
def on_draw():
    window.clear()
    rectangle.draw()
    projectile.draw()


# for row in image:
#     for cell in row:
#         print(cell)

if __name__ == '__main__':
    pyglet.app.run()
Exemple #8
0
import pyglet
import cv2 as cv
import time

window = EventWindow(fullscreen=True)
# soul_image = pyglet.image.load('soul.png')
# soul = pyglet.sprite.Sprite(soul_image)
soul = Player(src='soul.png')
print(soul.width, soul.height)
print(window.width / 2, window.height / 2)
soul.move(window.width / 2 - soul.width, window.height / 2 - soul.height)
soul.scale = 1.3
print('Soul: ', soul.x, soul.y, soul.width, soul.height)
soul_np = cv.imread('soul.png')
projectile = Projectile(src='projectiles/dull_knife.png',
                        speed=10,
                        x=window.width * 0.7,
                        y=window.height)
# projectile.x = window.width / 3
# projectile.rectangle.x = projectile.x
# projectile.y = window.height / 2
# projectile.rectangle.y = projectile.y
projectile.point(soul.x, soul.y)


@window.event
def on_draw():
    window.clear()
    projectile.draw()
    soul.draw()