113 lines
2.0 KiB
Plaintext
113 lines
2.0 KiB
Plaintext
type :Vec {
|
|
f32 :x
|
|
f32 :y
|
|
f32 :z
|
|
}
|
|
|
|
type :Color {
|
|
i8 :r
|
|
i8 :g
|
|
i8 :b
|
|
}
|
|
|
|
type :Player {
|
|
Str :username
|
|
Vec :pos
|
|
Color :color
|
|
}
|
|
|
|
fn :login {
|
|
Player
|
|
str
|
|
|
|
(* do the login here *)
|
|
}
|
|
|
|
Color :purple {255 255 0}
|
|
|
|
fn :main {
|
|
i32 :screen_width 800
|
|
i32 :screen_height 450
|
|
|
|
split argv
|
|
str :username
|
|
str :password
|
|
|
|
Player :me {
|
|
username
|
|
vec {0.0 1.0 2.0}
|
|
purple
|
|
}
|
|
Player() :players { login me password }
|
|
|
|
Camera3D :camera {
|
|
vec {0.0 1.0 0.0}
|
|
i32 45.0
|
|
atom :CAMERA_PERSPECTIVE
|
|
vec {
|
|
add acc (:me :pos :x) 10.0
|
|
add acc (:me :pos :y) 10.0
|
|
acc (:me :pos :z)
|
|
}
|
|
vec {acc me :pos}
|
|
}
|
|
|
|
init_window "zwl client : raylib" screen_width screen_height
|
|
set_target_fps 60
|
|
|
|
(* Main game loop *)
|
|
while { not window_should_close } {
|
|
|
|
if {is_key_down :KEY_RIGHT} {
|
|
mut (:me :pos :x) add acc me :pos :x 0.2
|
|
set :player_updated true
|
|
}
|
|
|
|
if {is_key_down :KEY_LEFT} {
|
|
mut (:me :pos :x) sub acc me :pos :x 0.2
|
|
set :player_updated true
|
|
}
|
|
|
|
if {is_key_down :KEY_DOWN} {
|
|
mut (:me :pos :z) add acc me :pos :z 0.2
|
|
set :player_updated true
|
|
}
|
|
|
|
if {is_key_down :KEY_UP} {
|
|
mut (:me :pos :z) sub acc me :pos :z 0.2
|
|
set :player_updated true
|
|
}
|
|
|
|
sync_camera camera me
|
|
|
|
if (player_updated) {
|
|
set :players move me
|
|
} else {
|
|
set :players ping me
|
|
}
|
|
|
|
begin_drawing
|
|
clear_background RAYWHITE
|
|
|
|
begin_mode_3d camera
|
|
|
|
(* Draw floor *)
|
|
draw_grid 30 1.0
|
|
|
|
draw_cube [acc me :pos] 0.5 0.5 0.5 [acc me :apperance]
|
|
|
|
map :player players {
|
|
draw_cube [acc player :pos] 0.5 0.5 0.5 [acc player apperance]
|
|
}
|
|
|
|
end_mode_3d
|
|
|
|
end_drawing
|
|
}
|
|
(* Detect window close button or ESC key *)
|
|
|
|
set :players logout me
|
|
close_window (*Close window and OpenGL context *)
|
|
}
|
|
|
|
main |