110 lines
2.3 KiB
Plaintext
110 lines
2.3 KiB
Plaintext
:vec {
|
|
<f32> :x
|
|
<f32> :y
|
|
<f32> :z
|
|
} type
|
|
|
|
:color {
|
|
<i8> :r
|
|
<i8> :g
|
|
<i8> :b
|
|
} type
|
|
|
|
:player {
|
|
<str> :username
|
|
<vec> :pos
|
|
<color> :color
|
|
} type
|
|
|
|
:login {
|
|
<player> 0 check
|
|
<str> 1 check
|
|
|
|
(* do the login here *)
|
|
} sub
|
|
|
|
255 255 0 <color> new :purple set
|
|
|
|
:main {
|
|
800 <i32> new :screen_width set
|
|
450 <i32> new :screen_height set
|
|
|
|
argv split
|
|
<str> new :username set
|
|
<str> new :password set
|
|
|
|
username (0.0 1.0 2.0) purple <player> new :me set
|
|
password me login <(player)> new :players set
|
|
|
|
() me (:pos :x) acc push
|
|
me (:pos :y) acc 10.0 add push
|
|
me (:pos :z) acc 10.0 add push (* Camera pos *)
|
|
|
|
() me (:pos :x) acc push
|
|
me (:pos :y) acc push
|
|
me (:pos :z) acc push (* Camera looking at point *)
|
|
|
|
(0.0 1.0 0.0) (* Camera up vector(rotation towards target) *)
|
|
45.0 (* Camera field - of - view Y *)
|
|
:CAMERA_PERSPECTIVE (* Camera projection type *)
|
|
<Camera3D> new :camera set
|
|
|
|
screen_width screen_height "zwl client : raylib" init_window
|
|
60 set_target_fps
|
|
|
|
(* Main game loop *)
|
|
{
|
|
|
|
:KEY_RIGHT is_key_down {
|
|
0.2 me (:pos :x) acc inc me (:pos :x) mut :me set
|
|
true :player_updated set
|
|
} ifyes
|
|
|
|
:KEY_LEFT is_key_down {
|
|
0.2 me (:pos :x) acc dec me (:pos :x) mut :me set
|
|
true :player_updated set
|
|
} ifyes
|
|
|
|
:KEY_DOWN is_key_down {
|
|
0.2 me (:pos :z) acc inc me (:z :pos) mut :me set
|
|
true :player_updated set
|
|
} ifyes
|
|
|
|
:KEY_UP is_key_down {
|
|
0.2 me (:pos :z) acc dec me (:z :pos) mut :me set
|
|
true :player_updated set
|
|
} ifyes
|
|
|
|
camera me sync_camera
|
|
|
|
player_updated choose {
|
|
me move :players set
|
|
} ifyes {
|
|
me ping :players set
|
|
} isubo
|
|
|
|
begin_drawing
|
|
RAYWHITE clear_background
|
|
|
|
camera begin_mode_3d
|
|
|
|
(* Draw floor *)
|
|
30 1.0 draw_grid
|
|
|
|
me .pos 0.5 0.5 0.5 me .apperance draw_cube
|
|
players {
|
|
.pos 0.5 0.5 0.5 .apperance draw_cube
|
|
} map
|
|
|
|
end_mode_3d
|
|
|
|
end_drawing
|
|
}
|
|
{ window_should_close not } while (* Detect window close button or ESC key *)
|
|
|
|
:players me logout set
|
|
close_window() (*Close window and OpenGL context *)
|
|
|
|
} sub
|
|
|
|
main |