diff --git a/assets/init.lua b/assets/init.lua index 6f6dcd3..b50800b 100644 --- a/assets/init.lua +++ b/assets/init.lua @@ -4,56 +4,56 @@ module('scene') module('locale') -- Default Input bindings. --- if PLATFORM == "psp" then --- inputBind("up", INPUT_ACTION_UP) --- inputBind("down", INPUT_ACTION_DOWN) --- inputBind("left", INPUT_ACTION_LEFT) --- inputBind("right", INPUT_ACTION_RIGHT) --- inputBind("circle", INPUT_ACTION_CANCEL) --- inputBind("cross", INPUT_ACTION_ACCEPT) --- inputBind("select", INPUT_ACTION_RAGEQUIT) --- inputBind("lstick_up", INPUT_ACTION_UP) --- inputBind("lstick_down", INPUT_ACTION_DOWN) --- inputBind("lstick_left", INPUT_ACTION_LEFT) --- inputBind("lstick_right", INPUT_ACTION_RIGHT) +if PLATFORM == "psp" then + inputBind("up", INPUT_ACTION_UP) + inputBind("down", INPUT_ACTION_DOWN) + inputBind("left", INPUT_ACTION_LEFT) + inputBind("right", INPUT_ACTION_RIGHT) + inputBind("circle", INPUT_ACTION_CANCEL) + inputBind("cross", INPUT_ACTION_ACCEPT) + inputBind("select", INPUT_ACTION_RAGEQUIT) + inputBind("lstick_up", INPUT_ACTION_UP) + inputBind("lstick_down", INPUT_ACTION_DOWN) + inputBind("lstick_left", INPUT_ACTION_LEFT) + inputBind("lstick_right", INPUT_ACTION_RIGHT) --- elseif DOLPHIN then --- inputBind("up", INPUT_ACTION_UP) --- inputBind("down", INPUT_ACTION_DOWN) --- inputBind("left", INPUT_ACTION_LEFT) --- inputBind("right", INPUT_ACTION_RIGHT) --- inputBind("b", INPUT_ACTION_CANCEL) --- inputBind("a", INPUT_ACTION_ACCEPT) --- inputBind("z", INPUT_ACTION_RAGEQUIT) --- inputBind("lstick_up", INPUT_ACTION_UP) --- inputBind("lstick_down", INPUT_ACTION_DOWN) --- inputBind("lstick_left", INPUT_ACTION_LEFT) --- inputBind("lstick_right", INPUT_ACTION_RIGHT) +elseif DOLPHIN then + inputBind("up", INPUT_ACTION_UP) + inputBind("down", INPUT_ACTION_DOWN) + inputBind("left", INPUT_ACTION_LEFT) + inputBind("right", INPUT_ACTION_RIGHT) + inputBind("b", INPUT_ACTION_CANCEL) + inputBind("a", INPUT_ACTION_ACCEPT) + inputBind("z", INPUT_ACTION_RAGEQUIT) + inputBind("lstick_up", INPUT_ACTION_UP) + inputBind("lstick_down", INPUT_ACTION_DOWN) + inputBind("lstick_left", INPUT_ACTION_LEFT) + inputBind("lstick_right", INPUT_ACTION_RIGHT) --- else --- if INPUT_KEYBOARD then --- inputBind("w", INPUT_ACTION_UP) --- inputBind("s", INPUT_ACTION_DOWN) --- inputBind("a", INPUT_ACTION_LEFT) --- inputBind("d", INPUT_ACTION_RIGHT) +else + if INPUT_KEYBOARD then + inputBind("w", INPUT_ACTION_UP) + inputBind("s", INPUT_ACTION_DOWN) + inputBind("a", INPUT_ACTION_LEFT) + inputBind("d", INPUT_ACTION_RIGHT) --- inputBind("left", INPUT_ACTION_LEFT) --- inputBind("right", INPUT_ACTION_RIGHT) --- inputBind("up", INPUT_ACTION_UP) --- inputBind("down", INPUT_ACTION_DOWN) + inputBind("left", INPUT_ACTION_LEFT) + inputBind("right", INPUT_ACTION_RIGHT) + inputBind("up", INPUT_ACTION_UP) + inputBind("down", INPUT_ACTION_DOWN) --- inputBind("enter", INPUT_ACTION_ACCEPT) --- inputBind("e", INPUT_ACTION_ACCEPT) + inputBind("enter", INPUT_ACTION_ACCEPT) + inputBind("e", INPUT_ACTION_ACCEPT) --- inputBind("q", INPUT_ACTION_CANCEL) + inputBind("q", INPUT_ACTION_CANCEL) --- inputBind("escape", INPUT_ACTION_RAGEQUIT) --- end + inputBind("escape", INPUT_ACTION_RAGEQUIT) + end --- if INPUT_POINTER then --- inputBind("mouse_x", INPUT_ACTION_POINTERX) --- inputBind("mouse_y", INPUT_ACTION_POINTERY) --- end --- end + if INPUT_POINTER then + inputBind("mouse_x", INPUT_ACTION_POINTERX) + inputBind("mouse_y", INPUT_ACTION_POINTERY) + end +end --- sceneSet('scene/minesweeper.lua') \ No newline at end of file +sceneSet('scene/minesweeper.lua') \ No newline at end of file diff --git a/assets/scene/minesweeper.lua b/assets/scene/minesweeper.lua index 70094cd..9e2c7bb 100644 --- a/assets/scene/minesweeper.lua +++ b/assets/scene/minesweeper.lua @@ -183,24 +183,30 @@ function sceneRender() camera.bottom = screenGetHeight() camera.right = screenGetWidth() + spriteBatchPush( + nil, + 0, 0, 32, 32, + colorBlue() + ) + -- Update mouse position - if INPUT_POINTER then - mouseX = inputGetValue(INPUT_ACTION_POINTERX) * screenGetWidth() - mouseY = inputGetValue(INPUT_ACTION_POINTERY) * screenGetHeight() + -- if INPUT_POINTER then + -- mouseX = inputGetValue(INPUT_ACTION_POINTERX) * screenGetWidth() + -- mouseY = inputGetValue(INPUT_ACTION_POINTERY) * screenGetHeight() - -- Draw cursor - spriteBatchPush( - nil, - mouseX - 2, mouseY - 2, - mouseX + 2, mouseY + 2, - colorRed(), - 0, 0, - 1, 1 - ) - end + -- -- Draw cursor + -- spriteBatchPush( + -- nil, + -- mouseX - 2, mouseY - 2, + -- mouseX + 2, mouseY + 2, + -- colorRed(), + -- 0, 0, + -- 1, 1 + -- ) + -- end - textDraw(10, 10, "Hello World") + -- textDraw(10, 10, "Hello World") -- centerX = math.floor(screenGetWidth() / 2) -- centerY = math.floor(screenGetHeight() / 2) diff --git a/src/dusk/display/screen/screen.c b/src/dusk/display/screen/screen.c index 708c79e..831dc5d 100644 --- a/src/dusk/display/screen/screen.c +++ b/src/dusk/display/screen/screen.c @@ -17,9 +17,9 @@ errorret_t screenInit() { SCREEN.background = COLOR_CORNFLOWER_BLUE; - #if DISPLAY_SIZE_DYNAMIC == 1 + #ifdef DUSK_DISPLAY_SIZE_DYNAMIC SCREEN.mode = SCREEN_MODE_FIXED_VIEWPORT_HEIGHT; - SCREEN.fixedHeight.height = DISPLAY_SCREEN_HEIGHT_DEFAULT; + SCREEN.fixedHeight.height = DUSK_DISPLAY_SCREEN_HEIGHT; cameraInitOrthographic(&SCREEN.framebufferCamera); SCREEN.framebufferCamera.viewType = CAMERA_VIEW_TYPE_2D; @@ -27,14 +27,14 @@ errorret_t screenInit() { SCREEN.framebufferCamera._2d.position[1] = 0; SCREEN.framebufferCamera._2d.zoom = 1.0f; - errorChain(quadBuffer( + quadBuffer( SCREEN.frameBufferMeshVertices, 0.0f, 0.0f, 1.0f, 1.0f, COLOR_WHITE, 0.0f, 0.0f, 1.0f, 1.0f - )); + ); errorChain(meshInit( &SCREEN.frameBufferMesh, QUAD_PRIMITIVE_TYPE, @@ -57,7 +57,7 @@ void screenBind() { SCREEN.height = frameBufferGetHeight(FRAMEBUFFER_BOUND); // No needd for a framebuffer. - #if DISPLAY_SIZE_DYNAMIC == 1 + #ifdef DUSK_DISPLAY_SIZE_DYNAMIC if(SCREEN.framebufferReady) { frameBufferDispose(&SCREEN.framebuffer); SCREEN.framebufferReady = false; @@ -66,7 +66,7 @@ void screenBind() { break; } - #if DISPLAY_SIZE_DYNAMIC == 1 + #ifdef DUSK_DISPLAY_SIZE_DYNAMIC case SCREEN_MODE_FIXED_SIZE: { SCREEN.width = SCREEN.fixedSize.width; SCREEN.height = SCREEN.fixedSize.height; @@ -270,7 +270,7 @@ void screenUnbind() { case SCREEN_MODE_BACKBUFFER: break; - #if DISPLAY_SIZE_DYNAMIC == 1 + #ifdef DUSK_DISPLAY_SIZE_DYNAMIC case SCREEN_MODE_ASPECT_RATIO: case SCREEN_MODE_FIXED_HEIGHT: case SCREEN_MODE_FIXED_SIZE: @@ -293,7 +293,7 @@ void screenRender() { return; } - #if DISPLAY_SIZE_DYNAMIC == 1 + #ifdef DUSK_DISPLAY_SIZE_DYNAMIC if(SCREEN.mode == SCREEN_MODE_FIXED_VIEWPORT_HEIGHT) { glViewport(0, 0, SCREEN.width, SCREEN.height); return; @@ -369,7 +369,7 @@ void screenRender() { } void screenDispose() { - #if DISPLAY_SIZE_DYNAMIC == 1 + #ifdef DUSK_DISPLAY_SIZE_DYNAMIC if(SCREEN.framebufferReady) { frameBufferDispose(&SCREEN.framebuffer); SCREEN.framebufferReady = false; diff --git a/src/dusk/display/screen/screen.h b/src/dusk/display/screen/screen.h index 714a24a..148713d 100644 --- a/src/dusk/display/screen/screen.h +++ b/src/dusk/display/screen/screen.h @@ -12,7 +12,7 @@ #include "display/mesh/quad.h" #include "display/color.h" -#if DUSK_DISPLAY_SIZE_DYNAMIC == 1 +#ifdef DUSK_DISPLAY_SIZE_DYNAMIC #ifndef DUSK_DISPLAY_SCREEN_HEIGHT #error "DUSK_DISPLAY_SCREEN_HEIGHT must be defined" #endif @@ -47,7 +47,7 @@ typedef struct { float_t aspect; color_t background; - #if DISPLAY_SIZE_DYNAMIC == 1 + #ifdef DUSK_DISPLAY_SIZE_DYNAMIC framebuffer_t framebuffer; bool_t framebufferReady; camera_t framebufferCamera; diff --git a/src/dusk/input/inputaction.h b/src/dusk/input/inputaction.h index 8aca01e..b829c0e 100644 --- a/src/dusk/input/inputaction.h +++ b/src/dusk/input/inputaction.h @@ -14,7 +14,7 @@ typedef struct { float_t lastValue; float_t currentValue; - #if TIME_FIXED == 0 + #ifdef DUSK_TIME_DYNAMIC float_t lastDynamicValue; float_t currentDynamicValue; #endif diff --git a/src/dusk/map/map.c b/src/dusk/map/map.c index 2b7d76c..572bd32 100644 --- a/src/dusk/map/map.c +++ b/src/dusk/map/map.c @@ -168,8 +168,8 @@ errorret_t mapPositionSet(const chunkpos_t newPos) { } void mapUpdate() { - #if TIME_FIXED == 0 - if(!TIME.dynamicUpdate) return; + #ifdef DUSK_TIME_DYNAMIC + if(!TIME.dynamicUpdate) return; #endif } diff --git a/src/dusk/scene/scene.c b/src/dusk/scene/scene.c index 054240b..0d026a8 100644 --- a/src/dusk/scene/scene.c +++ b/src/dusk/scene/scene.c @@ -21,10 +21,10 @@ errorret_t sceneInit(void) { } errorret_t sceneUpdate(void) { - #if TIME_FIXED == 0 - if(!TIME.dynamicUpdate) { - errorOk(); - } + #ifdef DUSK_TIME_DYNAMIC + if(!TIME.dynamicUpdate) { + errorOk(); + } #endif lua_getglobal(SCENE.scriptContext.luaState, "sceneUpdate"); diff --git a/src/dusk/script/module/input/moduleinput.c b/src/dusk/script/module/input/moduleinput.c index 5c25741..48056e7 100644 --- a/src/dusk/script/module/input/moduleinput.c +++ b/src/dusk/script/module/input/moduleinput.c @@ -18,25 +18,18 @@ void moduleInput(scriptcontext_t *context) { // Input values. scriptContextExec(context, - #if INPUT_KEYBOARD == 1 + "" + #ifdef DUSK_INPUT_KEYBOARD "INPUT_KEYBOARD = true\n" - #else - "" #endif - #if INPUT_GAMEPAD == 1 + #ifdef DUSK_INPUT_GAMEPAD "INPUT_GAMEPAD = true\n" - #else - "" #endif - #if INPUT_POINTER == 1 + #ifdef DUSK_INPUT_POINTER "INPUT_POINTER = true\n" - #else - "" #endif - #if INPUT_SDL2 == 1 - "INPUT_SDL2 = true\n" - #else - "" + #ifdef DUSK_INPUT_TOUCH + "INPUT_TOUCH = true\n" #endif ); diff --git a/src/duskgl/display/framebuffer/framebufferplatform.h b/src/duskgl/display/framebuffer/framebufferplatform.h index ec4edfa..17d6ee0 100644 --- a/src/duskgl/display/framebuffer/framebufferplatform.h +++ b/src/duskgl/display/framebuffer/framebufferplatform.h @@ -15,7 +15,7 @@ typedef framebuffergl_t framebufferplatform_t; #define frameBufferPlatformBind frameBufferGLBind #define frameBufferPlatformClear frameBufferGLClear -#if DUSK_DISPLAY_SIZE_DYNAMIC +#ifdef DUSK_DISPLAY_SIZE_DYNAMIC #define frameBufferPlatformInit frameBufferGLInit #define frameBufferPlatformDispose frameBufferGLDispose #endif \ No newline at end of file