Skip to content

Instantly share code, notes, and snippets.

View enghqii's full-sized avatar

Chanwoo enghqii

  • NEXON KOREA
  • South Korea
View GitHub Profile
@enghqii
enghqii / main.lua
Last active August 29, 2015 14:05
Isometric coord to Descartes coord (running on love2D engine)
-- https://github.com/davidm/lua-matrix/blob/master/lua/matrix.lua
local matrix = require 'matrix'
-- Origin x,y (Screen coord)
Ix0, Iy0 = 93, 329; -- Isometric
Dx0, Dy0 = 450, 329; -- Descartes
-- invert y axis, move to Dx0, Dy0
descartesToScreenMatrix = (matrix{{1, 0, Dx0}, {0, 1, Dy0}, {0, 0, 1}} * matrix{{1, 0, 0}, {0, -1, 0}, {0, 0, 1}})
-- Basis Vector I is (sqrt(3)/2, -1/2), J is (0, 1)
#include <stdio.h>
int max(int a, int b, int c){
int t = ( a > b ? a : b);
return (t > c ? t : c);
}
int max(int a, int b){
return (a > b? a : b);
@enghqii
enghqii / 3rdDim.cpp
Created October 25, 2014 21:04
Dynamic 3rd dimension array alloc in C++
#include <iostream>
using namespace std;
#define SAFE_DELETE_ARRAY(ptr) { if(ptr) { delete [](ptr); (ptr)=NULL; } }
int main(){
// alloc 'team'
int*** team = new int**[1001];
for(int x = 0; x < 1001; x++){
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <dirent.h>
#include <time.h>
#include <sys/stat.h>
#include <sys/types.h>
#include<iostream>
#include<sstream>
#include<array>
using namespace std;
typedef array<array<char, 5>, 5> char5x5;
typedef array<array<int, 5>, 5> int5x5;
int inline safeAccess(const int5x5& table, int i, int j)
{
@enghqii
enghqii / LSMG.cpp
Last active April 19, 2016 12:11
Lagrange Snail Matrix Generator - http://enghqii.tistory.com/24
#include <iostream>
#include <sstream>
using namespace std;
typedef int uint;
std::string LagrangeGenerator(const uint k){
uint** arr = new uint*[k];
for(uint i=0;i<k;i++){ arr[i] = new uint[k]; }
#include <iostream>
#include <vector>
#include <set>
using namespace std;
int main(){
int testcase = 0;
cin>>testcase;
@enghqii
enghqii / main.cpp
Created May 28, 2015 08:20
Win32 Console Double Buffering
#include <windows.h>
#include <stdio.h>
#define WIDTH 120
#define HEIGHT 30
float playerX = 0;
float playerY = 0;
float dx = 0,dy = 0;
%option noyywrap
%option yylineno
%{
//#include "sym.h"
#include "coma.tab.h"
%}
@enghqii
enghqii / NormalMap.shader
Created December 12, 2015 02:23
NormalMap shader Unity
Shader "Custom/NormalMapShader" {
Properties {
_Color ("Color", Color) = (1,1,1,1)
_LightColor("LightColor", Color) = (1,1,1,1)
_MainTex("Albedo (RGB)", 2D) = "white" {}
_SpecularMap("SpecularMap (RGB)", 2D) = "white" {}
_NormalMap("NormalMap", 2D) = "white" {}
_MainLightPosition("MainLightPosition", Vector) = (0,0,0,0)
}
SubShader{