File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -21,24 +21,38 @@ Angle degrees(float a)
2121 return r ;
2222};
2323
24+ /// @brief Time in the number of samples.
2425AudioTime samples (int32_t s )
2526{
2627 struct AudioTime t = {s };
2728 return t ;
2829}
2930
31+ /// @brief Time in seconds.
3032AudioTime seconds (int32_t s )
3133{
3234 struct AudioTime t = {s * SAMPLE_RATE };
3335 return t ;
3436}
3537
38+ /// @brief Time in miliseconds.
3639AudioTime miliseconds (int32_t s )
3740{
3841 struct AudioTime t = {s * SAMPLE_RATE / 1000 };
3942 return t ;
4043}
4144
45+ /// @brief Convert Pad to DPad.
46+ DPad pad_to_dpad (Pad pad )
47+ {
48+ DPad dpad = {
49+ .left = pad .x <= -100 ,
50+ .right = pad .x >= 100 ,
51+ .up = pad .y <= -100 ,
52+ .down = pad .y >= 100 };
53+ return dpad ;
54+ }
55+
4256// -- GRAPHICS -- //
4357
4458/// @brief Fill the whole frame with the given color.
Original file line number Diff line number Diff line change @@ -174,6 +174,20 @@ struct Pad
174174};
175175typedef struct Pad Pad ;
176176
177+ /// @brief A classic 4-button representation of the Pad.
178+ struct DPad
179+ {
180+ /// @brief If the left segment of the Pad is pressed.
181+ bool left ;
182+ /// @brief If the right segment of the Pad is pressed.
183+ bool right ;
184+ /// @brief If the upper segment of the Pad is pressed.
185+ bool up ;
186+ /// @brief If the lower segment of the Pad is pressed.
187+ bool down ;
188+ };
189+ typedef struct DPad DPad ;
190+
177191/// @brief State of the buttons. True is pressed, false is released.
178192struct Buttons
179193{
@@ -316,6 +330,7 @@ Angle degrees(float a);
316330AudioTime samples (int32_t s );
317331AudioTime seconds (int32_t s );
318332AudioTime miliseconds (int32_t s );
333+ DPad pad_to_dpad (Pad pad );
319334
320335void clear_screen (Color c );
321336void set_color (Color c , RGB v );
You can’t perform that action at this time.
0 commit comments