diff --git a/lisp/client/picolisp/client.l b/lisp/client/picolisp/client.l old mode 100755 new mode 100644 index df8d3b4..6f97979 --- a/lisp/client/picolisp/client.l +++ b/lisp/client/picolisp/client.l @@ -3,76 +3,100 @@ (load "@lib/clang.l") (clang "structs" '("-lraylib") - (BeginMode3D (pos tgt up fovy projection) PilBeginMode3D NIL (cons (car pos) -1.0) - (cons (cadr pos) -1.0) - (cons (caddr pos) -1.0) - (cons (car tgt) -1.0) - (cons (cadr tgt) -1.0) - (cons (caddr tgt) -1.0) - (cons (car up) -1.0) - (cons (cadr up) -1.0) - (cons (caddr up) -1.0) - fovy projection) - (DrawCube (pos width height length col) PilDrawCube NIL (cons (car pos) -1.0) - (cons (cadr pos) -1.0) - (cons (caddr pos) -1.0) - (cons width -1.0) - (cons length -1.0) - (cons height -1.0) col) - ) + (DrawCube (pos w l h color) PilDrawCube NIL (cons (car pos) -1.0) + (cons (cadr pos) -1.0) + (cons (caddr pos) -1.0) + (cons w -1.0) + (cons l -1.0) + (cons h -1.0) + color) + (BeginMode3D (pos target) PilBeginMode3D NIL (cons (car pos) -1.0) + (cons (cadr pos) -1.0) + (cons (caddr pos) -1.0) + (cons (car target) -1.0) + (cons (cadr target) -1.0) + (cons (caddr target) -1.0) ) ) #include #include "raylib.h" -void PilBeginMode3D(float pos_x, float pos_y, float pos_z, float tgt_x, float tgt_y, float tgt_z, float up_x, float up_y, float up_z, float fovy, int projection) -{ - Camera camera = {0}; - camera.position = (Vector3){pos_x,pos_y,pos_z}; - camera.target = (Vector3){tgt_x,tgt_y,tgt_z}; - camera.up = (Vector3){up_x,up_y,up_z}; - camera.fovy = fovy; - camera.projection = projection; +void +PilBeginMode3D (float pos_x, float pos_y, float pos_z, float tgt_x, float tgt_y, float tgt_z) +{ + Camera camera = {0}; - BeginMode3D(camera); + Vector3 position = {0}; + position.x = pos_x; + position.y = pos_y; + position.z = pos_z; + + Vector3 target = {0}; + target.x = tgt_x; + target.y = tgt_y; + target.z = tgt_z; + + camera.position = position; + camera.target = target; + camera.up = (Vector3){0.0f, 1.0f, 0.0f}; + camera.fovy = 60.0f; + camera.projection = 0; + + UpdateCameraPro(&camera, (Vector3){0.0f,0.0f,0.0f},(Vector3){0.0f,0.0f,0.0f},0.0f); + + BeginMode3D(camera); } -void PilDrawCube(float pos_x, float pos_y, float pos_z, float width, float height, float length, Color color) { - DrawCube((Vector3){pos_x, pos_y, pos_z}, width, height, length, color); +void +PilDrawCube (float pos_x, float pos_y, float pos_z, float w, float l, float h, Color color) +{ + Vector3 position = {0}; + position.x = pos_x; + position.y = pos_y; + position.z = pos_z; + + DrawCube(position, w, l, h, color); } /**/ -(de raylib @ (pass native "libraylib.dylib")) +(de raylib @ (pass native "libraylib.so")) -(setq screen_width 800 - screen_height 450 - KEY_RIGHT 262 - KEY_LEFT 263 - KEY_DOWN 264 - KEY_UP 265 - CAMERA_PERSPECTIVE 0 - RAYWHITE (hex "FFF5F5F5") - DARKGRAY (hex "FF505050") - MAROON (hex "FF3721BE")) +(de MovePos (pos) + (when (=1 (raylib "IsKeyDown" 'B KEY_RIGHT)) (inc pos 0.2)) + (when (=1 (raylib "IsKeyDown" 'B KEY_LEFT)) (dec pos 0.2)) + (when (=1 (raylib "IsKeyDown" 'B KEY_UP)) (dec (cddr pos) 0.2)) + (when (=1 (raylib "IsKeyDown" 'B KEY_DOWN)) (inc (cddr pos) 0.2)) ) -(setq camera_pos (list 0.0 12.0 14.0) ) -(setq target_pos (list 0.0 2.0 0.0) ) -(setq up_vec (list 0.0 1.0 0.0) ) +(setq screen_width 800 + screen_height 450 + KEY_RIGHT 262 + KEY_LEFT 263 + KEY_DOWN 264 + KEY_UP 265 + MOUSE_BUTTON_LEFT 0 + RAYWHITE (hex "FFF5F5F5") + DARKGRAY (hex "FF505050") + MAROON (hex "FF3721BE")) + +(raylib "InitWindow" NIL screen_width screen_height "raylib mmo - picolisp") + +(setq camera_pos (list 0.0 10.0 10.0) ) +(setq target_pos (list 0.0 0.0 0.0) ) -(raylib "InitWindow" NIL screen_width screen_height "raylib [core] example - basic window") (raylib "SetTargetFPS" NIL 60) -(until (= 1 (raylib "WindowShouldClose" 'B)) - (raylib "BeginDrawing") - (raylib "ClearBackground" NIL RAYWHITE) - (BeginMode3D camera_pos target_pos up_vec 60.0 0) +(while (=0 (raylib "WindowShouldClose" 'B)) - (raylib "DrawGrid" NIL 30 (cons 1.0 -1.0)) + (MovePos camera_pos) + (MovePos target_pos) - (DrawCube target_pos 0.5 0.5 0.5 MAROON) + (raylib "BeginDrawing") + (raylib "ClearBackground" NIL RAYWHITE ) + (BeginMode3D camera_pos target_pos) + (raylib "DrawGrid" NIL 30 (cons 1.0 -1.0)) + (DrawCube target_pos 0.5 0.5 0.5 MAROON) + (raylib "EndMode3D") + (raylib "EndDrawing") ) - (raylib "EndMode3D") - (raylib "EndDrawing") ) (raylib "CloseWindow") (bye) - diff --git a/lisp/client/picolisp/old/basic-window.l b/lisp/client/picolisp/demo/basic-window.l similarity index 100% rename from lisp/client/picolisp/old/basic-window.l rename to lisp/client/picolisp/demo/basic-window.l diff --git a/lisp/client/picolisp/old/libraylib.dylib b/lisp/client/picolisp/demo/libraylib.dylib similarity index 100% rename from lisp/client/picolisp/old/libraylib.dylib rename to lisp/client/picolisp/demo/libraylib.dylib diff --git a/lisp/client/picolisp/input-keys.l b/lisp/client/picolisp/input-keys.l deleted file mode 100755 index 39c3f1e..0000000 --- a/lisp/client/picolisp/input-keys.l +++ /dev/null @@ -1,51 +0,0 @@ -(scl 4) - -(load "@lib/clang.l") - -(clang "structs" '("-lraylib") - (DrawCircleV (pos r col) PilDrawCircleV NIL (cons (car pos) -1.0) (cons (cadr pos) -1.0) (cons r -1.0) col) ) - -#include -#include "raylib.h" -void PilDrawCircleV (float x, float y, float r, Color col){ - Vector2 v = {x,y}; - DrawCircleV(v,r,col); - DrawCircle(x,y,r,col); -} - -/**/ - -(de raylib @ (pass native "libraylib.dylib")) - -(setq screenWidth 800 - screenHeight 450 - KEY_RIGHT 262 - KEY_LEFT 263 - KEY_DOWN 264 - KEY_UP 265 - RAYWHITE (hex "FFF5F5F5") - DARKGRAY (hex "FF505050") - MAROON (hex "FF3721BE")) - -(raylib "InitWindow" NIL screenWidth screenHeight "raylib [core] example - keyboard input") - -(setq ballPosition (list (*/ screenWidth 1.0 2) (*/ screenHeight 1.0 2)) ) - -(raylib "SetTargetFPS" NIL 60) - - -(while (=0 (raylib "WindowShouldClose" 'B)) - (when (=1 (raylib "IsKeyDown" 'B KEY_RIGHT)) (inc ballPosition 2.)) - (when (=1 (raylib "IsKeyDown" 'B KEY_LEFT)) (dec ballPosition 2.)) - (when (=1 (raylib "IsKeyDown" 'B KEY_UP)) (dec (cdr ballPosition) 2.)) - (when (=1 (raylib "IsKeyDown" 'B KEY_DOWN)) (inc (cdr ballPosition) 2.)) - - (raylib "BeginDrawing") - (raylib "ClearBackground" NIL RAYWHITE ) - (raylib "DrawText" NIL "move the ball with arrow keys" 10 10 20 DARKGRAY) - (DrawCircleV ballPosition 50.0 MAROON) - (raylib "EndDrawing") -) - -(raylib "CloseWindow") -(bye) \ No newline at end of file diff --git a/lisp/server/server.l b/lisp/server/server.l new file mode 100644 index 0000000..aacb24d --- /dev/null +++ b/lisp/server/server.l @@ -0,0 +1,27 @@ +(de chat Lst + (out *Sock + (mapc prin Lst) + (prinl) ) ) + +(setq *Port (port 4004)) + +(loop + (setq *Sock (listen *Port)) + (NIL (fork) (close *Port)) + (close *Sock) ) + +(out *Sock + (prin "Please enter your name: ") + (flush) ) +(in *Sock (setq *Name (line T))) + +(tell 'chat "+++ " *Name " arrived +++") + +(task *Sock + (in @ + (ifn (eof) + (tell 'chat *Name "> " (line T)) + (tell 'chat "--- " *Name " left ---") + (bye) ) ) ) +(wait) + diff --git a/lisp/www/run.sh b/lisp/www/run.sh new file mode 100755 index 0000000..0e330bc --- /dev/null +++ b/lisp/www/run.sh @@ -0,0 +1,2 @@ +#!/bin/sh +pil www.l -main -go -wait diff --git a/lisp/www/users.db b/lisp/www/users.db new file mode 100644 index 0000000..aec433d Binary files /dev/null and b/lisp/www/users.db differ diff --git a/lisp/www/www.l b/lisp/www/www.l new file mode 100644 index 0000000..728d829 --- /dev/null +++ b/lisp/www/www.l @@ -0,0 +1,27 @@ + + (allowed () + "!work" "@lib.css" ) + + (load "@lib/http.l" "@lib/xhtml.l" "@lib/form.l") + + (class +User +Entity) + (rel username (+Need +Sn +Idx +String)) + (rel password (+String)) + (rel px (+Number)) + (rel py (+Number)) + (rel appearance (+String)) + (rel login (+Date)) + (rel created (+Date)) + + (de work () + (app) + (action + (html 0 "MMO Project" "@lib.css" NIL + (

NIL "hello world!") ) ) ) + + (de main () + (locale "US") + (pool "users.db") ) + + (de go () + (server 8080 "!work") )