c like idea
This commit is contained in:
parent
1202fdc1dd
commit
68ab786d8a
|
@ -0,0 +1,100 @@
|
||||||
|
type Color {
|
||||||
|
i8 r;
|
||||||
|
i8 g;
|
||||||
|
i8 b;
|
||||||
|
}
|
||||||
|
|
||||||
|
type Player {
|
||||||
|
str username;
|
||||||
|
f32[] pos;
|
||||||
|
Color color;
|
||||||
|
}
|
||||||
|
|
||||||
|
void login(Player p, str password) {
|
||||||
|
(* do the login here *)
|
||||||
|
}
|
||||||
|
|
||||||
|
Color purple(255, 255, 0);
|
||||||
|
|
||||||
|
void main(int argc, str[] argv) {
|
||||||
|
i32 screen_width = 800;
|
||||||
|
i32 screen_height = 450;
|
||||||
|
|
||||||
|
str username = argv[0];
|
||||||
|
str password = argv[1];
|
||||||
|
|
||||||
|
Player me(
|
||||||
|
username,
|
||||||
|
[0.0, 1.0, 2.0],
|
||||||
|
purple
|
||||||
|
);
|
||||||
|
Player[] players = login(me, password);
|
||||||
|
|
||||||
|
Camera3D camera(
|
||||||
|
[0.0, 1.0, 0.0]
|
||||||
|
45.0,
|
||||||
|
:CAMERA_PERSPECTIVE,
|
||||||
|
[
|
||||||
|
me.pos.x + 10.0,
|
||||||
|
me.pos.y + 10.0,
|
||||||
|
me.pos.z
|
||||||
|
]
|
||||||
|
[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)) {
|
||||||
|
me.pos.x = me.pos.x + 0.2;
|
||||||
|
player_updated = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (is_key_down(:KEY_LEFT)) {
|
||||||
|
me.pos.x = me.pos.x - 0.2;
|
||||||
|
player_updated = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (is_key_down(:KEY_DOWN)) {
|
||||||
|
me.pos.z = me.pos.z + 0.2;
|
||||||
|
player_updated = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (is_key_down(:KEY_UP)) {
|
||||||
|
me.pos.z = me.pos.z - 0.2;
|
||||||
|
player_updated = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
sync_camera(camera, me);
|
||||||
|
|
||||||
|
if (player_updated) {
|
||||||
|
players = move(me);
|
||||||
|
} else {
|
||||||
|
players = ping(me);
|
||||||
|
}
|
||||||
|
|
||||||
|
begin_drawing();
|
||||||
|
clear_background(:RAYWHITE);
|
||||||
|
|
||||||
|
begin_mode_3d(camera);
|
||||||
|
|
||||||
|
(* Draw floor *)
|
||||||
|
draw_grid(30, 1.0);
|
||||||
|
|
||||||
|
draw_cube(me.pos, 0.5, 0.5, 0.5, me.apperance);
|
||||||
|
|
||||||
|
for (player in players) {
|
||||||
|
draw_cube(player.pos, 0.5, 0.5, 0.5, player.apperance);
|
||||||
|
}
|
||||||
|
|
||||||
|
end_mode_3d();
|
||||||
|
|
||||||
|
end_drawing();
|
||||||
|
}
|
||||||
|
|
||||||
|
logout(me);
|
||||||
|
close_window(); (*Close window and OpenGL context *)
|
||||||
|
}
|
Loading…
Reference in New Issue