Skip to content

Instantly share code, notes, and snippets.

View thai-ng's full-sized avatar

Thai Nguyen thai-ng

View GitHub Profile
@thai-ng
thai-ng / Maze.cpp
Last active February 16, 2017 03:22
Recursive Division Maze Generator
#include <iostream>
#include <vector>
#include <random>
#include <chrono>
enum class TileStatus
{
Visited,
Wall,
NotVisited
@thai-ng
thai-ng / matrix.hpp
Created February 25, 2017 01:52
Compile time matrix
#pragma once
#include <array>
template <int width, int height, typename T>
class Matrix
{
using row_t = std::array<T, width>;
using col_t = std::array<T, height>;
public:
@thai-ng
thai-ng / angle.cpp
Last active March 5, 2017 02:58
count number of viewable points
#include <vector>
#include <cmath>
#include <algorithm>
struct Point
{
int x;
int y;
};
#include "drawable.h"
#include <SDL/SDL.h>
class SDLDrawable : public Drawable
{
public:
SDLDrawable(int w, int h);
~SDLDrawable();
void setPixel(int x, int y, unsigned int color);
unsigned int getPixel(int x, int y);
#include "SDLDrawable.hpp"
SDLDrawable::SDLDrawable(int w, int h) : width(w), height(h)
{
SDL_Init(SDL_INIT_VIDEO);
screen = SDL_SetVideoMode(width, height, 32, SDL_SWSURFACE);
if (SDL_MUSTLOCK(screen))
SDL_LockSurface(screen);
}
#include <SDL/SDL.h>
#include <emscripten.h>
#include "SDLDrawable.hpp"
#include "client.h"
int main()
{
SDLDrawable drawable(750, 750);
Client client(&drawable, "test.simp");
CXX=emcc
all: test.html
test.html:
$(CXX) -std=c++1z -stdlib=libc++ -O3 *.cpp -o $@ --preload-file test.simp --preload-file teapot.obj -s ALLOW_MEMORY_GROWTH=1
#include <cstdio>
using namespace Platform;
void doTheThing(const wchar_t* string)
{
printf("%ws\n", string);
}
template <typename T>
#include <cstdio>
#include <type_traits>
using namespace Platform;
void doTheThing(const wchar_t* string)
{
printf("%ws\n", string);
}
#include <vector>
#include <iostream>
#include <memory>
#include <algorithm>
#include <type_traits>
using namespace std;
class EventHandler
{