64 lines
1.3 KiB
Python
64 lines
1.3 KiB
Python
import pyray as RL
|
|
from pyray import (Rectangle as Rect, Vector2 as Vec2, Vector3 as Vec3, Camera3D, BoundingBox)
|
|
import math
|
|
import pdb
|
|
import random
|
|
from typing import Optional, Tuple, List
|
|
from dataclasses import dataclass, field
|
|
|
|
def dump(struct):
|
|
s = f"{RL.ffi.typeof(struct)}: (".replace('<ctype ', '').replace('>', '')
|
|
for field in dir(struct):
|
|
data = struct.__getattribute__(field)
|
|
if str(data).startswith("<cdata"):
|
|
data = dump(data)
|
|
s += f"{field}:{data} "
|
|
s += ")"
|
|
return s
|
|
|
|
screen_width = 1024
|
|
screen_height = 768
|
|
|
|
@dataclass
|
|
class World:
|
|
cam: Camera3D
|
|
frame_count: int = 0
|
|
|
|
def init() -> World:
|
|
cam = Camera3D(Vec3(0, 10, 10), Vec3(0, 0, 0), Vec3(0, 1, 0), 45, RL.CAMERA_PERSPECTIVE)
|
|
return World(cam)
|
|
|
|
def player_input(w: World):
|
|
pass
|
|
|
|
def update(w: World):
|
|
pass
|
|
|
|
def draw_3d(w: World):
|
|
pass
|
|
|
|
def draw_2d(w: World):
|
|
pass
|
|
|
|
RL.init_window(screen_width, screen_height, "Starter");
|
|
RL.set_target_fps(60)
|
|
|
|
w = init()
|
|
while not RL.window_should_close():
|
|
player_input(w)
|
|
update(w)
|
|
|
|
# Drawing
|
|
RL.begin_drawing()
|
|
RL.clear_background(RL.WHITE)
|
|
|
|
RL.begin_mode_3d(w.cam)
|
|
draw_3d(w)
|
|
RL.end_mode_3d()
|
|
|
|
draw_2d(w)
|
|
|
|
RL.end_drawing()
|
|
w.frame_count += 1
|
|
|