[update] Allowed the standalone version of sjplayer
to load a script file.
This commit is contained in:
parent
f35bd8cef6
commit
a85dcb8f3e
@ -152,7 +152,7 @@ class CircleElementProgram {
|
|||||||
float r = length(uv_);
|
float r = length(uv_);
|
||||||
float w = 1 - weight_;
|
float w = 1 - weight_;
|
||||||
return
|
return
|
||||||
smoothstep(w, w+smooth_, r) *
|
smoothstep(w-smooth_, w, r) *
|
||||||
(1 - smoothstep(1-smooth_, 1, r));
|
(1 - smoothstep(1-smooth_, 1, r));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,9 +28,9 @@ class CircleElementScheduledController :
|
|||||||
element_.alive = true;
|
element_.alive = true;
|
||||||
element_.damage = 0;
|
element_.damage = 0;
|
||||||
element_.nearness_coe = 0;
|
element_.nearness_coe = 0;
|
||||||
element_.matrix = mat3.identity;
|
element_.matrix = mat3.identity.transposed;
|
||||||
element_.weight = 1;
|
element_.weight = 1;
|
||||||
element_.smooth = 0;
|
element_.smooth = 0.01;
|
||||||
element_.color = vec4(1, 1, 1, 1);
|
element_.color = vec4(1, 1, 1, 1);
|
||||||
}
|
}
|
||||||
override void FinalizeOperation(ref in ParametersBlock params) {
|
override void FinalizeOperation(ref in ParametersBlock params) {
|
||||||
|
@ -7,6 +7,8 @@ import derelict.sfml2.audio,
|
|||||||
|
|
||||||
import gl4d;
|
import gl4d;
|
||||||
|
|
||||||
|
import sjplayer;
|
||||||
|
|
||||||
int main(string[] args) {
|
int main(string[] args) {
|
||||||
(args.length == 4).enforce;
|
(args.length == 4).enforce;
|
||||||
const music_file = args[1];
|
const music_file = args[1];
|
||||||
@ -20,28 +22,10 @@ int main(string[] args) {
|
|||||||
scope(exit) sfMusic_destroy(music);
|
scope(exit) sfMusic_destroy(music);
|
||||||
sfMusic_play(music);
|
sfMusic_play(music);
|
||||||
|
|
||||||
import sjplayer.ElementProgramSet;
|
|
||||||
auto programs = new ElementProgramSet;
|
auto programs = new ElementProgramSet;
|
||||||
scope(exit) programs.destroy();
|
scope(exit) programs.destroy();
|
||||||
|
|
||||||
import sjplayer.CircleElement;
|
auto context = script_file.readText.CreateContextFromText(programs);
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
sfEvent e;
|
sfEvent e;
|
||||||
@ -50,8 +34,11 @@ int main(string[] args) {
|
|||||||
|
|
||||||
const msecs = sfMusic_getPlayingOffset(music).microseconds * 1e-6f;
|
const msecs = sfMusic_getPlayingOffset(music).microseconds * 1e-6f;
|
||||||
const beat = msecs/60f * bpm;
|
const beat = msecs/60f * bpm;
|
||||||
drawer.Draw();
|
|
||||||
|
|
||||||
|
context.OperateScheduledControllers(beat);
|
||||||
|
|
||||||
|
gl.Clear(GL_COLOR_BUFFER_BIT);
|
||||||
|
context.DrawElements();
|
||||||
sfWindow_display(win);
|
sfWindow_display(win);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
Reference in New Issue
Block a user