diff --git a/sjplayer/src/sjplayer/CircleElement.d b/sjplayer/src/sjplayer/CircleElement.d index 6dda0da..68a4c85 100644 --- a/sjplayer/src/sjplayer/CircleElement.d +++ b/sjplayer/src/sjplayer/CircleElement.d @@ -152,7 +152,7 @@ class CircleElementProgram { float r = length(uv_); float w = 1 - weight_; return - smoothstep(w, w+smooth_, r) * + smoothstep(w-smooth_, w, r) * (1 - smoothstep(1-smooth_, 1, r)); } diff --git a/sjplayer/src/sjplayer/CircleElementScheduledController.d b/sjplayer/src/sjplayer/CircleElementScheduledController.d index 0a7ce6a..980cf25 100644 --- a/sjplayer/src/sjplayer/CircleElementScheduledController.d +++ b/sjplayer/src/sjplayer/CircleElementScheduledController.d @@ -28,9 +28,9 @@ class CircleElementScheduledController : element_.alive = true; element_.damage = 0; element_.nearness_coe = 0; - element_.matrix = mat3.identity; + element_.matrix = mat3.identity.transposed; element_.weight = 1; - element_.smooth = 0; + element_.smooth = 0.01; element_.color = vec4(1, 1, 1, 1); } override void FinalizeOperation(ref in ParametersBlock params) { diff --git a/sjplayer/standalone/main.d b/sjplayer/standalone/main.d index 293e496..407549c 100644 --- a/sjplayer/standalone/main.d +++ b/sjplayer/standalone/main.d @@ -7,6 +7,8 @@ import derelict.sfml2.audio, import gl4d; +import sjplayer; + int main(string[] args) { (args.length == 4).enforce; const music_file = args[1]; @@ -20,28 +22,10 @@ int main(string[] args) { scope(exit) sfMusic_destroy(music); sfMusic_play(music); - import sjplayer.ElementProgramSet; auto programs = new ElementProgramSet; scope(exit) programs.destroy(); - import sjplayer.CircleElement; - auto element = new CircleElement; - scope(exit) element.destroy(); - auto drawer = new CircleElementDrawer(programs.Get!CircleElementProgram, [element]); - scope(exit) drawer.destroy(); - - with (element) { - alive = true; - - matrix = mat3.identity; - matrix.scale(0.5, 0.5, 0.5); - matrix.translate(0.1, 0, 0); - matrix.transpose(); - - weight = 1; - smooth = 0.01; - color = vec4(1, 1, 1, 1); - } + auto context = script_file.readText.CreateContextFromText(programs); while (true) { sfEvent e; @@ -50,8 +34,11 @@ int main(string[] args) { const msecs = sfMusic_getPlayingOffset(music).microseconds * 1e-6f; const beat = msecs/60f * bpm; - drawer.Draw(); + context.OperateScheduledControllers(beat); + + gl.Clear(GL_COLOR_BUFFER_BIT); + context.DrawElements(); sfWindow_display(win); } return 0;