Last active
October 12, 2017 17:23
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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