26#define PLAYER_SIZE glm::vec2(6.f / 8.f, 1.f)
39 void move(glm::vec2 dir);
43 void jump(
float power);
60 Block *map,
bool &upTouch,
bool &downTouch,
bool &leftTouch,
bool &rightTouch);
63 glm::vec2 delta,
bool &upTouch,
bool &downTouch,
bool &leftTouch,
bool &rightTouch);
74 gl2d::TextureAtlasPadding
atlas;
102 if (requestedInfo.
getFileSizeBinary(SAMURAI_RESOURCES_PATH
"/mario/map1.scene", s))
124 if (requestedInfo.
getFileSizeBinary(SAMURAI_RESOURCES_PATH
"/mario/1985_tiles.png", s))
126 void *data =
new unsigned char[s];
127 if (requestedInfo.
readEntireFileBinary(SAMURAI_RESOURCES_PATH
"/mario/1985_tiles.png", data, s))
129 tiles.createFromFileDataWithPixelPadding((
unsigned char*)data, s, 8,
true,
false);
140 marioTexture.loadFromFile(SAMURAI_RESOURCES_PATH
"/mario/mario.png",
true,
false);
141 marioTexture.loadFromFile(SAMURAI_RESOURCES_PATH
"/mario/mario.png",
true,
false);
145 atlas = gl2d::TextureAtlasPadding(8, 10, 8*8, 8*10);
153 bool rez =
loadMap(requestedInfo);
155 fileChanged.setFile(SAMURAI_RESOURCES_PATH
"/mario/map1.scene");
165 glClear(GL_COLOR_BUFFER_BIT);
166 gl2d::enableNecessaryGLFeatures();
167 renderer.updateWindowMetrics(windowState.
w, windowState.
h);
176 float wheel = ImGui::GetIO().MouseWheel;
180 if ((ImGui::GetIO().KeysData[ImGuiKey_LeftCtrl].Down || ImGui::GetIO().KeysData[ImGuiKey_RightCtrl].Down) && input.
hasFocus)
182 renderer.currentCamera.zoom += wheel * 3;
232 auto viewRect =
renderer.getViewRect();
239 minV = {viewRect.x - 2, viewRect.y - 2};
240 maxV = minV + glm::ivec2{viewRect.z + 4, viewRect.w + 4};
241 minV = glm::max(minV, {0,0});
242 maxV = glm::min(maxV,
mapSize);
245 for (
int j = minV.y; j < maxV.y; j++)
246 for (
int i = minV.x; i < maxV.x; i++)
glm::vec4 getTileUV(gl2d::TextureAtlasPadding atlas, int id, int flip)
void setGlobalAllocator(samurai::memory::CustomAllocator *allocator)
void setGlobalAllocatorToStandard()
size_t constexpr MB(size_t x)
size_t defaultHeapMemorySize
gl2d::Texture marioTexture
bool update(samurai::Input input, samurai::WindowState windowState, RequestedContainerInfo &requestedInfo)
Block & getMapBlockUnsafe(int x, int y)
gl2d::Renderer2D renderer
static ContainerStaticInfo containerInfo()
bool create(RequestedContainerInfo &requestedInfo, samurai::StaticString< 256 > commandLineArgument)
samurai::FileChanged fileChanged
bool loadMap(RequestedContainerInfo &requestedInfo)
gl2d::TextureAtlasPadding atlas
void updatePhisics(float deltaTime)
void resolveConstrains(Block *map)
glm::vec2 performCollision(Block *map, glm::vec2 pos, glm::vec2 size, glm::vec2 delta, bool &upTouch, bool &downTouch, bool &leftTouch, bool &rightTouch)
void applyGravity(float gravity)
void moveVelocityX(float dir)
void checkCollisionBrute(glm::vec2 &pos, glm::vec2 lastPos, Block *map, bool &upTouch, bool &downTouch, bool &leftTouch, bool &rightTouch)
bool readEntireFileBinary(const char *name, void *buffer, size_t size)
bool getFileSizeBinary(const char *name, size_t &size)
samurai::memory::CustomAllocator * mainAllocator