This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def tick(args) | |
grid_w = 16 | |
grid_h = 16 | |
args.state.grid ||= [ | |
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |
0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, | |
0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, | |
0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef ENGINE_SCENE_SCENE_H | |
#define ENGINE_SCENE_SCENE_H | |
#include <scene/types.h> | |
#include <any> | |
#include <map> | |
#include <bitset> | |
#include <vector> | |
#include <typeindex> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cmake_minimum_required(VERSION 3.24) | |
# Install CPM.cmake | |
set(CPM_VERSION 0.38.1) | |
set(CPM_SOURCE_CACHE ${CMAKE_SOURCE_DIR}/ext) | |
set(CPM_DOWNLOAD_LOCATION "${CPM_SOURCE_CACHE}/cpm/CPM_${CPM_VERSION}.cmake") | |
if(NOT (EXISTS ${CPM_DOWNLOAD_LOCATION})) | |
file(DOWNLOAD https://github.com/TheLartians/CPM.cmake/releases/download/v${CPM_VERSION}/CPM.cmake |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cmake_minimum_required(VERSION 3.8 FATAL_ERROR) | |
# Install CPM ########################################################################################################## | |
set(CPM_VERSION 0.38.1) | |
set(CPM_SOURCE_CACHE ${CMAKE_SOURCE_DIR}/libraries) | |
set(CPM_DOWNLOAD_LOCATION "${CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake") | |
if(NOT (EXISTS ${CPM_DOWNLOAD_LOCATION})) | |
file(DOWNLOAD https://github.com/TheLartians/CPM.cmake/releases/download/v${CPM_VERSION}/CPM.cmake |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <objc/runtime.h> | |
#include <objc/message.h> | |
#include <CoreGraphics/CoreGraphics.h> | |
template <typename Return, typename... Args> auto send(id obj, SEL selector, Args... args) { | |
return reinterpret_cast<Return (*)(id, SEL, Args...)>(objc_msgSend)(obj, selector, args...); | |
} | |
template <typename Return, typename... Args> auto send(Class cls, SEL selector, Args... args) { | |
return reinterpret_cast<Return (*)(id, SEL, Args...)>(objc_msgSend)(reinterpret_cast<id>(cls), selector, args...); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cmake_minimum_required(VERSION 3.25) | |
project(CocoaWindow) | |
set(CMAKE_CXX_STANDARD 20) | |
# Install CPM ########################################################################################################## | |
set(CPM_VERSION 0.38.1) | |
set(CPM_SOURCE_CACHE ${CMAKE_SOURCE_DIR}/libraries) | |
set(CPM_DOWNLOAD_LOCATION "${CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "Camera", | |
"components": [ | |
{ | |
"name": "Position", | |
"attributes": [ | |
{ "x": 100 } | |
] | |
} | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template <typename T> class delegate; | |
template <typename R, typename... Args> class delegate<R(Args...)> { | |
public: | |
template <R(*function)(Args...)> auto bind(void) -> void { | |
_instance = nullptr; | |
_proxy = &function_proxy<function>; | |
} | |
template <class C, R(C::* function)(Args...)> auto bind(C* instance) -> void { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef ENGINE_TYPES_H | |
#define ENGINE_TYPES_H | |
#include <immintrin.h> | |
auto inline sqrt(float const s) -> float { return _mm_cvtss_f32(_mm_sqrt_ss(_mm_set_ss(s))); } | |
auto inline rsqrt(float const s) -> float { return _mm_cvtss_f32(_mm_rsqrt_ss(_mm_set_ss(s))); } | |
struct vector2 { float x, y; }; | |
struct vector3 { float x, y, z; }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DEG2RAD = Math::PI / 180.0 | |
def tick args | |
b = args.state.box_a ||= { x: 540, y: 360, w: 200, h: 200, angle: 45, path: 'sprites/square/blue.png' } | |
a = args.state.box_b ||= { x: 340, y: 360, w: 100, h: 100, angle: 45, path: 'sprites/square/green.png' } | |
$a = a | |
a.y += 1 if args.inputs.up | |
a.y -= 1 if args.inputs.down | |
a.x -= 1 if args.inputs.left |
NewerOlder