move stuff, add client experiment
This commit is contained in:
parent
be7a3e731b
commit
7ae64fb165
|
@ -0,0 +1,108 @@
|
||||||
|
use "raylib.zwl"
|
||||||
|
|
||||||
|
type Vec {
|
||||||
|
f32 x;
|
||||||
|
f32 y;
|
||||||
|
f32 z;
|
||||||
|
}
|
||||||
|
|
||||||
|
type Color {
|
||||||
|
i8 r;
|
||||||
|
i8 g;
|
||||||
|
i8 b;
|
||||||
|
}
|
||||||
|
|
||||||
|
type Player {
|
||||||
|
str username;
|
||||||
|
Vec 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,
|
||||||
|
Vec(0.0, 1.0, 2.0),
|
||||||
|
purple
|
||||||
|
);
|
||||||
|
Player[] players = login(me, password);
|
||||||
|
|
||||||
|
Camera3D camera(
|
||||||
|
Vec(0.0, 1.0, 0.0),
|
||||||
|
45.0,
|
||||||
|
:CAMERA_PERSPECTIVE,
|
||||||
|
Vec(
|
||||||
|
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
|
||||||
|
}
|
|
@ -0,0 +1,35 @@
|
||||||
|
void build(ProjectConfig c) {
|
||||||
|
c.name("MMO Project");
|
||||||
|
|
||||||
|
c.client({
|
||||||
|
"javascript":{
|
||||||
|
"out": "client/"
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
c.server({
|
||||||
|
"c":{
|
||||||
|
"out":"server/"
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
c.database({
|
||||||
|
"sqlite":{
|
||||||
|
"out":"db/"
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
c.common({
|
||||||
|
"c":{
|
||||||
|
"out":"server/"
|
||||||
|
},
|
||||||
|
"javascript":{
|
||||||
|
"out":"client/"
|
||||||
|
},
|
||||||
|
"sqlite":{
|
||||||
|
"out":"db/"
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
c.build();
|
||||||
|
}
|
|
@ -0,0 +1,91 @@
|
||||||
|
use "common.zl"
|
||||||
|
|
||||||
|
Player[] login(Server s, Player p, str password) {
|
||||||
|
/* do the login here */
|
||||||
|
}
|
||||||
|
|
||||||
|
void main(int argc, str[] argv) {
|
||||||
|
i32 screen_width = 800;
|
||||||
|
i32 screen_height = 450;
|
||||||
|
|
||||||
|
str username = argv[0];
|
||||||
|
str password = argv[1];
|
||||||
|
|
||||||
|
tunnel s();
|
||||||
|
s.attach("localhost:25565");
|
||||||
|
|
||||||
|
Player me(
|
||||||
|
username,
|
||||||
|
Vec(0.0, 1.0, 2.0),
|
||||||
|
purple
|
||||||
|
);
|
||||||
|
Player[] players = login(s, me, password);
|
||||||
|
|
||||||
|
Camera3D camera(
|
||||||
|
Vec(0.0, 1.0, 0.0),
|
||||||
|
45.0,
|
||||||
|
:CAMERA_PERSPECTIVE,
|
||||||
|
Vec(
|
||||||
|
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(s, me, camera);
|
||||||
|
|
||||||
|
if (player_updated) {
|
||||||
|
players = move(s, me);
|
||||||
|
} else {
|
||||||
|
players = ping(s, 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 *)
|
||||||
|
}
|
|
@ -0,0 +1,19 @@
|
||||||
|
type Vec {
|
||||||
|
f32 x;
|
||||||
|
f32 y;
|
||||||
|
f32 z;
|
||||||
|
}
|
||||||
|
|
||||||
|
type Color {
|
||||||
|
i8 r;
|
||||||
|
i8 g;
|
||||||
|
i8 b;
|
||||||
|
}
|
||||||
|
|
||||||
|
type Player {
|
||||||
|
str username;
|
||||||
|
Vec pos;
|
||||||
|
Color color;
|
||||||
|
}
|
||||||
|
|
||||||
|
Color purple(255, 255, 0);
|
|
@ -0,0 +1,57 @@
|
||||||
|
void main(int argc, str[] argv) {
|
||||||
|
tunnel s();
|
||||||
|
s.host("localhost:25565",
|
||||||
|
version,
|
||||||
|
auth,
|
||||||
|
error,
|
||||||
|
flush,
|
||||||
|
attach,
|
||||||
|
walk,
|
||||||
|
open,
|
||||||
|
create,
|
||||||
|
read,
|
||||||
|
write,
|
||||||
|
clunk,
|
||||||
|
remove,
|
||||||
|
stat);
|
||||||
|
}
|
||||||
|
|
||||||
|
msg version(msg m) {
|
||||||
|
|
||||||
|
}
|
||||||
|
msg auth(msg m) {
|
||||||
|
|
||||||
|
}
|
||||||
|
msg error(msg m) {
|
||||||
|
|
||||||
|
}
|
||||||
|
msg flush(msg m) {
|
||||||
|
|
||||||
|
}
|
||||||
|
msg attach(msg m) {
|
||||||
|
|
||||||
|
}
|
||||||
|
msg walk(msg m) {
|
||||||
|
|
||||||
|
}
|
||||||
|
msg open(msg m) {
|
||||||
|
|
||||||
|
}
|
||||||
|
msg create(msg m) {
|
||||||
|
|
||||||
|
}
|
||||||
|
msg read(msg m) {
|
||||||
|
|
||||||
|
}
|
||||||
|
msg write(msg m) {
|
||||||
|
|
||||||
|
}
|
||||||
|
msg clunk(msg m) {
|
||||||
|
|
||||||
|
}
|
||||||
|
msg remove(msg m) {
|
||||||
|
|
||||||
|
}
|
||||||
|
msg stat(msg m) {
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue