From 5388b2cafeb4c40888ed55cb2148c7ddba69da28 Mon Sep 17 00:00:00 2001 From: "Jill \"oatmealine\" Monoids" Date: Fri, 9 Dec 2022 21:55:17 +0300 Subject: [PATCH] don't reset actors each frame by default; make the behavior toggleable --- MANUAL.md | 21 ++++++++++++++++----- src/main.lua | 1 + template | 2 +- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/MANUAL.md b/MANUAL.md index 825256b..95c7c15 100644 --- a/MANUAL.md +++ b/MANUAL.md @@ -200,9 +200,11 @@ text:rotationz(30) text:diffuse(1, 0.8, 0.8, 1) ``` -All methods that you run upon definition will be ran again at the start of every frame: +All methods that you run upon definition will be ran again at the start of every frame with `resetOnFrameStart`: ```lua +resetOnFrameStart(true) + local quad = Quad() quad:xy(scx, scy) quad:zoomto(60, 60) @@ -217,7 +219,7 @@ function uranium.update() end ``` -If you want to avoid this, or otherwise call getter methods, use the [`uranium.init`](#uraniuminit) callback: +If you want to avoid this for individual actors, or otherwise call getter methods, use the [`uranium.init`](#uraniuminit) callback: ```lua local sprite = Sprite() @@ -235,6 +237,14 @@ sprite:addcommand('Init', function(self) end) ``` +Or, you can disable the frame resetting functionality individually: +```lua +resetOnFrameStart(true) +local sprite = Sprite() +resetActorOnFrameStart(sprite, false) +sprite:Draw() -- will not be called per-frame +``` + ### Accessing raw actors As you may have noticed, when you print an actor defined with Uranium, it won't show up as an actor - it'll show up as a "proxy" of an actor. This is because we can't actually get actors created on demand in NotITG - what happens instead is you get an object that _acts_ like an actor by calling all the same methods you pass into it, but isn't really one. @@ -1134,6 +1144,7 @@ quad:xy(scx, scy) quad:zoom(120) quad:diffuse(0.8, 1, 0.7, 1) quad:skewx(0.2) +resetActorOnFrameStart(quad) -- define a sprite local sprite = Sprite('docs/uranium.png') @@ -1363,12 +1374,12 @@ void main() { gl_FragColor = col * color; } ]]) -shader:uniform1f('yo', 1) -shader:uniform1f('scale', 0.25) - setShader(sprite, shader) function uranium.update() + shader:uniform1f('yo', 1) + shader:uniform1f('scale', 0.25) + shader:uniform1f('tx', t) shader:uniform1f('ty', t) diff --git a/src/main.lua b/src/main.lua index 9b789a4..bf0fa45 100644 --- a/src/main.lua +++ b/src/main.lua @@ -10,6 +10,7 @@ quad:xy(scx, scy) quad:zoom(120) quad:diffuse(0.8, 1, 0.7, 1) quad:skewx(0.2) +resetActorOnFrameStart(quad) -- define a sprite local sprite = Sprite('docs/uranium.png') diff --git a/template b/template index f4e8c1d..0a1805e 160000 --- a/template +++ b/template @@ -1 +1 @@ -Subproject commit f4e8c1df7ca44eff65662d636fcb1ddb74254121 +Subproject commit 0a1805e6fa8448bcf38b0dde5a77e64213e49bc8