diff --git a/lisp/client/client.lisp b/lisp/client/client.lisp deleted file mode 100644 index 9491a6a..0000000 --- a/lisp/client/client.lisp +++ /dev/null @@ -1,2 +0,0 @@ -(ql:quickload '(:claylib :usocket :simple-actors :bordeau-thread)) - diff --git a/lisp/client/picolisp/client.l b/lisp/client/picolisp/client.l new file mode 100755 index 0000000..df8d3b4 --- /dev/null +++ b/lisp/client/picolisp/client.l @@ -0,0 +1,78 @@ +(scl 4) + +(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) + ) + +#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; + + 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); +} + +/**/ + +(de raylib @ (pass native "libraylib.dylib")) + +(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")) + +(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) ) + +(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) + + (raylib "DrawGrid" NIL 30 (cons 1.0 -1.0)) + + (DrawCube target_pos 0.5 0.5 0.5 MAROON) + + (raylib "EndMode3D") + (raylib "EndDrawing") ) +(raylib "CloseWindow") +(bye) + diff --git a/lisp/client/picolisp/input-keys.l b/lisp/client/picolisp/input-keys.l new file mode 100755 index 0000000..39c3f1e --- /dev/null +++ b/lisp/client/picolisp/input-keys.l @@ -0,0 +1,51 @@ +(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/client/picolisp/old/basic-window.l b/lisp/client/picolisp/old/basic-window.l new file mode 100755 index 0000000..bb4e488 --- /dev/null +++ b/lisp/client/picolisp/old/basic-window.l @@ -0,0 +1,11 @@ +(de raylib @ (pass native "libraylib.dylib")) + +(raylib "InitWindow" NIL 800 450 "raylib [core] example - basic window") +(raylib "SetTargetFPS" NIL 60) +(until (= 1 (raylib "WindowShouldClose" 'I)) + (raylib "BeginDrawing") + (raylib "ClearBackground" NIL (hex "FFF5F5F5")) + (raylib "DrawText" NIL "Congrats! You created your first window!" 190 200 20 (hex "ffc8c8c8")) + (raylib "EndDrawing") ) +(raylib "CloseWindow") +(bye) diff --git a/lisp/client/picolisp/old/libraylib.dylib b/lisp/client/picolisp/old/libraylib.dylib new file mode 100644 index 0000000..dcd75ee Binary files /dev/null and b/lisp/client/picolisp/old/libraylib.dylib differ diff --git a/lisp/client/picolisp/run.sh b/lisp/client/picolisp/run.sh new file mode 100755 index 0000000..416b903 --- /dev/null +++ b/lisp/client/picolisp/run.sh @@ -0,0 +1,2 @@ +#!/bin/bash +~/pil21/pil ~/pil21/lib.l ./input-keys.l \ No newline at end of file diff --git a/lisp/client/client.rkt b/lisp/client/racket/client.rkt similarity index 100% rename from lisp/client/client.rkt rename to lisp/client/racket/client.rkt diff --git a/lisp/client/sbcl/client.lisp b/lisp/client/sbcl/client.lisp new file mode 100644 index 0000000..e5058da --- /dev/null +++ b/lisp/client/sbcl/client.lisp @@ -0,0 +1,43 @@ + (load "~/quicklisp/setup.lisp") +(ql:quickload '(:claylib :usocket :simple-actors :bordeau-thread)) + +(defvar *mouse-delta* (make-vector2 0 0)) + +(defun reset-up (camera) + (setf (x (up camera)) 0 + (y (up camera)) 1 + (z (up camera)) 0)) + +(defun pro-mvmt (key1 key2) + (if (or (is-key-down-p key1) (is-key-down-p key2)) 0.1 0)) + +(defun pro-mode-update (camera) + (get-mouse-delta :vec *mouse-delta*) + (setf (x (movement camera)) (- (pro-mvmt +key-w+ +key-up+) + (pro-mvmt +key-s+ +key-down+)) + (y (movement camera)) (- (pro-mvmt +key-d+ +key-right+) + (pro-mvmt +key-a+ +key-left+)) + (x (rot camera)) (* 0.05 (x *mouse-delta*)) + (y (rot camera)) (* 0.05 (y *mouse-delta*)) + (zoom camera) (* 2 (get-mouse-wheel-move)))) + + (with-window (:title "common lisp client : raylib") + (let ((camera (make-camera-3d 0 2 4 + 0 2 0 + 0 1 0 + :fovy 60.0 + :projection +camera-perspective+ + :mode +camera-first-person+)) + (scene (make-scene () + ((ground (make-plane 0 0 0 32 32 +lightgray+)) + (blue (make-cube -16 2.5 0 + 1 5 32 + +blue+))))))) + (with-scenes scene () + (do-game-loop (:livesupport t) +(pro-mode-update camera) + (with-drawing () + (with-3d-mode camera + (draw-scene scene '(ground blue green yellow)) + (draw-scene-regex scene "^COLUMN")) + (draw-scene-regex scene "^(STATUS|INST)")))))) diff --git a/lisp/client/install-cl-raylib.sh b/lisp/client/sbcl/install-cl-raylib.sh old mode 100644 new mode 100755 similarity index 100% rename from lisp/client/install-cl-raylib.sh rename to lisp/client/sbcl/install-cl-raylib.sh