reorganize lisp
This commit is contained in:
parent
6ff83af479
commit
ff1b75c044
|
@ -1,2 +0,0 @@
|
||||||
(ql:quickload '(:claylib :usocket :simple-actors :bordeau-thread))
|
|
||||||
|
|
|
@ -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 <stdio.h>
|
||||||
|
#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)
|
||||||
|
|
|
@ -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 <stdio.h>
|
||||||
|
#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)
|
|
@ -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)
|
Binary file not shown.
|
@ -0,0 +1,2 @@
|
||||||
|
#!/bin/bash
|
||||||
|
~/pil21/pil ~/pil21/lib.l ./input-keys.l
|
|
@ -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)"))))))
|
0
lisp/client/install-cl-raylib.sh → lisp/client/sbcl/install-cl-raylib.sh
Normal file → Executable file
0
lisp/client/install-cl-raylib.sh → lisp/client/sbcl/install-cl-raylib.sh
Normal file → Executable file
Loading…
Reference in New Issue