Пример #1
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)
Пример #2
0
 def Set_collider(self, center, size, rotation=Quaternion(1, (0, 0, 0))):
     self.collider = Collider.Box_collider(self, center, size, rotation)
Пример #3
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