Skip to content

Commit a535ac6

Browse files
committed
Custom scene cycling
Signed-off-by: Joachim Wiberg <[email protected]>
1 parent 282f1ee commit a535ac6

File tree

2 files changed

+47
-12
lines changed

2 files changed

+47
-12
lines changed

README.md

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,29 @@ The build system will automatically detect and embed the music file.
4444
make run
4545
```
4646

47-
Or run a specific scene:
47+
### Command-Line Options
4848

4949
```
50-
./demo 2 # Run only the cube scene
51-
./demo 4 # Run only the bouncing logo scene
50+
Usage: ./demo [OPTIONS] [SCENE...]
51+
52+
Options:
53+
-h, --help Show help message
54+
-d, --duration SEC Set scene duration in seconds (default: 15)
55+
56+
Scenes:
57+
0 - Starfield
58+
1 - Plasma
59+
2 - Cube
60+
3 - Tunnel
61+
4 - Bouncing Logo (hidden - manual only)
62+
5 - Raining Logo
63+
64+
Examples:
65+
./demo # Auto-cycle through scenes 0-3 and 5
66+
./demo 2 # Show only cube scene
67+
./demo 1 3 5 # Cycle between plasma, tunnel, and raining logo
68+
./demo -d 30 # Auto-cycle with 30 second scenes
69+
./demo -d 10 2 5 # Cycle cube and raining logo, 10 sec each
5270
```
5371

5472
## Distribution

demo.c

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ typedef struct {
5959
SDL_Surface *logo_surface;
6060
SDL_Texture *logo_texture;
6161
int current_scene;
62+
int current_scene_index; /* Index into scene_list */
6263
int fixed_scene;
6364
float time;
6465
float global_time;
@@ -67,6 +68,8 @@ typedef struct {
6768
ScrollStyle scroll_style;
6869
Star stars[NUM_STARS];
6970
Uint32 scene_duration; /* Milliseconds per scene */
71+
int scene_list[6]; /* Custom scene order */
72+
int num_scenes; /* Number of scenes in list */
7073
} DemoContext;
7174

7275
/* Plasma effect - optimized with lower resolution and LUT */
@@ -851,6 +854,7 @@ int main(int argc, char *argv[])
851854

852855
DemoContext ctx = {0};
853856
ctx.fixed_scene = -1; /* -1 means auto-switch scenes */
857+
ctx.current_scene_index = 0;
854858
int scene_list[6];
855859
int num_scenes = 0;
856860

@@ -922,12 +926,25 @@ int main(int argc, char *argv[])
922926
/* Single scene - fix to that scene */
923927
ctx.fixed_scene = scene_list[0];
924928
ctx.current_scene = scene_list[0];
929+
ctx.num_scenes = 0; /* Fixed scene, no list */
925930
} else if (num_scenes > 1) {
926-
/* Multiple scenes specified - use first as starting point */
927-
ctx.current_scene = scene_list[0];
928-
/* TODO: Implement custom scene cycling through scene_list */
929-
fprintf(stderr, "Note: Multiple scene cycling not yet implemented, using first scene only\n");
930-
ctx.fixed_scene = scene_list[0];
931+
/* Multiple scenes specified - cycle through custom list */
932+
for (int i = 0; i < num_scenes; i++) {
933+
ctx.scene_list[i] = scene_list[i];
934+
}
935+
ctx.num_scenes = num_scenes;
936+
ctx.current_scene_index = 0;
937+
ctx.current_scene = ctx.scene_list[0];
938+
} else {
939+
/* No scenes specified - use default list (skip scene 4) */
940+
ctx.scene_list[0] = 0;
941+
ctx.scene_list[1] = 1;
942+
ctx.scene_list[2] = 2;
943+
ctx.scene_list[3] = 3;
944+
ctx.scene_list[4] = 5;
945+
ctx.num_scenes = 5;
946+
ctx.current_scene_index = 0;
947+
ctx.current_scene = ctx.scene_list[0];
931948
}
932949

933950
ctx.window = SDL_CreateWindow("Infix Container Demo",
@@ -1089,10 +1106,10 @@ int main(int argc, char *argv[])
10891106
} else if (fade_progress < 2.0f) {
10901107
/* Switch scene and fade in */
10911108
if (ctx.fade_alpha < 0.5f) {
1092-
/* Skip scene 4 (bouncing logo - hidden scene) */
1093-
ctx.current_scene = (ctx.current_scene + 1) % 6;
1094-
if (ctx.current_scene == 4) {
1095-
ctx.current_scene = 5; /* Jump to raining logo instead */
1109+
/* Advance to next scene in the list */
1110+
if (ctx.num_scenes > 0) {
1111+
ctx.current_scene_index = (ctx.current_scene_index + 1) % ctx.num_scenes;
1112+
ctx.current_scene = ctx.scene_list[ctx.current_scene_index];
10961113
}
10971114
scene_start = current_time - (Uint32)fade_duration;
10981115
ctx.time = 0;

0 commit comments

Comments
 (0)