diff --git a/Makefile b/Makefile index 15d6f68..d25d4b6 100755 --- a/Makefile +++ b/Makefile @@ -115,7 +115,7 @@ $(BIN)$(NAME): $(objprefix)/source/engine/yugine.o $(ENGINE) $(CC) $< $(LINK) -o $(BIN)$(NAME) @echo Finished build -$(BIN)$(DIST): $(BIN)$(NAME) source/scripts/* source/shaders/* +$(BIN)$(DIST): $(BIN)$(NAME) source/shaders/* @echo Creating distribution $(DIST) @mkdir -p $(BIN)dist @cp $(BIN)$(NAME) $(BIN)dist diff --git a/source/engine/2dphysics.c b/source/engine/2dphysics.c index 68750e0..29b2307 100644 --- a/source/engine/2dphysics.c +++ b/source/engine/2dphysics.c @@ -467,6 +467,11 @@ void phys2d_dbgdrawedge(struct phys2d_edge *edge) } } +cpShape *id2shape(int id) +{ + return NULL; +} + void phys2d_reindex_body(cpBody *body) { cpSpaceReindexShapesForBody(space, body); } diff --git a/source/engine/2dphysics.h b/source/engine/2dphysics.h index 6fb872d..f39198d 100644 --- a/source/engine/2dphysics.h +++ b/source/engine/2dphysics.h @@ -97,6 +97,8 @@ void phys2d_add_handler_type(int cmd, int go, struct callee c); void register_collide(void *sym); void phys2d_set_gravity(cpVect v); +cpShape *id2shape(int id); + struct color { unsigned char r; unsigned char g; diff --git a/source/engine/ffi.c b/source/engine/ffi.c index 482224f..2f5beae 100644 --- a/source/engine/ffi.c +++ b/source/engine/ffi.c @@ -152,6 +152,17 @@ duk_ret_t duk_cmd(duk_context *duk) { set_trigger_color(duk2color(duk, 1)); break; + case 18: + cpShapeSetSensor(id2shape(duk_to_int(duk, 1)), duk_to_boolean(duk, 2)); + break; + + case 19: + if (id2shape(duk_to_int(duk, 1))) + duk_push_boolean(duk, cpShapeGetSensor(id2shape(duk_to_int(duk, 1)))); + else + duk_push_undefined(duk); + + return 1; } return 0; diff --git a/source/engine/input.c b/source/engine/input.c index 3a7c2ec..95dbfae 100644 --- a/source/engine/input.c +++ b/source/engine/input.c @@ -127,6 +127,10 @@ const char *keyname_extd(int key, int scancode) { case GLFW_KEY_RIGHT_ALT: kkey= "ralt"; break; + + case GLFW_KEY_SPACE: + kkey = "space"; + break; } if (kkey) return kkey; diff --git a/source/scripts/engine.scm b/source/scripts/engine.scm deleted file mode 100644 index 8ad7ca3..0000000 --- a/source/scripts/engine.scm +++ /dev/null @@ -1,165 +0,0 @@ -(define-macro (time expr) - `(let ((start (*s7* 'cpu-time))) - (let ((res (list ,expr))) - (list (car res) - (- (*s7* 'cpu-time) start))))) - -(define-macro (funcinfo func info) - `(*function* (funclet ,func) ,info)) - -(define-macro (funcloc func) - `(format #f "~A:~A" (funcinfo ,func 'file) (funcinfo ,func 'line))) - -(define-macro (funcsrc func) - `(funcinfo ,func 'source)) - -(define (objects->string . objs) - (apply string-append (map (lambda (obj) (object->string obj #f)) objs))) - -(define-bacro (glog data lvl) - (let ((file (port-filename)) - (line (port-line-number))) - `(log ,lvl ,data - (if (equal? ,file "*stdin*") (*function* (outlet (curlet)) 'file) ,file) - (if (equal? ,file "*stdin*") (*function* (outlet (curlet)) 'line) ,line)))) - -(define-bacro (loginfo . data) - `(glog (objects->string ,@data) 0)) - -(define-bacro (logwarn . data) - `(glog (objects->string ,@data) 1)) - -(define-bacro (logerr . data) - `(glog (objects->string ,@data) 2)) - -(define-bacro (logcrit . data) - `(glog (objects->string ,@data) 3)) - -(define (set_fps fps) (settings_cmd 0 (/ 1 fps))) -(define (set_update fps) (settings_cmd 1 (/ 1 fps))) -(define (set_phys fps) (settings_cmd 2 (/ 1 fps))) -(define (zoom! amt) (settings_cmd 5 amt)) - -(define (win_fulltoggle) (win_cmd 0 0)) -(define (win_fullscreen) (win_cmd 0 1)) -(define (win_unfullscreen) (win_cmd 0 2)) -(define (win_w) (win_cmd 0 3)) -(define (win_h) (win_cmd 0 4)) - -(define (load_level s) (gen_cmd 0 s)) -(define (load_prefab s) (gen_cmd 1 s)) -(define (newobject) (sys_cmd 7)) -(define (clear_level) (sys_cmd 9)) -(define (fps) (sys_cmd 8)) -(define (quit) (sys_cmd 0)) -(define (exit) (quit)) - -(define (sound_play sound) (sound_cmd sound 0)) -(define (sound_pause sound) (sound_cmd sound 1)) -(define (sound_stop sound) (sound_cmd sound 2)) -(define (sound_restart sound) (sound_cmd sound 3)) - -(define-macro (anim_play anim) - `(anim_cmd 0 body ,anim)) - -(define-macro (registertype type . expr) - (let ((f (gensym))) - `(begin - (define (,f) (begin . ,expr)) - (register ,(case type - ((update) 0) - ((gui) 1)) ,f)))) - -(define-macro (update . expr) - (let ((f (gensym))) - `(begin - (define (,f dt) (begin . ,expr)) - (register 0 ,f)))) - -(define-macro (gui . expr) - `(registertype gui - (let ((pos #(0 0))) ,@expr))) - -(define-macro (while condition . body) - (let ((loop (gensym))) - `(let ,loop () - (cond (,condition - (begin . ,body) - (,loop)))))) - -(define (clamp val min max) - (cond ((< val min) min) - ((> val max) max) - (else val))) - -(define (lerp s f dt) - (+ s (* (clamp dt 0 1) (- f s)))) - -(define (deg2rad deg) - (* deg 0.01745329252)) - - - -(define-macro (body_type! body type) - `(set_body ,body 1 ,(case type - ((static) 2) - ((dynamic) 0) - ((kinematic) 1)))) - -(define (body_angle! body angle) (set_body body 0 angle)) -(define (body_pos! body pos) (set_body body 2 pos)) -(define (body_move! body vec) (set_body body 3 vec)) -(define (body_flipx! body flip) (set_body body 5 flip)) -(define (body_flipy! body flip) (set_body body 6 flip)) - -(define (gravity! x y) (phys_set 0 x y)) - -(define (b2i val) (if (eq? val #f) 0 1)) -(define (dbg_draw_phys val) (settings_cmd 3 (b2i val))) -(define (timescale! val) (settings_cmd 4 val)) -(define (sim_play) (sys_cmd 1)) -(define (sim_stop) (sys_cmd 2)) -(define (sim_pause) (sys_cmd 3)) -(define (sim_step) (sys_cmd 4)) -(define (sim_play?) (sys_cmd 5)) -(define (sim_pause?) (sys_cmd 6)) - -(define (camera! body) (int_cmd 0 body)) - -(define (bodytype? body) (phys_q body 0)) - -(define-macro (register-phys type . expr) - (let ((f (gensym))) - `(begin - (define (,f hit norm) (begin . ,expr)) - (phys_cmd body ,(case type - ((collide) 0) - ((separate) 3)) ,f)))) - -(define-macro (collide . expr) - `(register-phys collide ,@expr)) - -(define-macro (separate . expr) - `(register-phys separate ,@expr)) - -(define-macro (not! var) - `(set! ,var (not ,var))) - -(define-macro* (define-script name (lets ()) . expr ) - `(define* (,name (gameobject -1)) - (let ((body gameobject) - ,@lets) - ,@expr - (curlet)))) - -(define-macro (input key . expr) - `(define (,(symbol "input_" (symbol->string key))) (begin . ,expr))) - -(define-macro (+=! var amt) - `(set! ,var (+ ,var ,amt))) - -(define-macro (-=! var amt) - `(set! ,var (- ,var ,amt))) - -(define (attach-script script object) - (let-set! script 'body object))