Пример #1
0
 def __init__(self, x=0, y=0, z=0, fov=70.0):
     self.last_mouse = ffi.new("struct Vector2 *", [0, 0])
     self.fov = fov
     self.yaw = -46.33
     self.pitch = 0.0
     self.front = glm.vec3()
     self.up = glm.vec3()
     self.right = glm.vec3()
     self.position = glm.vec3(x, y, z)
     self.world_up = glm.vec3(0, 1, 0)
     self.fps_facing = glm.vec3()
     self.movement_speed = 10
     self.mouse_sensitivity = 0.002
     self.last_time = rl.GetFrameTime()
Пример #2
0
    def process(self):
        if CTM() > self.start + 50:
            self.ang = math.radians(glm.simplex(self.pos) * 360.0)
            self.start = CTM()

        self.rot = glm.vec2(
            glm.vec4(1) * glm.rotate(glm.mat4(), self.ang, [0, 0, 1]))
        self.pre = int(self.pos.x), int(self.pos.y)
        self.pos += self.rot * rl.GetFrameTime() * 64
        rl.DrawLine(int(self.pos.x), int(self.pos.y), *self.pre, self.clr)

        if self.pos.x < 0: self.pos.x = rl.GetScreenWidth() - 1
        if self.pos.y < 0: self.pos.y = rl.GetScreenHeight() - 1
        if self.pos.x >= rl.GetScreenWidth(): self.pos.x = 0
        if self.pos.y >= rl.GetScreenHeight(): self.pos.y = 0

        hlf = self.scl // 2
        self.mem = int(self.pos.x) - hlf, int(self.pos.y) - hlf
        rl.DrawRectangle(*self.mem, self.scl if not BEES else hlf, self.scl,
                         self.clr)
        if BEES:
            rl.DrawRectangle(self.mem[0] + hlf, self.mem[1], hlf, self.scl,
                             [0, 0, 0, 55])
Пример #3
0
    def update_keyboard(self):
        boost = 4 if rl.IsKeyDown(rl.KEY_LEFT_SHIFT) else 1
        velocity = self.movement_speed * boost * rl.GetFrameTime()

        if rl.IsKeyDown(rl.KEY_W):
            self.position = self.position - self.fps_facing * velocity

        if rl.IsKeyDown(rl.KEY_S):
            self.position = self.position + self.fps_facing * velocity

        if rl.IsKeyDown(rl.KEY_D):
            dirr = glm.normalize(glm.cross(self.fps_facing, self.world_up))
            self.position = self.position - dirr * velocity

        if rl.IsKeyDown(rl.KEY_A):
            dirr = glm.normalize(glm.cross(self.fps_facing, self.world_up))
            self.position = self.position + dirr * velocity

        if rl.IsKeyDown(rl.KEY_SPACE):
            self.position = self.position + self.world_up * velocity

        if rl.IsKeyDown(rl.KEY_LEFT_CONTROL) or rl.IsKeyDown(
                rl.KEY_RIGHT_CONTROL):
            self.position = self.position - self.world_up * velocity
Пример #4
0
# start3 = [160, 160]; end3 = [144, 144]
# start4 = [160, 0]  ; end4 = [144, 16]

start1 = [0, 0]
end1 = [8, 8]
start2 = [0, 160]
end2 = [8, 152]
start3 = [160, 160]
end3 = [152, 152]
start4 = [160, 0]
end4 = [152, 8]

while not rl.WindowShouldClose():
    frame_start_time = CTM()

    elapsed += 2 * rl.GetFrameTime()
    if elapsed > 1.0:
        elapsed = 0
        start1, end1 = end1, start1
        start2, end2 = end2, start2
        start3, end3 = end3, start3
        start4, end4 = end4, start4

    mouse_pos = Vec2(rl.GetMousePosition())

    if rl.IsKeyReleased(rl.KEY_ENTER):
        window_pos = glm.vec2()
        window_vel = glm.vec2()

    if rl.CheckCollisionPointRec(list(mouse_pos), [0, 0, width, height]):
        if rl.IsMouseButtonPressed(rl.MOUSE_LEFT_BUTTON):
Пример #5
0
Файл: main.py Проект: Pebaz/awd
trans = 155
elapsed = CTM()

frames = list(pathlib.Path('data').iterdir())
frames.sort(key=lambda img: int(img.stem))
frames = [rl.LoadTexture(str(i).encode()) for i in frames]

frame_counter = 0
frame_time = CTM()
frame_flip = True
energy_ball = rl.LoadTexture(b'energy-ball.png')

while not rl.WindowShouldClose():
    frame_start_time = CTM()

    elapsed += 1 * rl.GetFrameTime()
    if elapsed > 1.0:
        elapsed = 0

    mouse_pos = Vec2(rl.GetMousePosition())

    if rl.IsKeyReleased(rl.KEY_ENTER):
        window_pos = glm.vec2()
        window_vel = glm.vec2()

    if rl.CheckCollisionPointRec(list(mouse_pos), [0, 0, width, height]):
        if rl.IsMouseButtonPressed(rl.MOUSE_LEFT_BUTTON):
            drag = True
            offset = mouse_pos

        trans = 255