Example #1
0
 def __init__(self, pos, scale=1, **kw):
     """Initialize the game object."""
     Collider.__init__(self, kw.get('shape', Collider.ELLIPSE))
     Controllable.__init__(self, ConstantController(-1, 0))
     Movable.__init__(self, pos)
     GameObject.__init__(self, GameObject.Priority.BOSS)
     self.__sprite = Sprite('media/images/asteroid.png',
                            scale=scale, rotate=0)
Example #2
0
 def __init__(self, creator, color, origin, target, size=8):
     """Initialize the object."""
     Collider.__init__(self, Collider.LINE)
     Controllable.__init__(self, self.__controller(origin, target, size))
     Movable.__init__(self, origin)
     Hideable.__init__(self)
     GameObject.__init__(self, GameObject.Priority.PROJECTILE)
     self.__creator = type(creator)
     self.__color = color
     self.__next = None
Example #3
0
 def __init__(self, canvas, image, **kw):
     """Initialize Enemy object."""
     Controllable.__init__(self,
                           kw.get('controller', ConstantController(-1, 0)))
     Collider.__init__(self, kw.get('bounding_shape', Collider.RECT))
     Movable.__init__(
         self,
         kw.get('position', (canvas[0] + 10, randint(50, canvas[1] - 50))))
     GameObject.__init__(self, kw.get('priority', GameObject.Priority.NPC))
     self.__sprite = Sprite(image, **kw)
     x, y, *_ = self.__sprite.bounds
     self.move(x, y)
Example #4
0
 def __init__(self, creator, color, origin, direction, **kwargs):
     """Initialize the object."""
     Collider.__init__(self, Collider.LINE)
     Controllable.__init__(self, direction)
     Movable.__init__(self, origin)
     Hideable.__init__(self)
     GameObject.__init__(self, GameObject.Priority.PROJECTILE)
     self.__size = kwargs.get("size", 8)
     self.__creator = type(creator)
     self.__color = color
     self.__next = None
     self.__ignore_colision = tuple(kwargs.get('ignore_colision', ()))
Example #5
0
 def __init__(self, canvas, image, **kw):
     """Initialize Enemy object."""
     Controllable.__init__(self,
                           kw.get('controller',
                                  ConstantController(-1, 0)))
     Collider.__init__(self, kw.get('shape', Collider.RECT))
     Movable.__init__(self, kw.get('position', (canvas[0] + 10,
                                   randint(50, canvas[1] - 50))))
     Killable.__init__(self, Explosion.SMALL, time_scale=0.5)
     GameObject.__init__(self, GameObject.Priority.NPC)
     self. __sprite = Sprite(image,
                             animate=kw.get('animate', False),
                             cast_shadow=kw.get('cast_shadow', True))
Example #6
0
 def __init__(self, position, speed=5, controller=ConstantController(0, 0)):
     """Initialize the object."""
     Collider.__init__(self, Collider.RECT)
     Controllable.__init__(self, controller)
     Movable.__init__(self, position)
     Killable.__init__(self, Explosion.BIG)
     GameObject.__init__(self, GameObject.Priority.PLAYER)
     self.__original_position = position
     self.__sprite = Sprite('media/images/f18.png')
     self.__lives = 3
     self.__points = 0
     self.__speed = speed
     self.__move = (0, 0)
Example #7
0
    def Calculate_collider(self):
        min_x = None
        max_x = None
        min_y = None
        max_y = None
        min_z = None
        max_z = None
        for vertex in self.mesh.vertices_init:
            if not min_x or min_x > vertex[0]:
                min_x = vertex[0]
            if not max_x or max_x < vertex[0]:
                max_x = vertex[0]
            if not min_y or min_y > vertex[1]:
                min_y = vertex[1]
            if not max_y or max_y < vertex[1]:
                max_y = vertex[1]
            if not min_z or min_z > vertex[2]:
                min_z = vertex[2]
            if not max_z or max_z < vertex[2]:
                max_z = vertex[2]

        collider_center = ((max_x + min_x) / 2, (max_y + min_y) / 2,
                           (max_z + min_z) / 2)
        collider_size = ((max_x - min_x) / 2, (max_y - min_y) / 2,
                         (max_z - min_z) / 2)
        self.collider = Collider.Box_collider(self, collider_center,
                                              collider_size)
Example #8
0
 def Set_collider(self, center, size, rotation=Quaternion(1, (0, 0, 0))):
     self.collider = Collider.Box_collider(self, center, size, rotation)
Example #9
0
import pygame

from engine import (Collider, Color, Importer, Input, Mesh, Other, Rigidbody,
                    pyinit)
from engine.Quaternion import Quaternion
from engine.Ray import Ray
from engine.render import text_renderer
from engine.math import vector3, vector2
from engine.render import Screen
from engine.render.camera import camera

player = Mesh.Object((0, 0, 0.9))
cam = camera.Camera((0, 0, 0.9), resolution=(1366, 768))
player.add_camera(cam)
player.collider = Collider.Box_collider(player, (0, 0, 0), (0.1, 0.1, 0.85))

pygame.mixer.pre_init(44100, -16, 1, 512)
pyinit.init(camera.main_camera.resolution, "The game", "window")
pygame.mouse.set_visible(False)
pygame.event.set_grab(True)
game_exit = False
"""**********************************************************************************
**********************************************************************************
***********************************MAIN*******************************************
**********************************************************************************
**********************************************************************************"""

walk_speed = 1.5
run_speed = 3
crouch_speed = 0.8