-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcarioca.cpp
More file actions
60 lines (50 loc) · 1.5 KB
/
carioca.cpp
File metadata and controls
60 lines (50 loc) · 1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/*
Carioca dancing
Coloque qualquer música e veja como qualquer música combina com o vídeo
Carioca dancing
Play any song and see how it matches the video
by Francisco Passos (Frank Steps)
*/
#include <iostream>
#include <string>
#include <vector>
namespace ray{
#include <raylib.h>
}
int main(int argc, char* argv[]) {
ray::InitWindow(224, 224, "Carioca dancing");
ray::InitAudioDevice();
const int frame_count = 2325;
std::vector<ray::Texture> frames(frame_count);
for (int i = 0; i < frame_count; i++) {
frames[i] = ray::LoadTexture(("dancing/carioca_" + std::to_string(i) + ".png").c_str());
}
ray::Sound sound;
if (argc > 1) {
sound = ray::LoadSound(argv[1]);
ray::PlaySound(sound);
} else {
return EXIT_FAILURE;
}
int current_frame = 0;
float frame_timer = 0.0f;
const float frame_duration = 1.0f / 60.0f;;
while (!ray::WindowShouldClose()) {
frame_timer += ray::GetFrameTime();
if (frame_timer >= frame_duration) {
current_frame = (current_frame + 1) % frame_count;
frame_timer = 0.0f;
}
ray::BeginDrawing();
ray::ClearBackground(ray::RAYWHITE);
ray::DrawTexture(frames[current_frame], 0, 0, ray::WHITE);
ray::EndDrawing();
}
for(int i = 0; i < frame_count; i++){
ray::UnloadTexture(frames[i]);
}
ray::UnloadSound(sound);
ray::CloseAudioDevice();
ray::CloseWindow();
return EXIT_SUCCESS;
}