Files

62 lines
1.2 KiB
C++
Raw Permalink Normal View History

2018-04-21 15:13:43 +02:00
#include <switch.h>
#include <sys/stat.h>
#include "draw.hpp"
#include "game.hpp"
u8* g_framebuf;
2025-02-02 08:03:44 +10:30
Framebuffer g_framebuffer;
u32 g_framebufWidth, g_framebufHeight;
PadState g_pad;
2018-04-21 15:13:43 +02:00
bool fileExists(std::string path)
{
struct stat buffer;
return (stat (path.c_str(), &buffer) == 0);
}
2025-02-02 08:03:44 +10:30
void Initgfx()
{
NWindow* win = nwindowGetDefault();
g_framebufHeight = 720;
g_framebufWidth = 1280;
framebufferCreate(&g_framebuffer, win, g_framebufWidth, g_framebufHeight, PIXEL_FORMAT_RGBA_8888, 2);
framebufferMakeLinear(&g_framebuffer);
}
void InitController()
{
padConfigureInput(1, HidNpadStyleSet_NpadStandard);
padInitializeDefault(&g_pad);
}
2018-04-21 15:13:43 +02:00
int main()
{
mkdir("sdmc:/switch", 777);
mkdir("sdmc:/switch/2048", 777);
2025-02-02 08:03:44 +10:30
Initgfx();
InitController();
2018-04-21 15:13:43 +02:00
Game::init();
if (fileExists("sdmc:/switch/2048/state"))
{
Game::loadState();
}
2025-02-02 08:03:44 +10:30
while(appletMainLoop())
2018-04-21 15:13:43 +02:00
{
2025-02-02 08:03:44 +10:30
padUpdate(&g_pad);
u64 kDown = padGetButtonsDown(&g_pad);
if (kDown & HidNpadButton_Plus)
{
break;
}
2018-04-21 15:13:43 +02:00
Game::scanInput();
Game::show();
}
Game::saveState();
2025-02-02 08:03:44 +10:30
framebufferClose(&g_framebuffer);
return 0;
2018-04-21 15:13:43 +02:00
}