Skip to content

Instantly share code, notes, and snippets.

@msg555
Last active October 12, 2017 17:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save msg555/3aaa96428d964c1612b540c208c3ad1e to your computer and use it in GitHub Desktop.
Save msg555/3aaa96428d964c1612b540c208c3ad1e to your computer and use it in GitHub Desktop.
An example of how to embed, build, and use custom sprites with dustscripts.
const string EMBED_test1 = "test1.png";
const string EMBED_test2 = "test2.png";
class script {
int frame_count;
sprites@ spr;
script() {
frame_count = 0;
@spr = create_sprites();
}
void build_sprites(message@ msg) {
msg.set_string("image1", "test1");
msg.set_int("image1|offsetx", 103);
msg.set_int("image1|offsety", 129);
msg.set_string("image2", "test2");
}
void on_level_start() {
spr.add_sprite_set("script");
}
void step(int) {
frame_count++;
}
void draw(float subframe) {
int frame = 1;
int palette = 1;
int colour = 0xFFFFFFFF;
int rotation = frame_count % 360;
spr.draw_hud(10, 10, "image1", frame, palette, 0, 0,
frame_count, 1, 1, colour);
spr.draw_hud(20, 10, "image2", frame, palette, 200, 0,
frame_count, 1, 1, colour);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment