add object merging

This commit is contained in:
2023-09-22 00:51:38 +00:00
parent 14d743e704
commit a8eb444991
6 changed files with 101 additions and 43 deletions

View File

@@ -1314,11 +1314,9 @@ JSValue duk_set_body(JSContext *js, JSValueConst this, int argc, JSValueConst *a
break;
case 7:
go->mass = js2number(argv[2]);
if (go->bodytype == CP_BODY_TYPE_DYNAMIC)
cpBodySetMass(go->body, js2number(argv[2]));
else
YughWarn("Cannot set mass of a non dynamic body.");
cpBodySetMass(go->body, go->mass);
break;
case 8:

View File

@@ -8,6 +8,7 @@
#include "time.h"
#include <stdio.h>
#include <ctype.h>
#include <wchar.h>
#include "resources.h"
#include "stb_ds.h"
@@ -190,13 +191,17 @@ void input_btn(int btn, int state, uint32_t mod)
}
}
void input_key(int key, uint32_t mod)
static const uint32_t UNCHAR_FLAGS = SAPP_MODIFIER_CTRL | SAPP_MODIFIER_ALT | SAPP_MODIFIER_SUPER;
void input_key(uint32_t key, uint32_t mod)
{
if (mod & UNCHAR_FLAGS) return;
if (key <= 31 || key >= 127) return;
JSValue argv[2];
char out[2] = {0};
out[0] = (char)key;
char s[2] = {key, '\0'};
argv[0] = JS_NewString(js, "char");
argv[1] = JS_NewString(js, out);
argv[1] = JS_NewString(js, s);
script_callee(pawn_callee, 2, argv);
JS_FreeValue(js, argv[0]);

View File

@@ -29,7 +29,7 @@ void input_mouse(int btn, int state, uint32_t mod);
void input_mouse_move(float x, float y, float dx, float dy, uint32_t mod);
void input_mouse_scroll(float x, float y, uint32_t mod);
void input_btn(int btn, int state, uint32_t mod);
void input_key(int key, uint32_t mod);
void input_key(uint32_t key, uint32_t mod);
const char *keyname_extd(int key);
int action_down(int key);