falling.webm
[Hide] (1MB, 1270x790, 00:37) Yesterday I was so tired that I went to sleep 3 hours earlier than usual, but I did manage to simplify my cutscene code a LOT. Now it's just a switch statement that spawns particles, something like this:
void game (void) {
switch (game_state) {
case GAME_STATE_INIT: {
...
}
case GAME_STATE_CUTSCENE: {
static int event = 0;
static int event_time_left = 0;
event_time_left -= time.delta_ms;
if (event_time_left <= 0) {
switch (event) {
case 0: {
play_sound(bg_music, ...);
spawn_particle(player_walking, ...);
event_time_left += 2000;
break;
}
case 1: {
spawn_particle(mining_screenshot, ...);
event_time_left += 2000;
break;
}
case 2: {
kill_all_particles();
game_state = GAME_STATE_MAINGAME;
break;
}
}
event ++;
}
break;
}
case GAME_STATE_MAINGAME: {
...
}
}
}
I've also redone the particle code twice because thinking about the cutscene caused me set them up all wrong. Previously particles had start and end values for all the animated properties because that's how it made sense for the cutscene. Now I'm using a start position and change speed, but I have helper macros that can take start and end values and translate that into a change speed based on the particle's lifetime. It's much easier to create particles too:
// Before:
tmfarr_append(&particles, &((Particle){.sprite=&sprite_cs_mining, .lifetime=2000, .from={.pos=vec2f(700,100), .scale=1, .color=vec4f(1,1,1,2)}, .to={.pos=vec2f(500,100), .scale=1, .color=vec4f(1,1,1,0), .rotate=15.0/180.0}}));
// After:
{ pa_start(sprite_cs_mining, 2000, 700,100) pa_moveto(500,100) pa_fadefromto(2, 0) pa_rotateto(15.0) pa_end() }
Today I was mostly implementing entities and the main gameplay logic. Now I just need to come up with a bunch of obstacles and collectables, but I can't actually think of what to add. What things make anon happy?