Skip to content

Instantly share code, notes, and snippets.

View TheSeamau5's full-sized avatar

Hassan Hayat TheSeamau5

  • Entrepreneur
  • Austin, TX
View GitHub Profile
@TheSeamau5
TheSeamau5 / Pong3D.elm
Last active August 29, 2015 14:13
Pong in 3d using Graphics Engine in Elm
import Engine (..)
import Engine.Material.Material (MaterialProperty)
import Math.Vector3 (vec3, Vec3)
import Engine.Shader.GouraudShader (gouraudShader)
import Time (..)
import Signal (..)
import Keyboard
import Window
@TheSeamau5
TheSeamau5 / SimpleHexGrid.elm
Last active February 8, 2016 22:05
Simple way to create a hexagonal grid in Elm
import List (..)
import Text (asText)
import Graphics.Collage (..)
import Graphics.Element (..)
import Color (..)
--Based on http://www.redblobgames.com/grids/hexagons/
type alias Point = {
x : Int,
@TheSeamau5
TheSeamau5 / IdealizedECS
Last active January 27, 2018 10:31
Idealized vision of using Entity Component Systems
----------------------------
----- TYPE DEFINITIONS -----
----------------------------
Entity : Object
Component : Object
DeltaTime : Component
deltaTime : Number
@TheSeamau5
TheSeamau5 / ECSExampleInDartOOPStyle.dart
Created January 7, 2015 22:24
ECS Example in Dart using OOP
class Point {
final num x;
final num y;
const Point(this.x, this.y);
Point operator + (Point p) {
return new Point(p.x + x, p.y + y);
}
Point scale(num factor){
return new Point(x * factor, y * factor);
}
@TheSeamau5
TheSeamau5 / ECSExampleInES6.js
Last active September 16, 2022 21:41
ECS Example in Javascript / ES6
// HELPER FUNCTIONS
const has = (entity, components) => {
const exists = (x) => typeof x !== "undefined";
return components.map((component) => exists(entity[component]))
.reduce((x,y) => x && y);
};
const clone = (object) => {
if (object === null || typeof object !== 'object'){
return object;
@TheSeamau5
TheSeamau5 / hackyECS.elm
Last active October 7, 2015 15:53
Entity Component Systems in Elm using hacks à-la elm-webgl
type Entity entity = Entity
type Component = Component
get : String -> Entity -> Maybe Component
get = ECS.Native.get
update : String -> a -> Entity -> Entity
update = ECS.Native.update
@TheSeamau5
TheSeamau5 / makingElmDynamicSafely.md
Last active February 16, 2017 20:40
Proposal to make Elm more dynamic while maintaining type safety

Making Elm more Dynamic safely

The goal of this piece is to explore ways to give Elm some of the awesome features of dynamic languages while not sacrificing Elm's safety. The following ideas have come from exploring entity component systems/plugin architectures and noticing some of Elm's "limitations" to represent some of these ideas.

*NOTE: I am by no means an expert in type systems, compiler, programming languages, or actually programming in general. These are simply ideas I have been playing around with in recent weeks and wished to share with the Elm community. The hope is not that my ideas be adopted or pushed for or whatever. The goal is simply to improve the Elm language/platform by exploring possibilities to enhance the language in such a way as to not break any of its current guarantees or void any of its current advantages. The following is an exploration on how to make Elm's type system more "dynamic" in the sense that the inputs may be of unknown type while keeping the static nature of the lan

@TheSeamau5
TheSeamau5 / usingHeterogeneousLists.elm
Created January 6, 2015 17:21
Using Heterogeneous lists in Proposal in Elm
mario = {
position = {x = 0, y = 0},
velocity = {x = 0, y = 0},
mass = 10,
Life,
Groundedness,
Controllability
}
goomba = {
@TheSeamau5
TheSeamau5 / heterogeneousLists.elm
Created January 6, 2015 16:39
Safe Heterogeneous Lists through meta-annotations
-- We could use meta-annotations to have heterogeneous lists
mario = {
position = { x = 0, y = 0 },
velocity = { x = 0, y = 0 },
Life,
Controllability,
Groundedness
}
goomba = {
@TheSeamau5
TheSeamau5 / symbols.elm
Created January 6, 2015 16:22
Proposal for Symbols in Elm.
-- life is a singleton. it acts as a symbol
-- In this case, we use the presence or absence of this symbol as a boolean flag.
mario = {
position = {
x = 0,
y = 0
},
velocity = {
x = 0,
y = 0