- [NEW] exit()
- [NEW] anykey() - [NEW] ismusicplaying()
This commit is contained in:
19
lua.cpp
19
lua.cpp
@@ -450,6 +450,11 @@ extern "C" {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int cpp_anykey(lua_State *L) {
|
||||||
|
lua_pushboolean(L, anykey());
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
static int cpp_mousex(lua_State *L) {
|
static int cpp_mousex(lua_State *L) {
|
||||||
lua_pushinteger(L, mousex());
|
lua_pushinteger(L, mousex());
|
||||||
return 1;
|
return 1;
|
||||||
@@ -666,6 +671,16 @@ extern "C" {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int cpp_ismusicplaying(lua_State *L) {
|
||||||
|
lua_pushboolean(L,ismusicplaying());
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int cpp_exit(lua_State *L) {
|
||||||
|
exit();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
lua_State *L;
|
lua_State *L;
|
||||||
@@ -722,6 +737,7 @@ void push_lua_funcs() {
|
|||||||
lua_pushcfunction(L,cpp_map); lua_setglobal(L, "map");
|
lua_pushcfunction(L,cpp_map); lua_setglobal(L, "map");
|
||||||
lua_pushcfunction(L,cpp_btn); lua_setglobal(L, "btn");
|
lua_pushcfunction(L,cpp_btn); lua_setglobal(L, "btn");
|
||||||
lua_pushcfunction(L,cpp_btnp); lua_setglobal(L, "btnp");
|
lua_pushcfunction(L,cpp_btnp); lua_setglobal(L, "btnp");
|
||||||
|
lua_pushcfunction(L,cpp_anykey); lua_setglobal(L, "anykey");
|
||||||
lua_pushcfunction(L,cpp_mousex); lua_setglobal(L, "mousex");
|
lua_pushcfunction(L,cpp_mousex); lua_setglobal(L, "mousex");
|
||||||
lua_pushcfunction(L,cpp_mousey); lua_setglobal(L, "mousey");
|
lua_pushcfunction(L,cpp_mousey); lua_setglobal(L, "mousey");
|
||||||
lua_pushcfunction(L,cpp_mwheel); lua_setglobal(L, "mwheel");
|
lua_pushcfunction(L,cpp_mwheel); lua_setglobal(L, "mwheel");
|
||||||
@@ -765,6 +781,9 @@ void push_lua_funcs() {
|
|||||||
lua_pushcfunction(L,cpp_pausemusic); lua_setglobal(L, "pausemusic");
|
lua_pushcfunction(L,cpp_pausemusic); lua_setglobal(L, "pausemusic");
|
||||||
lua_pushcfunction(L,cpp_resumemusic); lua_setglobal(L, "resumemusic");
|
lua_pushcfunction(L,cpp_resumemusic); lua_setglobal(L, "resumemusic");
|
||||||
lua_pushcfunction(L,cpp_stopmusic); lua_setglobal(L, "stopmusic");
|
lua_pushcfunction(L,cpp_stopmusic); lua_setglobal(L, "stopmusic");
|
||||||
|
lua_pushcfunction(L,cpp_ismusicplaying); lua_setglobal(L, "ismusicplaying");
|
||||||
|
|
||||||
|
lua_pushcfunction(L,cpp_exit); lua_setglobal(L, "exit");
|
||||||
|
|
||||||
lua_pushinteger(L, 0); lua_setglobal(L, "KEY_UNKNOWN");
|
lua_pushinteger(L, 0); lua_setglobal(L, "KEY_UNKNOWN");
|
||||||
lua_pushinteger(L, 4); lua_setglobal(L, "KEY_A");
|
lua_pushinteger(L, 4); lua_setglobal(L, "KEY_A");
|
||||||
|
|||||||
19
mini.cpp
19
mini.cpp
@@ -50,6 +50,7 @@ namespace ds {
|
|||||||
bool fill_trans = false;
|
bool fill_trans = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool should_exit = false;
|
||||||
SDL_Window *mini_win;
|
SDL_Window *mini_win;
|
||||||
SDL_Renderer *mini_ren;
|
SDL_Renderer *mini_ren;
|
||||||
SDL_Texture *mini_bak;
|
SDL_Texture *mini_bak;
|
||||||
@@ -236,7 +237,7 @@ int main(int argc,char*argv[]){
|
|||||||
SDL_RenderSetLogicalSize(mini_ren, screen_width, screen_height);
|
SDL_RenderSetLogicalSize(mini_ren, screen_width, screen_height);
|
||||||
SDL_ShowCursor(show_cursor);
|
SDL_ShowCursor(show_cursor);
|
||||||
mini_bak = SDL_CreateTexture(mini_ren, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, screen_width, screen_height);
|
mini_bak = SDL_CreateTexture(mini_ren, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, screen_width, screen_height);
|
||||||
bool exit = false;
|
|
||||||
SDL_Event mini_eve;
|
SDL_Event mini_eve;
|
||||||
|
|
||||||
reinit();
|
reinit();
|
||||||
@@ -245,11 +246,11 @@ int main(int argc,char*argv[]){
|
|||||||
lua_init(lua_files);
|
lua_init(lua_files);
|
||||||
lua_call_init();
|
lua_call_init();
|
||||||
|
|
||||||
while(!exit) {
|
while(!should_exit) {
|
||||||
key_just_pressed = 0;
|
key_just_pressed = 0;
|
||||||
mouse_wheel = 0;
|
mouse_wheel = 0;
|
||||||
while(SDL_PollEvent(&mini_eve)) {
|
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.type == SDL_KEYDOWN) {
|
||||||
if (mini_eve.key.keysym.scancode == SDL_SCANCODE_ESCAPE) {
|
if (mini_eve.key.keysym.scancode == SDL_SCANCODE_ESCAPE) {
|
||||||
if (lua_is_playing()) {
|
if (lua_is_playing()) {
|
||||||
@@ -794,6 +795,10 @@ bool btnp(uint8_t i) {
|
|||||||
return key_just_pressed == i;
|
return key_just_pressed == i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool anykey() {
|
||||||
|
return key_just_pressed != 0;
|
||||||
|
}
|
||||||
|
|
||||||
int mousex() {
|
int mousex() {
|
||||||
return mouse_x;
|
return mouse_x;
|
||||||
}
|
}
|
||||||
@@ -998,3 +1003,11 @@ void resumemusic() {
|
|||||||
void stopmusic() {
|
void stopmusic() {
|
||||||
JA_StopMusic();
|
JA_StopMusic();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ismusicplaying() {
|
||||||
|
return JA_GetMusicState() == JA_MUSIC_PLAYING;
|
||||||
|
}
|
||||||
|
|
||||||
|
void exit() {
|
||||||
|
should_exit = true;
|
||||||
|
}
|
||||||
|
|||||||
4
mini.h
4
mini.h
@@ -196,6 +196,7 @@ void map(int celx, int cely, int sx, int sy, uint8_t celw, uint8_t celh, uint8_t
|
|||||||
|
|
||||||
bool btn(uint8_t i);
|
bool btn(uint8_t i);
|
||||||
bool btnp(uint8_t i);
|
bool btnp(uint8_t i);
|
||||||
|
bool anykey();
|
||||||
|
|
||||||
int mousex();
|
int mousex();
|
||||||
int mousey();
|
int mousey();
|
||||||
@@ -253,3 +254,6 @@ void playmusic(const char *filename, const bool loop = true);
|
|||||||
void pausemusic();
|
void pausemusic();
|
||||||
void resumemusic();
|
void resumemusic();
|
||||||
void stopmusic();
|
void stopmusic();
|
||||||
|
bool ismusicplaying();
|
||||||
|
|
||||||
|
void exit();
|
||||||
|
|||||||
Reference in New Issue
Block a user