added hardcode and settings
This commit is contained in:
+22
-43
@@ -3,6 +3,7 @@
|
||||
#include "render/textures.hpp"
|
||||
#include "tiles/tilebase.hpp"
|
||||
#include "saving/saving.hpp"
|
||||
#include "settings/hardcode.hpp"
|
||||
#include <cmath>
|
||||
#include <cstdlib>
|
||||
|
||||
@@ -27,8 +28,8 @@ struct Tiles {
|
||||
};
|
||||
|
||||
int main() {
|
||||
int screenWidth = 1980;
|
||||
int screenHeight = 1080;
|
||||
int screenWidth = 1980 / 2;
|
||||
int screenHeight = 1080 / 2;
|
||||
|
||||
|
||||
raylib::Window window(screenWidth, screenHeight, "raylib-cpp - basic window");
|
||||
@@ -85,54 +86,32 @@ int main() {
|
||||
|
||||
DrawText("Middle", 190, 200, 20, WHITE);
|
||||
|
||||
Texture bg = tileTextures.GetTexture(0);
|
||||
if (IsMouseButtonReleased(MOUSE_BUTTON_LEFT)) {
|
||||
Vector2 mousepos = GetMousePosition();
|
||||
Vector2 worldpos;
|
||||
worldpos.x = mousepos.x + camera.target.x;
|
||||
worldpos.y = mousepos.y + camera.target.y;
|
||||
|
||||
// Infinite Background
|
||||
int bh = bg.height;
|
||||
int bw = bg.width;
|
||||
int offsetX = ((int)camera.target.x % bg.width);
|
||||
int offsetY = ((int)camera.target.y % bg.height);
|
||||
|
||||
if (IsMouseButtonReleased(MOUSE_BUTTON_LEFT)) {
|
||||
storedPosition = GetMousePosition();
|
||||
storedPosition.x += camera.target.x - screenWidth / 2.0f;
|
||||
storedPosition.y += camera.target.y - screenHeight / 2.0f;
|
||||
|
||||
chunkx = storedPosition.x / 8 / 64 - 1;
|
||||
chunky = storedPosition.y / 8 / 64 - 1;
|
||||
|
||||
int tileindex = (int)storedPosition.x % (8*64) / 64 + 8 * ((int)storedPosition.y % (8*64) / 64);
|
||||
|
||||
tileindex = abs(tileindex);
|
||||
|
||||
std::cout << "placed at: " << chunkx << ", " << chunky << ". index: " << tileindex << "\n";
|
||||
|
||||
Coordinate chunk;
|
||||
chunk.x = chunkx;
|
||||
chunk.y = chunky;
|
||||
|
||||
for (auto it = gamemap.layers[0].chunks.begin(); it != gamemap.layers[0].chunks.end(); ++it) {
|
||||
std::cout << it->first.x << ", " << it->first.y << "\n";
|
||||
Coordinate chunkpos;
|
||||
chunkpos.x = worldpos.x / CHUNKWIDTH;
|
||||
chunkpos.y = worldpos.y / CHUNKWIDTH;
|
||||
|
||||
}
|
||||
|
||||
gamemap.layers[1].chunks[chunk].tiles[tileindex].spriteid = 1;
|
||||
|
||||
}
|
||||
|
||||
|
||||
raylib::Rectangle fov{
|
||||
camera.target.x - screenWidth / 2 / zoom,
|
||||
camera.target.y - screenHeight / 2 / zoom,
|
||||
screenWidth / zoom,
|
||||
screenHeight / zoom,
|
||||
};
|
||||
raylib::Rectangle fov{
|
||||
camera.target.x - screenWidth / 2 / zoom,
|
||||
camera.target.y - screenHeight / 2 / zoom,
|
||||
screenWidth / zoom,
|
||||
screenHeight / zoom,
|
||||
};
|
||||
|
||||
gamemap.Draw(fov);
|
||||
gamemap.Draw(fov);
|
||||
|
||||
player.Draw();
|
||||
player.Draw();
|
||||
|
||||
EndMode2D();
|
||||
EndDrawing();
|
||||
EndMode2D();
|
||||
EndDrawing();
|
||||
}
|
||||
|
||||
// UnloadTexture() and CloseWindow() are called automatically.
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
#ifndef HARDCODE
|
||||
#define HARDCODE
|
||||
|
||||
const int CHUNKSIZE = 8;
|
||||
const int TILEWIDTH = 64;
|
||||
const int CHUNKWIDTH = CHUNKSIZE * TILEWIDTH;
|
||||
const int CHUNKTILES = CHUNKSIZE * CHUNKSIZE;
|
||||
|
||||
#endif // !HARDCODE
|
||||
Reference in New Issue
Block a user