formatting

This commit is contained in:
zongor 2025-06-01 00:01:27 -04:00
parent a6e254a100
commit f1f84e0fe5
3 changed files with 97 additions and 105 deletions

View File

@ -1,22 +1,18 @@
use "common.ztl"; use "common.ztl";
fn main (argc real, argv str[]) { fn main(argc real, argv str[]) {
let screen_width = 800; let screen_width = 800;
let screen_height = 450; let screen_height = 450;
let username = argv[0]; let username = argv[0];
let password = argv[1]; let password = argv[1];
let me = Player( let me = Player(username, (0.0, 1.0, 2.0), PURPLE);
username,
(0.0, 1.0, 2.0),
PURPLE
);
let running = true; let running = true;
while (running) { while (running) {
window("zwl client", screen_width, screen_height) { window("zwl client", screen_width, screen_height) {
splitbox(parent.size*0.25) { splitbox(parent.size * 0.25) {
canvas("2D") { canvas("2D") {
if (button("logout")) { if (button("logout")) {
me.logout(); me.logout();
@ -24,7 +20,7 @@ fn main (argc real, argv str[]) {
} }
} }
} }
splitbox(parent.size*0.75) { splitbox(parent.size * 0.75) {
canvas("3D") { canvas("3D") {
model(Floor((0, 0, 0), 30)); model(Floor((0, 0, 0), 30));
me.update(); me.update();

View File

@ -15,20 +15,16 @@ type Camera {
* Player . * Player .
*/ */
type Player { type Player {
init (username str, pos Vec3, color Color) { init(username str, pos Vec3, color Color) {
this.server = Client("tcp://localhost:25565"); this.server = Client("tcp://localhost:25565");
this.username = username; this.username = username;
this.pos = pos; this.pos = pos;
this.color = color; this.color = color;
this.camera = Camera( this.camera =
(this.pos.x + 10.0, Camera((this.pos.x + 10.0, this.pos.y + 10.0, this.pos.z), this.pos);
this.pos.y + 10.0,
this.pos.z),
this.pos
);
} }
login (password str) Player[] { login(password str) Player[] {
this.server.attach(this.username, password); this.server.attach(this.username, password);
this.players = server.open("players"); this.players = server.open("players");
return players.read(); return players.read();
@ -63,6 +59,6 @@ type Player {
} }
} }
const RED is [255, 0, 0]; const RED is[255, 0, 0];
const WHITE is [0, 0, 0]; const WHITE is[0, 0, 0];
const PURPLE is [255, 255, 0]; const PURPLE is[255, 255, 0];

View File

@ -1,10 +1,10 @@
use "common.ztl"; use "common.ztl";
fn main (argc real, argv str[]) { fn main(argc real, argv str[]) {
let s = Server("tcp://0.0.0.0:25565"); let s = Server("tcp://0.0.0.0:25565");
let running = true; let running = true;
let players = [ Player("user", (0, 0, 0), RED) ]; let players = [Player("user", (0, 0, 0), RED)];
while(running) { while (running) {
if (let client = s.accept("players")) { if (let client = s.accept("players")) {
if (let message = client.get()) { if (let message = client.get()) {
if (message == "close") { if (message == "close") {