@@ -5,8 +5,8 @@ find_package(SFML 2.5 COMPONENTS graphics system window REQUIRED) | |||
set(CMAKE_CXX_CLANG_TIDY | |||
clang-tidy | |||
-header-filter=.* | |||
-checks=-*,-checks=bugprone-*,cert-*,performance-*,clang-analyzer-*,-cert-dcl16-c,-cert-err58-cpp,-clang-analyzer-optin.cplusplus.VirtualCall) | |||
--header-filter=.* | |||
--checks=-*,bugprone-*,cert-*,performance-*,clang-analyzer-*,-cert-dcl16-c,-cert-err58-cpp,-clang-analyzer-optin.cplusplus.VirtualCall) | |||
add_compile_options(-std=c++2a -Wall -Wextra -Wpedantic -Wno-unused-parameter) | |||
if(CMAKE_BUILD_TYPE STREQUAL Debug OR CMAKE_BUILD_TYPE STREQUAL "") |
@@ -1,9 +1,15 @@ | |||
#include "EntItemStack.h" | |||
#include <random> | |||
EntItemStack::EntItemStack(const Swan::Context &ctx, const Swan::SRF ¶ms): | |||
PhysicsEntity(SIZE, MASS) { | |||
readSRF(ctx, params); | |||
static std::uniform_real_distribution dis(-0.2f, 0.2f); | |||
body_.pos_ += Swan::Vec2{ dis(ctx.world.random_), dis(ctx.world.random_) }; | |||
} | |||
void EntItemStack::draw(const Swan::Context &ctx, Swan::Win &win) { |
@@ -6,9 +6,6 @@ namespace Swan { | |||
class Win { | |||
public: | |||
float scale_ = 2; | |||
Vec2 cam_; | |||
Win(sf::RenderWindow *win): window_(win) {} | |||
void setPos(const Vec2 &pos) { | |||
@@ -26,6 +23,9 @@ public: | |||
return Vec2(v.x, v.y) / (TILE_SIZE * scale_); | |||
} | |||
float scale_ = 2; | |||
Vec2 cam_; | |||
private: | |||
sf::RenderWindow *window_; | |||
sf::Transform transform_; |
@@ -3,6 +3,7 @@ | |||
#include <memory> | |||
#include <vector> | |||
#include <string> | |||
#include <random> | |||
#include "common.h" | |||
#include "Asset.h" | |||
@@ -18,7 +19,7 @@ class Game; | |||
class World { | |||
public: | |||
World(Game *game): game_(game) {} | |||
World(Game *game, unsigned long rand_seed): game_(game), random_(rand_seed) {} | |||
WorldPlane &addPlane(const std::string &gen); | |||
WorldPlane &addPlane() { return addPlane(default_world_gen_); } | |||
@@ -50,6 +51,8 @@ public: | |||
Entity *player_; | |||
Game *game_; | |||
std::mt19937 random_; | |||
private: | |||
class ChunkRenderer { | |||
public: |
@@ -3,6 +3,7 @@ | |||
#include <dlfcn.h> | |||
#include <math.h> | |||
#include <SFML/Window/Mouse.hpp> | |||
#include <time.h> | |||
#include "Tile.h" | |||
#include "Asset.h" | |||
@@ -30,7 +31,7 @@ void Game::loadMod(const std::string &path) { | |||
} | |||
void Game::createWorld(const std::string &worldgen) { | |||
world_.reset(new World(this)); | |||
world_.reset(new World(this, time(NULL))); | |||
for (auto &mod: registered_mods_) { | |||
world_->registerTile(std::shared_ptr<Tile>(Tile::createInvalid())); | |||