From 77b20ae9c253210dcae17db5a8ad5cadef46040d Mon Sep 17 00:00:00 2001 From: John Alanbrook Date: Sat, 9 Mar 2024 14:27:02 -0600 Subject: [PATCH] Correct makefile --- .gitignore | 9 ++++++++- Makefile | 9 ++++++--- doc/prosperon.org | 4 ++-- scripts/components.js | 2 ++ scripts/engine.js | 14 ++++++++------ scripts/entity.js | 7 +++++-- scripts/physics.js | 3 +++ scripts/spline.js | 3 +++ source/engine/2dphysics.c | 4 ++-- source/engine/jsffi.c | 7 +++++++ source/engine/render.c | 6 +++--- source/engine/window.c | 2 ++ 12 files changed, 51 insertions(+), 19 deletions(-) diff --git a/.gitignore b/.gitignore index b8dca54..4dcf56e 100644 --- a/.gitignore +++ b/.gitignore @@ -10,4 +10,11 @@ Jenkinsfile *.log *.gz *.tar - +.nova/ +packer +primum +sokol-shdc +source/shaders/*.h +core.cdb +primum.exe +core.cdb.h \ No newline at end of file diff --git a/Makefile b/Makefile index d161b0c..0c912d9 100755 --- a/Makefile +++ b/Makefile @@ -220,7 +220,7 @@ $(DISTDIR)/$(DIST): $(BIN)/$(NAME) @mkdir -p $(DISTDIR) @$(PKGCMD) -$(BIN)/libengine.a: source/engine/core.cdb.h $(OBJS) +$(BIN)/libengine.a: $(OBJS) @$(AR) rcs $@ $(OBJS) $(BIN)/libcdb.a: @@ -233,7 +233,6 @@ tools/libcdb.a: make -C $(CDB) libcdb.a mv $(CDB)/libcdb.a tools - DOCOS = Sound gameobject Game Window physics Profile Time Player Mouse IO Log ColorMap sprite SpriteAnim Render Geometry DOCHTML := $(addsuffix .api.html, $(DOCOS)) DOCMD := $(addsuffix .api.md, $(DOCOS)) @@ -263,7 +262,7 @@ $(BIN)/libquickjs.a: $(QUICKJS_O) @mkdir -p $(BIN) cp -rf quickjs/libquickjs.* $(BIN) -$(OBJDIR)/%.o: %.c +$(OBJDIR)/%.o: %.c source/engine/core.cdb.h $(SHADERS) @mkdir -p $(@D) @echo Making C object $@ @$(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@ @@ -330,12 +329,16 @@ clean: @echo Cleaning project @rm -rf bin dist @rm -f shaders/*.sglsl.h shaders/*.metal core.cdb jso cdb packer TAGS + @rm source/engine/core.cdb.h @make -C quickjs clean docs: doc/prosperon.org make -C doc mv doc/html . +test: + @echo No tests yet ... + TAGINC != find . -name "*.[chj]" tags: $(TAGINC) @echo Making tags. diff --git a/doc/prosperon.org b/doc/prosperon.org index cc90baf..60c07bd 100644 --- a/doc/prosperon.org +++ b/doc/prosperon.org @@ -106,7 +106,7 @@ Run ~prosperon~. You will see "Hello world!" in the console, and it shuts down. Using ~config.js~ and ~game.js~, you can write an entire game, without reaching any further. When you want to populate a world with independent actors, entities are what you will reach for. ** Actors -The fundamental tool for building in Prosperon is the actor system. Actors run independently from each other. Actors are defined by a combination of code and data. All actors have a *master*[fn::I am aware of the ongoing controversy surrounding the use of this term. That is precisely why I have used it: there are a plethora of similar relationships in video games, and by using a term most teams would rather not used, I have saved left the field of avaialable ones wide open] which controls certain properties of the actor. +The fundamental tool for building in Prosperon is the actor system. Actors run independently from each other. Actors are defined by a combination of code and data. All actors have a *master* which controls certain properties of the actor. The most masterful actor is the *Empyrean*. The first actor you create will have the Empyrean as its master. Subsequent actors can use any other actor as its master. @@ -117,7 +117,7 @@ The most masterful actor is the *Empyrean*. The first actor you create will have | delay(fn, seconds) | Calls 'fn' after 'seconds' with the context of the actor | *** Actor Lifetime -When an actor dies, all of the actors that have it as their master[fn::What a mouthful!] will die as well. +When an actor dies, all of the actors that have it as their master will die as well. *** Turns Actors get fragments of time called a *turn*. Actors which belong to different systems can have different lengths of turns. diff --git a/scripts/components.js b/scripts/components.js index 55e35e7..5c4da8b 100644 --- a/scripts/components.js +++ b/scripts/components.js @@ -527,6 +527,8 @@ component.edge2d = Object.copy(collider2d, { sample() { var spoints = this.spoints(); + if (spoints.length === 0) return []; + if (this.type === -1) { if (this.looped) spoints.push(spoints[0]); return spoints; diff --git a/scripts/engine.js b/scripts/engine.js index 8fa0271..109e294 100644 --- a/scripts/engine.js +++ b/scripts/engine.js @@ -383,13 +383,15 @@ var Window = { dimensions() { return cmd(265); }, get width() { return this.dimensions().x; }, get height() { return this.dimensions().y; }, + set width(x) { cmd(266, x); }, + set height(x) { cmd(267,x); }, mode: { - stretch: 0, - keep: 1, - width: 2, - height: 3, - expand: 4, - full: 5 + stretch: 0, // stretch to fill window + keep: 1, // keep exact dimensions + width: 2, // keep width + height: 3, // keep height + expand: 4, // expand width or height + full: 5 // expand out beyond window }, aspect(x) { cmd(264, x); }, title(str) { cmd(134, str); }, diff --git a/scripts/entity.js b/scripts/entity.js index 2b6b8ec..4645736 100644 --- a/scripts/entity.js +++ b/scripts/entity.js @@ -234,6 +234,7 @@ var gameobject = { }, cry(file) { + return; this.crying = audio.sound.play(file, audio.sound.bus.sfx); var killfn = () => {this.crying = undefined; console.warn("killed"); } this.crying.hook = killfn; @@ -301,7 +302,8 @@ var gameobject = { Object.mixin(ent,gameobject_impl); ent.body = make_gameobject(); - + ent.warp_layer = [true]; + ent.phys = 2; ent.components = {}; ent.objects = {}; ent.timers = []; @@ -673,7 +675,7 @@ gameobject.doc = { elasticity: `When two objects collide, their elasticities are multiplied together. Their velocities are then multiplied by this value to find their resultant velocities.`, friction: `When one object touches another, friction slows them down.`, mass: `The higher the mass of the object, the less forces will affect it.`, - phys: `Set to 0, 1, or 2, representing static, kinematic, and dynamic.`, + phys: `Set to 0, 1, or 2, representing dynamic, kinematic, and static.`, worldpos: `Function returns the world position of the object.`, set_worldpos: `Function to set the position of the object in world coordinates.`, worldangle: `Function to get the angle of the entity in the world.`, @@ -737,6 +739,7 @@ ur { /* u is given as */ function apply_ur(u, e) { + say(`applying ur ${u}`); if (typeof u !== 'string') { console.warn("Must give u as a string."); return; diff --git a/scripts/physics.js b/scripts/physics.js index 02c6a74..5cb102e 100644 --- a/scripts/physics.js +++ b/scripts/physics.js @@ -70,7 +70,10 @@ physics.warp.gravity = function() { return cmd(253); } physics.warp.damp = function() { return cmd(254); } physics.gravity = physics.warp.gravity(); +physics.gravity.mask = [true]; +physics.gravity.strength = 500; physics.damp = physics.warp.damp(); +physics.damp.mask = [true]; return { physics diff --git a/scripts/spline.js b/scripts/spline.js index fb43bce..61eb9cb 100644 --- a/scripts/spline.js +++ b/scripts/spline.js @@ -51,12 +51,15 @@ Spline.catmull_loop = function(cp) Spline.catmull_caps = function(cp) { + if (cp.length < 2) return; cp = cp.slice(); cp.unshift(cp[0].sub(cp[1]).add(cp[0])); cp.push(cp.last().sub(cp.at(-2).add(cp.last()))); return cp; } +Spline.catmull_caps.doc = "Given a set of control points cp, return the necessary caps added to the spline."; + Spline.catmull2bezier.doc = "Given a set of control points C for a camtull-rom type curve, return a set of cubic bezier points to give the same curve." Spline.type = { diff --git a/source/engine/2dphysics.c b/source/engine/2dphysics.c index d0e5205..c04e5a0 100644 --- a/source/engine/2dphysics.c +++ b/source/engine/2dphysics.c @@ -430,9 +430,9 @@ struct phys2d_edge *Make2DEdge(gameobject *go) { new->shape.go = go; new->shape.data = new; new->shape.debugdraw = phys2d_dbgdrawedge; - new->shape.moi = phys2d_edge_moi; + new->shape.moi = phys2d_edge_moi; new->shape.shape = NULL; - new->shape.apply = NULL; + new->shape.apply = NULL; new->shape.free = phys2d_edge_free; new->draws = 0; phys2d_applyedge(new); diff --git a/source/engine/jsffi.c b/source/engine/jsffi.c index b06edac..aaad214 100644 --- a/source/engine/jsffi.c +++ b/source/engine/jsffi.c @@ -1458,10 +1458,17 @@ JSValue duk_cmd(JSContext *js, JSValueConst this, int argc, JSValueConst *argv) break; case 264: aspect_mode = js2int(argv[1]); + window_resize(0,0); break; case 265: ret = vec2js((HMM_Vec2){mainwin.width, mainwin.height}); break; + case 266: + mainwin.width = js2number(argv[1]); + break; + case 267: + mainwin.height = js2number(argv[1]); + break; } if (str) JS_FreeCString(js, str); diff --git a/source/engine/render.c b/source/engine/render.c index e9afa0a..f4db3af 100644 --- a/source/engine/render.c +++ b/source/engine/render.c @@ -434,9 +434,9 @@ void full_2d_pass(struct window *window) sg_apply_viewportf(left,0,pwidth, window->height,1); // keep height break; case MODE_FULL: - usewidth = window->width; - useheight = window->height; - break; + usewidth = window->width; + useheight = window->height; + break; } // 2D projection diff --git a/source/engine/window.c b/source/engine/window.c index 074009f..a41ffbd 100644 --- a/source/engine/window.c +++ b/source/engine/window.c @@ -23,6 +23,8 @@ struct Texture *icon = NULL; void window_resize(int width, int height) { + width = sapp_width(); + height = sapp_height(); mainwin.dpi = sapp_dpi_scale(); mainwin.width = sapp_width(); mainwin.height = sapp_height();