diff --git a/idea.vq b/old/idea.vq similarity index 100% rename from idea.vq rename to old/idea.vq diff --git a/idea.zl0 b/old/idea.zl0 similarity index 100% rename from idea.zl0 rename to old/idea.zl0 diff --git a/idea.zl0b b/old/idea.zl0b similarity index 100% rename from idea.zl0b rename to old/idea.zl0b diff --git a/idea.zl1 b/old/idea.zl1 similarity index 100% rename from idea.zl1 rename to old/idea.zl1 diff --git a/idea.zl2 b/old/idea.zl2 similarity index 100% rename from idea.zl2 rename to old/idea.zl2 diff --git a/idea.zl2b b/old/idea.zl2b similarity index 100% rename from idea.zl2b rename to old/idea.zl2b diff --git a/idea.zl3 b/old/idea.zl3 similarity index 100% rename from idea.zl3 rename to old/idea.zl3 diff --git a/old/idea.zl3b b/old/idea.zl3b new file mode 100644 index 0000000..20c6370 --- /dev/null +++ b/old/idea.zl3b @@ -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 +} diff --git a/idea.zl4 b/old/idea.zl4 similarity index 100% rename from idea.zl4 rename to old/idea.zl4 diff --git a/project-example/build.ztl b/project-example/build.ztl new file mode 100644 index 0000000..9a49883 --- /dev/null +++ b/project-example/build.ztl @@ -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(); +} diff --git a/project-example/client.ztl b/project-example/client.ztl new file mode 100644 index 0000000..9e5bde4 --- /dev/null +++ b/project-example/client.ztl @@ -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 *) +} diff --git a/project-example/common.ztl b/project-example/common.ztl new file mode 100644 index 0000000..642bfb7 --- /dev/null +++ b/project-example/common.ztl @@ -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); diff --git a/project-example/server.ztl b/project-example/server.ztl new file mode 100644 index 0000000..74e23a0 --- /dev/null +++ b/project-example/server.ztl @@ -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) { + +} \ No newline at end of file