Skip to content

Instantly share code, notes, and snippets.

View G4rryS1ngh's full-sized avatar

ぎゃりぃ G4rryS1ngh

View GitHub Profile
@G4rryS1ngh
G4rryS1ngh / TerrainProcGen01.cpp
Last active July 10, 2023 00:28
Procedural generated terrain map and characters walking around on it. (test)
# include <Siv3D.hpp> // OpenSiv3D v0.4.3
struct NoiseUnit
{
double value;
Vec2 gradient;
Vec2 curl;
};
@G4rryS1ngh
G4rryS1ngh / relax_polygons.cpp
Created September 27, 2020 07:08
Relax polygon(triangle) vertices
# include <Siv3D.hpp> // OpenSiv3D v0.4.3
class Graph
{
using NodeID = int;
using Patch = Array<NodeID>;
private:
@G4rryS1ngh
G4rryS1ngh / town_procgen.cpp
Created September 25, 2020 14:54
自動街生成🏙
# include <Siv3D.hpp> // OpenSiv3D v0.4.3
Array<Polygon> createPolygons(RectF rect, double density)
{
Array<Vec2> centers = PoissonDisk2D(rect.size.asPoint(), density).getPoints();
centers.each([=](Vec2& v) { v.moveBy(rect.tl()); });
centers.keep_if([=](Vec2 v) { return rect.contains(v); });
Array<Polygon> polygons;
@G4rryS1ngh
G4rryS1ngh / tree_procgen.cpp
Last active March 6, 2020 15:43
Procedural tree generation using space colonization algorithm
# include <Siv3D.hpp> // OpenSiv3D v0.4.2
struct Leaf
{
Vec2 pos;
bool reached = false;
Leaf(Vec2 _pos)
@G4rryS1ngh
G4rryS1ngh / agriculture.cpp
Created March 3, 2020 10:55
農業ゲームのデモ( ˘ω˘ )
# include <Siv3D.hpp> // OpenSiv3D v0.4.2
RectF GetRectFrom2Pts(Vec2 _p1, Vec2 _p2)
{
Vec2 size(Abs(_p1.x - _p2.x), Abs(_p1.y - _p2.y));
if (_p1.x < _p2.x)
{
@G4rryS1ngh
G4rryS1ngh / city_builder.cpp
Last active March 1, 2020 14:08
街づくりシミュレーションっぽいデモ
# include <Siv3D.hpp> // OpenSiv3D v0.4.2
RectF GetRectFrom2Pts(Vec2 _p1, Vec2 _p2)
{
Vec2 size(Abs(_p1.x - _p2.x), Abs(_p1.y - _p2.y));
if (_p1.x < _p2.x)
{
@G4rryS1ngh
G4rryS1ngh / inventory.cpp
Last active December 29, 2019 22:05
Minecraft style inventory system WIP
# include <Siv3D.hpp> // OpenSiv3D v0.4.2
struct Player
{
Texture texture;
Vec2 pos;
Player(Vec2 _pos = Scene::CenterF())
: texture(Emoji(U"🐭"))
@G4rryS1ngh
G4rryS1ngh / polypads.cpp
Created December 25, 2019 11:31
Edge jointed polygons
# include <Siv3D.hpp> // OpenSiv3D v0.4.2
struct PolyPad
{
String shape_name;
double edge_length;
Polygon poly;
Polygon appearance;
Color color;
@G4rryS1ngh
G4rryS1ngh / contour_anim.cpp
Created May 3, 2019 22:48
輪郭をなぞる文字たち_( _´ω`)_
# include <Siv3D.hpp> // OpenSiv3D v0.3.2
using ContourPaths = Array<Array<Array<Vec2>>>;
class AnimatedCharacter
{
private:
@G4rryS1ngh
G4rryS1ngh / blackboard.cpp
Created May 1, 2019 01:30
こくばん(*'▽')
# include <Siv3D.hpp> // OpenSiv3D v0.3.2
Image CreateNoiseImage(double _density)
{
Grid<double> grid(Window::Size());
const PerlinNoise noise(Random(0, 100000));
for (auto p : step(grid.size()))
{