- [NEW] exit()

- [NEW] anykey()
- [NEW] ismusicplaying()
This commit is contained in:
2022-10-13 18:40:41 +02:00
parent d4ad849add
commit f1c87e4d25
3 changed files with 39 additions and 3 deletions

View File

@@ -50,6 +50,7 @@ namespace ds {
bool fill_trans = false;
}
bool should_exit = false;
SDL_Window *mini_win;
SDL_Renderer *mini_ren;
SDL_Texture *mini_bak;
@@ -236,7 +237,7 @@ int main(int argc,char*argv[]){
SDL_RenderSetLogicalSize(mini_ren, screen_width, screen_height);
SDL_ShowCursor(show_cursor);
mini_bak = SDL_CreateTexture(mini_ren, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, screen_width, screen_height);
bool exit = false;
SDL_Event mini_eve;
reinit();
@@ -245,11 +246,11 @@ int main(int argc,char*argv[]){
lua_init(lua_files);
lua_call_init();
while(!exit) {
while(!should_exit) {
key_just_pressed = 0;
mouse_wheel = 0;
while(SDL_PollEvent(&mini_eve)) {
if (mini_eve.type == SDL_QUIT) { exit=true; break; }
if (mini_eve.type == SDL_QUIT) { should_exit=true; break; }
if (mini_eve.type == SDL_KEYDOWN) {
if (mini_eve.key.keysym.scancode == SDL_SCANCODE_ESCAPE) {
if (lua_is_playing()) {
@@ -794,6 +795,10 @@ bool btnp(uint8_t i) {
return key_just_pressed == i;
}
bool anykey() {
return key_just_pressed != 0;
}
int mousex() {
return mouse_x;
}
@@ -998,3 +1003,11 @@ void resumemusic() {
void stopmusic() {
JA_StopMusic();
}
bool ismusicplaying() {
return JA_GetMusicState() == JA_MUSIC_PLAYING;
}
void exit() {
should_exit = true;
}