Add cool record spin feature
This commit is contained in:
parent
4e3f3e1325
commit
d05147fa69
174
src/main.cpp
174
src/main.cpp
|
@ -20,11 +20,11 @@
|
||||||
|
|
||||||
#include "stdio.h"
|
#include "stdio.h"
|
||||||
|
|
||||||
|
#include <curl/curl.h>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <sdbus-c++/sdbus-c++.h>
|
#include <sdbus-c++/sdbus-c++.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <curl/curl.h>
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#include "testc.h"
|
#include "testc.h"
|
||||||
}
|
}
|
||||||
|
@ -126,9 +126,9 @@ std::vector<std::string> GetMprisServices() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawPlay(Vector2 Pos, float scale, Color color) {
|
void DrawPlay(Vector2 Pos, float scale, Color color) {
|
||||||
Vector2 backtop = (Vector2) { .x=-0.29f, .y=-0.40f };
|
Vector2 backtop = (Vector2){.x = -0.29f, .y = -0.40f};
|
||||||
Vector2 backbot = (Vector2) { .x=-0.29f, .y=0.40f};
|
Vector2 backbot = (Vector2){.x = -0.29f, .y = 0.40f};
|
||||||
Vector2 front = (Vector2) {.x = 0.5f, .y=0};
|
Vector2 front = (Vector2){.x = 0.5f, .y = 0};
|
||||||
|
|
||||||
backtop = Vector2Scale(backtop, scale);
|
backtop = Vector2Scale(backtop, scale);
|
||||||
backbot = Vector2Scale(backbot, scale);
|
backbot = Vector2Scale(backbot, scale);
|
||||||
|
@ -142,9 +142,9 @@ void DrawPlay(Vector2 Pos, float scale, Color color) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawNext(Vector2 Pos, float scale, Color color) {
|
void DrawNext(Vector2 Pos, float scale, Color color) {
|
||||||
Vector2 backtop = (Vector2) { .x=-0.35f, .y=-0.35f };
|
Vector2 backtop = (Vector2){.x = -0.35f, .y = -0.35f};
|
||||||
Vector2 backbot = (Vector2) { .x=-0.35f, .y=0.35f};
|
Vector2 backbot = (Vector2){.x = -0.35f, .y = 0.35f};
|
||||||
Vector2 front = (Vector2) {.x = 0.28f, .y=0};
|
Vector2 front = (Vector2){.x = 0.28f, .y = 0};
|
||||||
|
|
||||||
backtop = Vector2Scale(backtop, scale);
|
backtop = Vector2Scale(backtop, scale);
|
||||||
backbot = Vector2Scale(backbot, scale);
|
backbot = Vector2Scale(backbot, scale);
|
||||||
|
@ -156,26 +156,22 @@ void DrawNext(Vector2 Pos, float scale, Color color) {
|
||||||
|
|
||||||
DrawTriangle(backtop, backbot, front, color);
|
DrawTriangle(backtop, backbot, front, color);
|
||||||
|
|
||||||
Vector2 topleft = (Vector2) {.x = -0.29f, .y = -0.4f };
|
Vector2 topleft = (Vector2){.x = -0.29f, .y = -0.4f};
|
||||||
|
|
||||||
|
Vector2 bar2topleft = Vector2Add(topleft, (Vector2){0.706f * 0.6f, .y = 0});
|
||||||
|
|
||||||
Vector2 bar2topleft = Vector2Add(topleft, (Vector2) {0.706f*0.6f, .y=0});
|
|
||||||
bar2topleft = Vector2Scale(bar2topleft, scale);
|
bar2topleft = Vector2Scale(bar2topleft, scale);
|
||||||
bar2topleft = Vector2Add(bar2topleft, Pos);
|
bar2topleft = Vector2Add(bar2topleft, Pos);
|
||||||
|
|
||||||
Vector2 size = (Vector2) {.x=0.706f *0.2f, .y = 0.8f };
|
Vector2 size = (Vector2){.x = 0.706f * 0.2f, .y = 0.8f};
|
||||||
size = Vector2Scale(size, scale);
|
size = Vector2Scale(size, scale);
|
||||||
|
|
||||||
|
|
||||||
DrawRectangleV(bar2topleft, size, color);
|
DrawRectangleV(bar2topleft, size, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void DrawBack(Vector2 Pos, float scale, Color color) {
|
void DrawBack(Vector2 Pos, float scale, Color color) {
|
||||||
Vector2 backtop = (Vector2) { .x=0.35f, .y=-0.35f };
|
Vector2 backtop = (Vector2){.x = 0.35f, .y = -0.35f};
|
||||||
Vector2 backbot = (Vector2) { .x=0.35f, .y=0.35f};
|
Vector2 backbot = (Vector2){.x = 0.35f, .y = 0.35f};
|
||||||
Vector2 front = (Vector2) {.x = -0.28f, .y=0};
|
Vector2 front = (Vector2){.x = -0.28f, .y = 0};
|
||||||
|
|
||||||
backtop = Vector2Scale(backtop, scale);
|
backtop = Vector2Scale(backtop, scale);
|
||||||
backbot = Vector2Scale(backbot, scale);
|
backbot = Vector2Scale(backbot, scale);
|
||||||
|
@ -185,27 +181,25 @@ void DrawBack(Vector2 Pos, float scale, Color color) {
|
||||||
backbot = Vector2Add(backbot, Pos);
|
backbot = Vector2Add(backbot, Pos);
|
||||||
front = Vector2Add(front, Pos);
|
front = Vector2Add(front, Pos);
|
||||||
|
|
||||||
//DrawTriangle(backtop, backbot, front, color);
|
// DrawTriangle(backtop, backbot, front, color);
|
||||||
DrawTriangle(front, backbot, backtop, color);
|
DrawTriangle(front, backbot, backtop, color);
|
||||||
|
|
||||||
Vector2 topleft = (Vector2) {.x = -0.29f, .y = -0.4f };
|
Vector2 topleft = (Vector2){.x = -0.29f, .y = -0.4f};
|
||||||
|
|
||||||
|
|
||||||
Vector2 bar1topleft = Vector2Scale(topleft, scale);
|
Vector2 bar1topleft = Vector2Scale(topleft, scale);
|
||||||
bar1topleft = Vector2Add(bar1topleft, Pos);
|
bar1topleft = Vector2Add(bar1topleft, Pos);
|
||||||
|
|
||||||
Vector2 size = (Vector2) {.x=0.706f *0.2f, .y = 0.8f };
|
Vector2 size = (Vector2){.x = 0.706f * 0.2f, .y = 0.8f};
|
||||||
size = Vector2Scale(size, scale);
|
size = Vector2Scale(size, scale);
|
||||||
|
|
||||||
|
|
||||||
DrawRectangleV(bar1topleft, size, color);
|
DrawRectangleV(bar1topleft, size, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawStop(Vector2 Pos, float scale, Color color) {
|
void DrawStop(Vector2 Pos, float scale, Color color) {
|
||||||
Vector2 topleft = (Vector2) {.x = -0.353f, .y = -0.353f };
|
Vector2 topleft = (Vector2){.x = -0.353f, .y = -0.353f};
|
||||||
Vector2 botright = (Vector2) {.x = 0.353f, .y = 0.353f };
|
Vector2 botright = (Vector2){.x = 0.353f, .y = 0.353f};
|
||||||
topleft = Vector2Scale(topleft, scale);
|
topleft = Vector2Scale(topleft, scale);
|
||||||
botright = Vector2Scale(botright, scale*2);
|
botright = Vector2Scale(botright, scale * 2);
|
||||||
|
|
||||||
topleft = Vector2Add(topleft, Pos);
|
topleft = Vector2Add(topleft, Pos);
|
||||||
|
|
||||||
|
@ -213,17 +207,16 @@ void DrawStop(Vector2 Pos, float scale, Color color) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawPause(Vector2 Pos, float scale, Color color) {
|
void DrawPause(Vector2 Pos, float scale, Color color) {
|
||||||
Vector2 topleft = (Vector2) {.x = -0.353f, .y = -0.353f };
|
Vector2 topleft = (Vector2){.x = -0.353f, .y = -0.353f};
|
||||||
|
|
||||||
|
|
||||||
Vector2 bar1topleft = Vector2Scale(topleft, scale);
|
Vector2 bar1topleft = Vector2Scale(topleft, scale);
|
||||||
bar1topleft = Vector2Add(bar1topleft, Pos);
|
bar1topleft = Vector2Add(bar1topleft, Pos);
|
||||||
|
|
||||||
Vector2 bar2topleft = Vector2Add(topleft, (Vector2) {0.706f*0.6f, .y=0});
|
Vector2 bar2topleft = Vector2Add(topleft, (Vector2){0.706f * 0.6f, .y = 0});
|
||||||
bar2topleft = Vector2Scale(bar2topleft, scale);
|
bar2topleft = Vector2Scale(bar2topleft, scale);
|
||||||
bar2topleft = Vector2Add(bar2topleft, Pos);
|
bar2topleft = Vector2Add(bar2topleft, Pos);
|
||||||
|
|
||||||
Vector2 size = (Vector2) {.x=0.706f *0.4f, .y = 0.706f };
|
Vector2 size = (Vector2){.x = 0.706f * 0.4f, .y = 0.706f};
|
||||||
size = Vector2Scale(size, scale);
|
size = Vector2Scale(size, scale);
|
||||||
|
|
||||||
topleft = Vector2Add(topleft, Pos);
|
topleft = Vector2Add(topleft, Pos);
|
||||||
|
@ -233,9 +226,19 @@ void DrawPause(Vector2 Pos, float scale, Color color) {
|
||||||
}
|
}
|
||||||
|
|
||||||
float ScaleToFit(Vector2 src, Vector2 dst) {
|
float ScaleToFit(Vector2 src, Vector2 dst) {
|
||||||
float ratio = std::min(dst.x/src.x, dst.y/src.y);
|
float ratio = std::min(dst.x / src.x, dst.y / src.y);
|
||||||
return ratio;
|
return ratio;
|
||||||
//return Vector2Scale(src, ratio);
|
// return Vector2Scale(src, ratio);
|
||||||
|
}
|
||||||
|
|
||||||
|
void GenCircleOverlay(RenderTexture tex) {
|
||||||
|
BeginTextureMode(tex);
|
||||||
|
ClearBackground(BLACK);
|
||||||
|
BeginBlendMode(BLEND_SUBTRACT_COLORS);
|
||||||
|
DrawCircle(GetScreenWidth()/2, GetScreenHeight()/2, std::min(GetScreenWidth()/2, GetScreenHeight()/2), (Color{0,0,0,0}));
|
||||||
|
EndBlendMode();
|
||||||
|
EndTextureMode();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
|
@ -265,11 +268,22 @@ int main(int argc, char *argv[]) {
|
||||||
|
|
||||||
auto current_player = MprisPlayer("org.mpris.MediaPlayer2.playerctld");
|
auto current_player = MprisPlayer("org.mpris.MediaPlayer2.playerctld");
|
||||||
double lasttime = 0.0;
|
double lasttime = 0.0;
|
||||||
|
bool discmode = false;
|
||||||
|
DiscObject disc(0);
|
||||||
// Main game loop
|
// Main game loop
|
||||||
while (!WindowShouldClose() &&
|
bool goodstate = false;
|
||||||
run) // Detect window close button or ESC key, or a quit from the menu
|
|
||||||
|
RenderTexture recordoverlay = LoadRenderTexture(screenWidth, screenHeight);
|
||||||
|
GenCircleOverlay(recordoverlay);
|
||||||
|
|
||||||
|
while (!WindowShouldClose() && run) // Detect window close button or ESC key, or a quit from the menu
|
||||||
{
|
{
|
||||||
if (GetTime() > lasttime+3 ) {
|
if (IsWindowResized()) {
|
||||||
|
UnloadRenderTexture(recordoverlay);
|
||||||
|
recordoverlay = LoadRenderTexture(GetScreenWidth(), GetScreenHeight());
|
||||||
|
GenCircleOverlay(recordoverlay);
|
||||||
|
}
|
||||||
|
if (GetTime() > lasttime + 3) {
|
||||||
lasttime = GetTime();
|
lasttime = GetTime();
|
||||||
current_player.Refresh();
|
current_player.Refresh();
|
||||||
}
|
}
|
||||||
|
@ -277,61 +291,88 @@ int main(int argc, char *argv[]) {
|
||||||
BeginDrawing();
|
BeginDrawing();
|
||||||
ClearBackground(BLACK);
|
ClearBackground(BLACK);
|
||||||
|
|
||||||
Vector2 winwidth = (Vector2) {(float) GetScreenWidth(), (float) GetScreenHeight()};
|
Vector2 winwidth = (Vector2){(float)GetScreenWidth(), (float)GetScreenHeight()};
|
||||||
Vector2 imagesize = (Vector2) {(float) current_player.tex.tex.width, (float) current_player.tex.tex.height};
|
Vector2 imagesize = (Vector2){(float)current_player.tex.tex.width, (float)current_player.tex.tex.height};
|
||||||
|
|
||||||
Vector2 scaledsize = Vector2Scale(imagesize, ScaleToFit(imagesize, winwidth));
|
Vector2 scaledsize = Vector2Scale(imagesize, ScaleToFit(imagesize, winwidth));
|
||||||
Vector2 fpos;
|
Vector2 fpos;
|
||||||
fpos.x = (winwidth.x *0.5) - (scaledsize.x * 0.5f);
|
fpos.x = (winwidth.x * 0.5) - (scaledsize.x * 0.5f);
|
||||||
fpos.y = (winwidth.y *0.5) - (scaledsize.y * 0.5f);
|
fpos.y = (winwidth.y * 0.5) - (scaledsize.y * 0.5f);
|
||||||
DrawTextureEx(current_player.tex.tex, fpos, 0, ScaleToFit(imagesize, winwidth), WHITE);
|
// DrawTextureEx(current_player.tex.tex, fpos, 0, ScaleToFit(imagesize, winwidth), WHITE);
|
||||||
|
Rectangle src = (Rectangle){0, 0, (float)current_player.tex.tex.width, (float)current_player.tex.tex.height};
|
||||||
|
Rectangle dst = (Rectangle){fpos.x + scaledsize.x / 2, fpos.y + scaledsize.y / 2, scaledsize.x, scaledsize.y};
|
||||||
|
|
||||||
|
DrawTexturePro(current_player.tex.tex, src, dst, (Vector2){dst.width / 2, dst.height / 2}, disc.pos, WHITE);
|
||||||
|
|
||||||
|
if (IsWindowFocused()) {
|
||||||
if ( IsWindowFocused() ) {
|
|
||||||
const float buttonsize = 0.1;
|
const float buttonsize = 0.1;
|
||||||
Vector2 screen = (Vector2) {(float) GetScreenWidth(), (float) GetScreenHeight()};
|
Vector2 screen = (Vector2){(float)GetScreenWidth(), (float)GetScreenHeight()};
|
||||||
Vector2 centerline;
|
Vector2 centerline;
|
||||||
centerline.x = screen.x / 2;
|
centerline.x = screen.x / 2;
|
||||||
centerline.y = screen.y * 0.8;
|
centerline.y = screen.y * 0.8;
|
||||||
|
|
||||||
Color transblack = BLACK;
|
Color transblack = BLACK;
|
||||||
transblack.a = (200);
|
transblack.a = (200);
|
||||||
DrawCircleV(centerline, 0.05*GetScreenWidth(), transblack);
|
DrawCircleV(centerline, 0.05 * GetScreenWidth(), transblack);
|
||||||
|
|
||||||
if (current_player.playstate == "Playing") {
|
if (current_player.playstate == "Playing") {
|
||||||
DrawPause(centerline, 0.1*GetScreenWidth(), WHITE);
|
DrawPause(centerline, 0.1 * GetScreenWidth(), WHITE);
|
||||||
} else {
|
} else {
|
||||||
DrawPlay(centerline, 0.1*GetScreenWidth(), WHITE);
|
DrawPlay(centerline, 0.1 * GetScreenWidth(), WHITE);
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector2 next = Vector2Add(centerline, (Vector2) {screen.x * 0.2f, 0.0f});
|
Vector2 next = Vector2Add(centerline, (Vector2){screen.x * 0.2f, 0.0f});
|
||||||
DrawCircleV(next, 0.05*GetScreenWidth(), transblack);
|
DrawCircleV(next, 0.05 * GetScreenWidth(), transblack);
|
||||||
DrawNext(next, 0.1*GetScreenWidth(), WHITE);
|
DrawNext(next, 0.1 * GetScreenWidth(), WHITE);
|
||||||
|
|
||||||
Vector2 back = Vector2Add(centerline, (Vector2) {screen.x * -0.2f, 0.0f});
|
Vector2 back = Vector2Add(centerline, (Vector2){screen.x * -0.2f, 0.0f});
|
||||||
DrawCircleV(back, 0.05*GetScreenWidth(), transblack);
|
DrawCircleV(back, 0.05 * GetScreenWidth(), transblack);
|
||||||
DrawBack(back, 0.1*GetScreenWidth(), WHITE);
|
DrawBack(back, 0.1 * GetScreenWidth(), WHITE);
|
||||||
|
|
||||||
if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT) && CheckCollisionPointCircle(GetMousePosition(), centerline, 0.05*GetScreenWidth()) ) {
|
if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT) && CheckCollisionPointCircle(GetMousePosition(), centerline, 0.05 * GetScreenWidth())) {
|
||||||
current_player.PausePlay();
|
current_player.PausePlay();
|
||||||
current_player.playstate = current_player.playstate == "Playing" ? "Paused" : "Playing";
|
current_player.playstate = current_player.playstate == "Playing" ? "Paused" : "Playing";
|
||||||
}
|
} else if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT) && CheckCollisionPointCircle(GetMousePosition(), next, 0.05 * GetScreenWidth())) {
|
||||||
|
|
||||||
if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT) && CheckCollisionPointCircle(GetMousePosition(), next, 0.05*GetScreenWidth()) ) {
|
|
||||||
current_player.Next();
|
current_player.Next();
|
||||||
current_player.playstate = current_player.playstate == "Playing" ? "Paused" : "Playing";
|
current_player.playstate = current_player.playstate == "Playing" ? "Paused" : "Playing";
|
||||||
}
|
} else if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT) && CheckCollisionPointCircle(GetMousePosition(), back, 0.05 * GetScreenWidth())) {
|
||||||
|
|
||||||
if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT) && CheckCollisionPointCircle(GetMousePosition(), back, 0.05*GetScreenWidth()) ) {
|
|
||||||
current_player.Prev();
|
current_player.Prev();
|
||||||
current_player.playstate = current_player.playstate == "Playing" ? "Paused" : "Playing";
|
current_player.playstate = current_player.playstate == "Playing" ? "Paused" : "Playing";
|
||||||
|
} else if (IsMouseButtonDown(MOUSE_BUTTON_LEFT)) {
|
||||||
|
float initmouserot;
|
||||||
|
Vector2 initmousepos;
|
||||||
|
if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT)) {
|
||||||
|
initmouserot = disc.pos;
|
||||||
|
initmousepos = GetMousePosition();
|
||||||
|
initmousepos = Vector2Add(initmousepos, (Vector2){-screen.x / 2, -screen.y / 2});
|
||||||
|
goodstate = true;
|
||||||
|
}
|
||||||
|
if (goodstate) {
|
||||||
|
Vector2 mouse = GetMousePosition();
|
||||||
|
Vector2 mousecentered = Vector2Add(mouse, (Vector2){-screen.x / 2, -screen.y / 2});
|
||||||
|
disc.velo = 0;
|
||||||
|
disc.UpdatePos(initmouserot + (((180.0f * atan2(mousecentered.y, mousecentered.x)) / M_PI) - ((180.0f * atan2(initmousepos.y, initmousepos.x)) / M_PI)), GetFrameTime());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!goodstate) {
|
||||||
|
disc.UpdatePos(GetFrameTime());
|
||||||
|
// Ease from velo to target
|
||||||
|
if (current_player.playstate == "Playing") {
|
||||||
|
disc.target = 100;
|
||||||
|
} else {
|
||||||
|
disc.target = 0;
|
||||||
|
}
|
||||||
|
disc.accel = disc.target - disc.velo;
|
||||||
|
}
|
||||||
|
if (IsMouseButtonReleased(MOUSE_BUTTON_LEFT)) {
|
||||||
|
goodstate = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (disc.active) {
|
||||||
|
DrawTexture(recordoverlay.texture, 0, 0 , WHITE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (IsKeyPressed(KEY_SLASH) || IsMouseButtonPressed(MOUSE_BUTTON_RIGHT)) {
|
if (IsKeyPressed(KEY_SLASH) || IsMouseButtonPressed(MOUSE_BUTTON_RIGHT)) {
|
||||||
showIMgui = !showIMgui;
|
showIMgui = !showIMgui;
|
||||||
}
|
}
|
||||||
|
@ -364,7 +405,9 @@ int main(int argc, char *argv[]) {
|
||||||
if (ImGui::BeginMenu("Window")) {
|
if (ImGui::BeginMenu("Window")) {
|
||||||
if (ImGui::MenuItem("Demo Window", nullptr, showDemoWindow))
|
if (ImGui::MenuItem("Demo Window", nullptr, showDemoWindow))
|
||||||
showDemoWindow = !showDemoWindow;
|
showDemoWindow = !showDemoWindow;
|
||||||
|
if (ImGui::MenuItem("Record Spin !!", nullptr, disc.active)) {
|
||||||
|
disc.Activate();
|
||||||
|
}
|
||||||
ImGui::EndMenu();
|
ImGui::EndMenu();
|
||||||
}
|
}
|
||||||
ImGui::EndMainMenuBar();
|
ImGui::EndMainMenuBar();
|
||||||
|
@ -375,7 +418,6 @@ int main(int argc, char *argv[]) {
|
||||||
if (ImGui::Begin("Player Control")) {
|
if (ImGui::Begin("Player Control")) {
|
||||||
ImGui::Text("%s", current_player.GetIdentity().c_str());
|
ImGui::Text("%s", current_player.GetIdentity().c_str());
|
||||||
|
|
||||||
|
|
||||||
if (ImGui::Button("Prev")) {
|
if (ImGui::Button("Prev")) {
|
||||||
current_player.Prev();
|
current_player.Prev();
|
||||||
}
|
}
|
||||||
|
@ -392,8 +434,12 @@ int main(int argc, char *argv[]) {
|
||||||
current_player.Refresh();
|
current_player.Refresh();
|
||||||
current_player.UpdateTexture();
|
current_player.UpdateTexture();
|
||||||
}
|
}
|
||||||
//rlImGuiImage(¤t_player.tex.tex);
|
|
||||||
rlImGuiImageSize(¤t_player.tex.tex,300,300);
|
// ImGui::SliderFloat("erm", &rotation, -180, 180, "Rotation");
|
||||||
|
// rlImGuiImage(¤t_player.tex.tex);
|
||||||
|
ImGui::Separator();
|
||||||
|
ImGui::LabelText("Disc Info", "P: %f, V: %f, A: %f", disc.pos, disc.velo, disc.accel);
|
||||||
|
rlImGuiImageSize(¤t_player.tex.tex, 300, 300);
|
||||||
}
|
}
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
|
|
||||||
|
|
|
@ -177,6 +177,49 @@ void MprisPlayer::UpdateTexture() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DiscObject::DiscObject(float ia) {
|
||||||
|
pos = 0;
|
||||||
|
prevouspos = 0;
|
||||||
|
velo = 0;
|
||||||
|
accel = 0;
|
||||||
|
target = ia;
|
||||||
|
active = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DiscObject::Activate() {
|
||||||
|
active = !active;
|
||||||
|
pos = 0;
|
||||||
|
prevouspos = 0;
|
||||||
|
velo = 0;
|
||||||
|
accel = 0;
|
||||||
|
target = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void DiscObject::UpdatePos(float dtime) {
|
||||||
|
if (active) {
|
||||||
|
prevouspos = pos;
|
||||||
|
pos = pos + velo * dtime;
|
||||||
|
velo = velo + accel * dtime;
|
||||||
|
accel = target;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DiscObject::UpdatePos(float new_pos, float dtime) {
|
||||||
|
if (active) {
|
||||||
|
prevouspos = pos;
|
||||||
|
pos = new_pos;
|
||||||
|
velo = (pos - prevouspos) / dtime;
|
||||||
|
accel = target;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void DiscObject::AddAccel(float ac) {
|
||||||
|
accel = accel + ac;
|
||||||
|
}
|
||||||
|
|
||||||
RayTexture::RayTexture() {
|
RayTexture::RayTexture() {
|
||||||
auto rtex = LoadRenderTexture(300,300);
|
auto rtex = LoadRenderTexture(300,300);
|
||||||
BeginTextureMode(rtex);
|
BeginTextureMode(rtex);
|
||||||
|
|
|
@ -22,6 +22,22 @@ class RayTexture {
|
||||||
~RayTexture();
|
~RayTexture();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class DiscObject {
|
||||||
|
public:
|
||||||
|
float prevouspos;
|
||||||
|
float pos;
|
||||||
|
float velo;
|
||||||
|
float accel;
|
||||||
|
float target;
|
||||||
|
bool active;
|
||||||
|
DiscObject(float ia);
|
||||||
|
void UpdatePos(float dtime);
|
||||||
|
void UpdatePos(float pos, float dtime);
|
||||||
|
void AddAccel(float ac);
|
||||||
|
void Activate();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
class MprisPlayer {
|
class MprisPlayer {
|
||||||
public:
|
public:
|
||||||
std::unique_ptr<sdbus::IConnection> bus_connection;
|
std::unique_ptr<sdbus::IConnection> bus_connection;
|
||||||
|
|
Loading…
Reference in a new issue