undar-lang/docs/project-syntax-example/client.ul

45 lines
1.0 KiB
Fortran

use <str.ul>; // from stdlib
use "common.ul"; // from local
function main(int argc, str[] argv) {
nat screen_width = 800;
nat screen_height = 450;
if (argv < 2) {
pln("usage: undar client.ul <username> <password>");
exit(-1);
}
str username = argv[1];
str password = argv[2];
Player me(username, [0.0, 1.0, 2.0], PURPLE);
bool running = true;
while (running) {
window("zwl client", screen_width, screen_height) {
splitbox(parent.size 0.25) {
canvas() {
if (button("logout")) {
me.logout();
running = false;
}
}
}
splitbox(parent.size 0.75) {
canvas() {
model(Floor([0, 0, 0], 30));
me.update();
model(Cube(me.pos, [0.5, 0.5, 0.5], me.appearance));
if (Player[] players = me.server.read("players")) {
for (p in players) {
model(Cube(p.pos, [0.5, 0.5, 0.5], p.apperance));
}
}
}
}
}
}
exits("Client Closed Successfully");
}