accidentally flipped v2 and v3, fixed
This commit is contained in:
parent
9c1d79812d
commit
acedcb1e23
|
@ -170,18 +170,12 @@ The following is a list of global operators and their effect:
|
||||||
- logical and
|
- logical and
|
||||||
- `or`
|
- `or`
|
||||||
- logical or
|
- logical or
|
||||||
- `nor`
|
|
||||||
- logical nor
|
|
||||||
- `nand`
|
|
||||||
- logical nand
|
|
||||||
- `xor`
|
- `xor`
|
||||||
- logical xor
|
- logical xor
|
||||||
- `band`
|
- `band`
|
||||||
- bitwise and
|
- bitwise and
|
||||||
- `bor`
|
- `bor`
|
||||||
- bitwise or
|
- bitwise or
|
||||||
- `bnor`
|
|
||||||
- bitwise nor
|
|
||||||
- `bxor`
|
- `bxor`
|
||||||
- bitwise xor
|
- bitwise xor
|
||||||
- `srl`
|
- `srl`
|
||||||
|
|
|
@ -1,47 +1,48 @@
|
||||||
fn build(ProjectConfig c) {
|
fn :build (ProjectConfig) {
|
||||||
|
set c to pop;
|
||||||
|
|
||||||
c.name("MMO Project");
|
c.name("MMO Project");
|
||||||
c.mode("dev");
|
|
||||||
|
|
||||||
c.client([
|
c.client([
|
||||||
LanguageSettings(
|
LanguageSettings {
|
||||||
"c", ! lang
|
"c", /* lang */
|
||||||
"src/client.ztl", ! file
|
"src/client.ztl", /* file */
|
||||||
"client/", ! out path
|
"client/", /* out path */
|
||||||
[ ! ffi settings
|
[ /* ffi */
|
||||||
FFISetting {
|
FFISetting {
|
||||||
"raylib", ! libary name
|
"raylib",
|
||||||
"$RAYLIB_PATH/libraylib.a", ! path
|
"$RAYLIB_PATH/libraylib.a",
|
||||||
"./", ! local path
|
"./",
|
||||||
"make build", ! build command
|
"make build",
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
)
|
}
|
||||||
]);
|
])
|
||||||
|
|
||||||
c.server([
|
c.server([
|
||||||
LanguageSettings(
|
LanguageSettings {
|
||||||
"javascript",
|
"javascript",
|
||||||
"src/server.ztl",
|
"src/server.ztl",
|
||||||
"server/"
|
"server/"
|
||||||
)
|
}
|
||||||
]);
|
]);
|
||||||
|
|
||||||
c.common([
|
c.common([
|
||||||
LanguageSettings(
|
LanguageSettings {
|
||||||
"c",
|
"c",
|
||||||
"src/common.ztl",
|
"src/common.ztl",
|
||||||
"client/"
|
"client/"
|
||||||
},
|
},
|
||||||
LanguageSettings(
|
LanguageSettings {
|
||||||
"javascript",
|
"javascript",
|
||||||
"src/common.ztl",
|
"src/common.ztl",
|
||||||
"server/"
|
"server/"
|
||||||
),
|
},
|
||||||
LanguageSettings(
|
LanguageSettings {
|
||||||
"sqlite",
|
"sqlite",
|
||||||
"src/common.ztl",
|
"src/common.ztl",
|
||||||
"db/"
|
"db/"
|
||||||
)
|
}
|
||||||
]);
|
]);
|
||||||
|
|
||||||
c.build();
|
c.build();
|
||||||
|
|
|
@ -1,93 +1,94 @@
|
||||||
use "common.ztl";
|
use "common.ztl"
|
||||||
use "raylib" as rl;
|
|
||||||
|
|
||||||
fn main (i32 argc, str[] argv) i32 {
|
fn :login (9p :s Player :p str :password) Player[] {
|
||||||
set screen_width to 800 as i32;
|
s.auth(p.username, password);
|
||||||
set screen_height to 450 as i32;
|
return s.read("players");
|
||||||
|
}
|
||||||
|
|
||||||
set username to argv[0];
|
|
||||||
set password to argv[1];
|
|
||||||
|
|
||||||
set server to 9p("localhost:25565");
|
fn :main (i32 :argc str[] :argv) i32 {
|
||||||
|
set :screen_width to i32 800;
|
||||||
|
set :screen_height to i32 450;
|
||||||
|
|
||||||
set me to Player(
|
set :username to argv[0];
|
||||||
server,
|
set :password to argv[1];
|
||||||
username,
|
|
||||||
Vec(0.0 1.0 2.0),
|
set :me to Player
|
||||||
|
username
|
||||||
|
0.0 1.0 2.0
|
||||||
purple
|
purple
|
||||||
);
|
;
|
||||||
|
|
||||||
set players to me.login(password);
|
set :players to Player[] login(password);
|
||||||
|
|
||||||
set camera to rl.Camera3D(
|
set :camera to Camera3D
|
||||||
Vec(0.0, 1.0, 0.0),
|
0.0 1.0 0.0
|
||||||
45.0,
|
45.0
|
||||||
CAMERA_PERSPECTIVE,
|
:CAMERA_PERSPECTIVE
|
||||||
Vec(me.pos.x + 10.0,
|
add me.pos.x 10.0
|
||||||
me.pos.y + 10.0,
|
add me.pos.y 10.0
|
||||||
me.pos.z),
|
me.pos.z
|
||||||
me.pos
|
me.pos
|
||||||
);
|
;
|
||||||
|
|
||||||
rl.init_window("zwl client : raylib", screen_width, screen_height);
|
init_window( "zwl client : raylib" screen_width screen_height);
|
||||||
rl.set_target_fps(60);
|
set_target_fps( 60);
|
||||||
|
|
||||||
!!
|
/* Main game loop */
|
||||||
Main game loop
|
while ( not window_should_close ) {
|
||||||
!!
|
|
||||||
while ( not rl.window_should_close() ) { ! Detect window close button or ESC key
|
|
||||||
|
|
||||||
set player_updated to false;
|
set :player_updated to false;
|
||||||
|
|
||||||
if (rl.is_key_down(KEY_RIGHT)) {
|
if (is_key_down(:KEY_RIGHT)) {
|
||||||
set me.pos.x to (me.pos.x + 0.2);
|
set me.pos.x to {add me.pos.x 0.2};
|
||||||
set player_updated to true;
|
set :player_updated true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rl.is_key_down(KEY_LEFT)) {
|
if (is_key_down(:KEY_LEFT)) {
|
||||||
set me.pos.x to (me.pos.x + 0.2);
|
set me.pos.x to {sub me.pos.x 0.2};
|
||||||
set player_updated to true;
|
set :player_updated true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rl.is_key_down(KEY_DOWN)) {
|
if (is_key_down(:KEY_DOWN)) {
|
||||||
set me.pos.z to (me.pos.z + 0.2);
|
set me.pos.z to {add me.pos.z 0.2};
|
||||||
set player_updated to true;
|
set :player_updated true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rl.is_key_down(KEY_UP)) {
|
if (is_key_down(:KEY_UP)) {
|
||||||
set me.pos.z to (me.pos.z - 0.2);
|
set me.pos.z to {sub me.pos.z 0.2};
|
||||||
set player_updated to true;
|
set :player_updated true;
|
||||||
}
|
}
|
||||||
|
|
||||||
me.sync_camera(camera);
|
me.sync_camera(camera);
|
||||||
|
|
||||||
if (player_updated) {
|
if (player_updated) {
|
||||||
set players to me.move();
|
set :players me.move();
|
||||||
} else {
|
} else {
|
||||||
set players to me.ping();
|
set :players me.ping();
|
||||||
}
|
}
|
||||||
|
|
||||||
rl.begin_drawing();
|
begin_drawing();
|
||||||
rl.clear_background(RAYWHITE);
|
clear_background(RAYWHITE);
|
||||||
|
|
||||||
rl.begin_mode_3d(camera);
|
begin_mode_3d(camera);
|
||||||
|
|
||||||
! Draw floor
|
/* Draw floor */
|
||||||
rl.draw_grid(30, 1.0);
|
draw_grid(30 1.0);
|
||||||
|
|
||||||
rl.draw_cube(me.pos, 0.5, 0.5, 0.5, me.apperance);
|
draw_cube(me.pos 0.5 0.5 0.5 me.apperance);
|
||||||
|
|
||||||
for (player in players) {
|
for :player in players {
|
||||||
rl.draw_cube(player.pos, 0.5, 0.5, 0.5, player.apperance);
|
draw_cube(player.pos 0.5 0.5 0.5 player.apperance);
|
||||||
}
|
}
|
||||||
|
|
||||||
rl.end_mode_3d();
|
end_mode_3d();
|
||||||
|
|
||||||
rl.end_drawing();
|
end_drawing();
|
||||||
}
|
}
|
||||||
|
/* Detect window close button or ESC key */
|
||||||
|
|
||||||
me.logout();
|
me.logout();
|
||||||
close_window(); ! Close window and OpenGL context
|
close_window(); /*Close window and OpenGL context */
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,37 +1,19 @@
|
||||||
type Vec {
|
set :Vec to type {
|
||||||
init(f32 x, f32 y, f32 z) {
|
f32 :x,
|
||||||
set this.x to x;
|
f32 :y,
|
||||||
set this.y to y;
|
f32 :z,
|
||||||
set this.z to z;
|
};
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
type Color {
|
set :Color to type {
|
||||||
init(i8 r, i8 g, i8 b) {
|
i8 :r,
|
||||||
set this.r to r;
|
i8 :g,
|
||||||
set this.g to g;
|
i8 :b,
|
||||||
set this.b to b;
|
};
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
type Player {
|
set :Player to type {
|
||||||
init (9p server, str username, Vec pos, Color color) {
|
str :username,
|
||||||
set this.server to server;
|
Vec :pos,
|
||||||
set this.username to username;
|
Color :color,
|
||||||
set this.pos to pos;
|
};
|
||||||
set this.color to color;
|
|
||||||
}
|
|
||||||
|
|
||||||
login (str password) Player[] {
|
set immutable :purple to Color {255 255 0};
|
||||||
this.server.auth(this.username, password);
|
|
||||||
set this.players to server.open("players");
|
|
||||||
return players.read();
|
|
||||||
}
|
|
||||||
|
|
||||||
logout() {
|
|
||||||
this.players.flush();
|
|
||||||
this.server.clunk();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const purple is Color(255, 255, 0);
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use "common.ztl";
|
use "common.ztl"
|
||||||
|
|
||||||
fn main (i32 argc, str[] argv) i32 {
|
fn :main (i32 :argc []str :argv) i32 {
|
||||||
set s to 9p (
|
set s to 9p {
|
||||||
version,
|
version,
|
||||||
auth,
|
auth,
|
||||||
error,
|
error,
|
||||||
|
@ -15,61 +15,59 @@ fn main (i32 argc, str[] argv) i32 {
|
||||||
clunk,
|
clunk,
|
||||||
remove,
|
remove,
|
||||||
stat,
|
stat,
|
||||||
);
|
};
|
||||||
|
|
||||||
s.host("0.0.0.0:25565");
|
s.host("0.0.0.0:25565")
|
||||||
|
};
|
||||||
|
|
||||||
return 0;
|
fn :version(9pmsg :m) {
|
||||||
}
|
|
||||||
|
|
||||||
fn version(9pmsg m) {
|
};
|
||||||
|
|
||||||
}
|
fn :auth(9pmsg :m) {
|
||||||
|
|
||||||
fn auth(9pmsg m) {
|
};
|
||||||
|
|
||||||
}
|
fn :error(9pmsg :m) {
|
||||||
|
|
||||||
fn error(9pmsg m) {
|
};
|
||||||
|
|
||||||
}
|
fn :flush(9pmsg :m) {
|
||||||
|
|
||||||
fn flush(9pmsg m) {
|
};
|
||||||
|
|
||||||
}
|
fn :attach(9pmsg :m) {
|
||||||
|
|
||||||
fn attach(9pmsg m) {
|
};
|
||||||
|
|
||||||
}
|
fn :walk(9pmsg :m) {
|
||||||
|
|
||||||
fn walk(9pmsg m) {
|
};
|
||||||
|
|
||||||
}
|
fn :open(9pmsg :m) {
|
||||||
|
|
||||||
fn open(9pmsg m) {
|
};
|
||||||
|
|
||||||
}
|
fn :create(9pmsg :m) {
|
||||||
|
|
||||||
fn create(9pmsg m) {
|
};
|
||||||
|
|
||||||
}
|
fn :read(9pmsg :m) {
|
||||||
|
|
||||||
fn read(9pmsg m) {
|
};
|
||||||
|
|
||||||
}
|
fn :write(9pmsg :m) {
|
||||||
|
|
||||||
fn write(9pmsg m) {
|
};
|
||||||
|
|
||||||
}
|
fn :clunk(9pmsg :m) {
|
||||||
|
|
||||||
fn clunk(9pmsg m) {
|
};
|
||||||
|
|
||||||
}
|
fn :remove(9pmsg :m) {
|
||||||
|
|
||||||
fn remove(9pmsg m) {
|
};
|
||||||
|
|
||||||
}
|
fn :stat(9pmsg :m) {
|
||||||
|
|
||||||
fn stat(9pmsg m) {
|
};
|
||||||
|
|
||||||
}
|
|
||||||
|
|
|
@ -4,9 +4,11 @@ local syntax = require 'core.syntax'
|
||||||
syntax.add {
|
syntax.add {
|
||||||
name = "Zongor's Transpiler Language",
|
name = "Zongor's Transpiler Language",
|
||||||
files = { "%.ztl$" },
|
files = { "%.ztl$" },
|
||||||
block_comment = { '/*', '*/' },
|
comment = "!",
|
||||||
|
block_comment = { '!!', '!!' },
|
||||||
patterns = {
|
patterns = {
|
||||||
{ pattern = { "/%*", "%*/" }, type = "comment" },
|
{ pattern = { "!!", "!!" }, type = "comment" }, -- tested ok
|
||||||
|
{ pattern = "!.*", type = "comment" },
|
||||||
{ pattern = { '"', '"', '\\' }, type = "string" },
|
{ pattern = { '"', '"', '\\' }, type = "string" },
|
||||||
{ pattern = { "'", "'", '\\' }, type = "string" },
|
{ pattern = { "'", "'", '\\' }, type = "string" },
|
||||||
{ pattern = ";", type = "operator" },
|
{ pattern = ";", type = "operator" },
|
||||||
|
@ -14,24 +16,40 @@ syntax.add {
|
||||||
{ pattern = "[viu][%d_]+", type = "keyword2" },
|
{ pattern = "[viu][%d_]+", type = "keyword2" },
|
||||||
{ pattern = "[A-Z][%w_]*", type = "keyword2" },
|
{ pattern = "[A-Z][%w_]*", type = "keyword2" },
|
||||||
{ pattern = "[9][%w_]*", type = "keyword2" },
|
{ pattern = "[9][%w_]*", type = "keyword2" },
|
||||||
{ pattern = ":[%w_]*", type = "literal" },
|
|
||||||
{ pattern = "-?%.?%d+f?", type = "number" },
|
{ pattern = "-?%.?%d+f?", type = "number" },
|
||||||
},
|
},
|
||||||
symbols = {
|
symbols = {
|
||||||
["fn"] = "keyword",
|
["fn"] = "keyword",
|
||||||
["to"] = "keyword",
|
["to"] = "keyword",
|
||||||
["in"] = "keyword",
|
["in"] = "keyword",
|
||||||
|
["is"] = "keyword",
|
||||||
|
["as"] = "keyword",
|
||||||
["use"] = "keyword",
|
["use"] = "keyword",
|
||||||
["set"] = "keyword",
|
["set"] = "keyword",
|
||||||
["if"] = "keyword",
|
["if"] = "keyword",
|
||||||
["else"] = "keyword",
|
["else"] = "keyword",
|
||||||
["for"] = "keyword",
|
["for"] = "keyword",
|
||||||
|
["loop"] = "keyword",
|
||||||
["while"] = "keyword",
|
["while"] = "keyword",
|
||||||
["push"] = "keyword",
|
["push"] = "keyword",
|
||||||
["pop"] = "keyword",
|
["pop"] = "keyword",
|
||||||
["return"] = "keyword",
|
["return"] = "keyword",
|
||||||
["immutable"] = "keyword",
|
["const"] = "keyword",
|
||||||
["type"] = "keyword",
|
["type"] = "keyword",
|
||||||
|
["this"] = "keyword",
|
||||||
|
|
||||||
|
["eq"] = "keyword",
|
||||||
|
["ne"] = "keyword",
|
||||||
|
["mod"] = "keyword",
|
||||||
|
["not"] = "keyword",
|
||||||
|
["and"] = "keyword",
|
||||||
|
["or"] = "keyword",
|
||||||
|
["xor"] = "keyword",
|
||||||
|
["band"] = "keyword",
|
||||||
|
["bor"] = "keyword",
|
||||||
|
["bxor"] = "keyword",
|
||||||
|
["srl"] = "keyword",
|
||||||
|
["sll"] = "keyword",
|
||||||
|
|
||||||
["char"] = "keyword2",
|
["char"] = "keyword2",
|
||||||
["str"] = "keyword2",
|
["str"] = "keyword2",
|
||||||
|
@ -42,4 +60,5 @@ syntax.add {
|
||||||
|
|
||||||
["true"] = "literal",
|
["true"] = "literal",
|
||||||
["false"] = "literal",
|
["false"] = "literal",
|
||||||
}}
|
},
|
||||||
|
}
|
||||||
|
|
|
@ -1,48 +1,47 @@
|
||||||
fn :build (ProjectConfig) {
|
fn build(ProjectConfig c) {
|
||||||
set c to pop;
|
|
||||||
|
|
||||||
c.name("MMO Project");
|
c.name("MMO Project");
|
||||||
|
c.mode("dev");
|
||||||
|
|
||||||
c.client([
|
c.client([
|
||||||
LanguageSettings {
|
LanguageSettings(
|
||||||
"c", /* lang */
|
"c", ! lang
|
||||||
"src/client.ztl", /* file */
|
"src/client.ztl", ! file
|
||||||
"client/", /* out path */
|
"client/", ! out path
|
||||||
[ /* ffi */
|
[ ! ffi settings
|
||||||
FFISetting {
|
FFISetting {
|
||||||
"raylib",
|
"raylib", ! libary name
|
||||||
"$RAYLIB_PATH/libraylib.a",
|
"$RAYLIB_PATH/libraylib.a", ! path
|
||||||
"./",
|
"./", ! local path
|
||||||
"make build",
|
"make build", ! build command
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
)
|
||||||
])
|
]);
|
||||||
|
|
||||||
c.server([
|
c.server([
|
||||||
LanguageSettings {
|
LanguageSettings(
|
||||||
"javascript",
|
"javascript",
|
||||||
"src/server.ztl",
|
"src/server.ztl",
|
||||||
"server/"
|
"server/"
|
||||||
}
|
)
|
||||||
]);
|
]);
|
||||||
|
|
||||||
c.common([
|
c.common([
|
||||||
LanguageSettings {
|
LanguageSettings(
|
||||||
"c",
|
"c",
|
||||||
"src/common.ztl",
|
"src/common.ztl",
|
||||||
"client/"
|
"client/"
|
||||||
},
|
},
|
||||||
LanguageSettings {
|
LanguageSettings(
|
||||||
"javascript",
|
"javascript",
|
||||||
"src/common.ztl",
|
"src/common.ztl",
|
||||||
"server/"
|
"server/"
|
||||||
},
|
),
|
||||||
LanguageSettings {
|
LanguageSettings(
|
||||||
"sqlite",
|
"sqlite",
|
||||||
"src/common.ztl",
|
"src/common.ztl",
|
||||||
"db/"
|
"db/"
|
||||||
}
|
)
|
||||||
]);
|
]);
|
||||||
|
|
||||||
c.build();
|
c.build();
|
||||||
|
|
|
@ -1,94 +1,93 @@
|
||||||
use "common.ztl"
|
use "common.ztl";
|
||||||
|
use "raylib" as rl;
|
||||||
|
|
||||||
fn :login (9p :s Player :p str :password) Player[] {
|
fn main (i32 argc, str[] argv) i32 {
|
||||||
s.auth(p.username, password);
|
set screen_width to 800 as i32;
|
||||||
return s.read("players");
|
set screen_height to 450 as i32;
|
||||||
}
|
|
||||||
|
|
||||||
|
set username to argv[0];
|
||||||
|
set password to argv[1];
|
||||||
|
|
||||||
fn :main (i32 :argc str[] :argv) i32 {
|
set server to 9p("localhost:25565");
|
||||||
set :screen_width to i32 800;
|
|
||||||
set :screen_height to i32 450;
|
|
||||||
|
|
||||||
set :username to argv[0];
|
set me to Player(
|
||||||
set :password to argv[1];
|
server,
|
||||||
|
username,
|
||||||
set :me to Player
|
Vec(0.0, 1.0, 2.0),
|
||||||
username
|
|
||||||
0.0 1.0 2.0
|
|
||||||
purple
|
purple
|
||||||
;
|
);
|
||||||
|
|
||||||
set :players to Player[] login(password);
|
set players to me.login(password);
|
||||||
|
|
||||||
set :camera to Camera3D
|
set camera to rl.Camera3D(
|
||||||
0.0 1.0 0.0
|
Vec(0.0, 1.0, 0.0),
|
||||||
45.0
|
45.0,
|
||||||
:CAMERA_PERSPECTIVE
|
CAMERA_PERSPECTIVE,
|
||||||
add me.pos.x 10.0
|
Vec(me.pos.x + 10.0,
|
||||||
add me.pos.y 10.0
|
me.pos.y + 10.0,
|
||||||
me.pos.z
|
me.pos.z),
|
||||||
me.pos
|
me.pos
|
||||||
;
|
);
|
||||||
|
|
||||||
init_window( "zwl client : raylib" screen_width screen_height);
|
rl.init_window("zwl client : raylib", screen_width, screen_height);
|
||||||
set_target_fps( 60);
|
rl.set_target_fps(60);
|
||||||
|
|
||||||
/* Main game loop */
|
!!
|
||||||
while ( not window_should_close ) {
|
Main game loop
|
||||||
|
!!
|
||||||
|
while ( not rl.window_should_close() ) { ! Detect window close button or ESC key
|
||||||
|
|
||||||
set :player_updated to false;
|
set player_updated to false;
|
||||||
|
|
||||||
if (is_key_down(:KEY_RIGHT)) {
|
if (rl.is_key_down(KEY_RIGHT)) {
|
||||||
set me.pos.x to {add me.pos.x 0.2};
|
set me.pos.x to (me.pos.x + 0.2);
|
||||||
set :player_updated true;
|
set player_updated to true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_key_down(:KEY_LEFT)) {
|
if (rl.is_key_down(KEY_LEFT)) {
|
||||||
set me.pos.x to {sub me.pos.x 0.2};
|
set me.pos.x to (me.pos.x + 0.2);
|
||||||
set :player_updated true;
|
set player_updated to true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_key_down(:KEY_DOWN)) {
|
if (rl.is_key_down(KEY_DOWN)) {
|
||||||
set me.pos.z to {add me.pos.z 0.2};
|
set me.pos.z to (me.pos.z + 0.2);
|
||||||
set :player_updated true;
|
set player_updated to true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_key_down(:KEY_UP)) {
|
if (rl.is_key_down(KEY_UP)) {
|
||||||
set me.pos.z to {sub me.pos.z 0.2};
|
set me.pos.z to (me.pos.z - 0.2);
|
||||||
set :player_updated true;
|
set player_updated to true;
|
||||||
}
|
}
|
||||||
|
|
||||||
me.sync_camera(camera);
|
me.sync_camera(camera);
|
||||||
|
|
||||||
if (player_updated) {
|
if (player_updated) {
|
||||||
set :players me.move();
|
set players to me.move();
|
||||||
} else {
|
} else {
|
||||||
set :players me.ping();
|
set players to me.ping();
|
||||||
}
|
}
|
||||||
|
|
||||||
begin_drawing();
|
rl.begin_drawing();
|
||||||
clear_background(RAYWHITE);
|
rl.clear_background(RAYWHITE);
|
||||||
|
|
||||||
begin_mode_3d(camera);
|
rl.begin_mode_3d(camera);
|
||||||
|
|
||||||
/* Draw floor */
|
! Draw floor
|
||||||
draw_grid(30 1.0);
|
rl.draw_grid(30, 1.0);
|
||||||
|
|
||||||
draw_cube(me.pos 0.5 0.5 0.5 me.apperance);
|
rl.draw_cube(me.pos, 0.5, 0.5, 0.5, me.apperance);
|
||||||
|
|
||||||
for :player in players {
|
for (player in players) {
|
||||||
draw_cube(player.pos 0.5 0.5 0.5 player.apperance);
|
rl.draw_cube(player.pos, 0.5, 0.5, 0.5, player.apperance);
|
||||||
}
|
}
|
||||||
|
|
||||||
end_mode_3d();
|
rl.end_mode_3d();
|
||||||
|
|
||||||
end_drawing();
|
rl.end_drawing();
|
||||||
}
|
}
|
||||||
/* Detect window close button or ESC key */
|
|
||||||
|
|
||||||
me.logout();
|
me.logout();
|
||||||
close_window(); /*Close window and OpenGL context */
|
close_window(); ! Close window and OpenGL context
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,19 +1,37 @@
|
||||||
set :Vec to type {
|
type Vec {
|
||||||
f32 :x,
|
init(f32 x, f32 y, f32 z) {
|
||||||
f32 :y,
|
set this.x to x;
|
||||||
f32 :z,
|
set this.y to y;
|
||||||
};
|
set this.z to z;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
set :Color to type {
|
type Color {
|
||||||
i8 :r,
|
init(i8 r, i8 g, i8 b) {
|
||||||
i8 :g,
|
set this.r to r;
|
||||||
i8 :b,
|
set this.g to g;
|
||||||
};
|
set this.b to b;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
set :Player to type {
|
type Player {
|
||||||
str :username,
|
init (9p server, str username, Vec pos, Color color) {
|
||||||
Vec :pos,
|
set this.server to server;
|
||||||
Color :color,
|
set this.username to username;
|
||||||
};
|
set this.pos to pos;
|
||||||
|
set this.color to color;
|
||||||
|
}
|
||||||
|
|
||||||
set immutable :purple to Color {255 255 0};
|
login (str password) Player[] {
|
||||||
|
this.server.auth(this.username, password);
|
||||||
|
set this.players to server.open("players");
|
||||||
|
return players.read();
|
||||||
|
}
|
||||||
|
|
||||||
|
logout() {
|
||||||
|
this.players.flush();
|
||||||
|
this.server.clunk();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const purple is Color(255, 255, 0);
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use "common.ztl"
|
use "common.ztl";
|
||||||
|
|
||||||
fn :main (i32 :argc []str :argv) i32 {
|
fn main (i32 argc, str[] argv) i32 {
|
||||||
set s to 9p {
|
set s to 9p (
|
||||||
version,
|
version,
|
||||||
auth,
|
auth,
|
||||||
error,
|
error,
|
||||||
|
@ -15,59 +15,61 @@ fn :main (i32 :argc []str :argv) i32 {
|
||||||
clunk,
|
clunk,
|
||||||
remove,
|
remove,
|
||||||
stat,
|
stat,
|
||||||
};
|
);
|
||||||
|
|
||||||
s.host("0.0.0.0:25565")
|
s.host("0.0.0.0:25565");
|
||||||
};
|
|
||||||
|
|
||||||
fn :version(9pmsg :m) {
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
};
|
fn version(9pmsg m) {
|
||||||
|
|
||||||
fn :auth(9pmsg :m) {
|
}
|
||||||
|
|
||||||
};
|
fn auth(9pmsg m) {
|
||||||
|
|
||||||
fn :error(9pmsg :m) {
|
}
|
||||||
|
|
||||||
};
|
fn error(9pmsg m) {
|
||||||
|
|
||||||
fn :flush(9pmsg :m) {
|
}
|
||||||
|
|
||||||
};
|
fn flush(9pmsg m) {
|
||||||
|
|
||||||
fn :attach(9pmsg :m) {
|
}
|
||||||
|
|
||||||
};
|
fn attach(9pmsg m) {
|
||||||
|
|
||||||
fn :walk(9pmsg :m) {
|
}
|
||||||
|
|
||||||
};
|
fn walk(9pmsg m) {
|
||||||
|
|
||||||
fn :open(9pmsg :m) {
|
}
|
||||||
|
|
||||||
};
|
fn open(9pmsg m) {
|
||||||
|
|
||||||
fn :create(9pmsg :m) {
|
}
|
||||||
|
|
||||||
};
|
fn create(9pmsg m) {
|
||||||
|
|
||||||
fn :read(9pmsg :m) {
|
}
|
||||||
|
|
||||||
};
|
fn read(9pmsg m) {
|
||||||
|
|
||||||
fn :write(9pmsg :m) {
|
}
|
||||||
|
|
||||||
};
|
fn write(9pmsg m) {
|
||||||
|
|
||||||
fn :clunk(9pmsg :m) {
|
}
|
||||||
|
|
||||||
};
|
fn clunk(9pmsg m) {
|
||||||
|
|
||||||
fn :remove(9pmsg :m) {
|
}
|
||||||
|
|
||||||
};
|
fn remove(9pmsg m) {
|
||||||
|
|
||||||
fn :stat(9pmsg :m) {
|
}
|
||||||
|
|
||||||
};
|
fn stat(9pmsg m) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue