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.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
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
RAD2DEG = 180.0 / Math::PI | |
TIME_STEP = 0.2 / 60 # delta time isn't required in DragonRuby but it really handy for tuning and debugging physics | |
COLLISION_BIAS = 0.05 # adds some energy into the collision to get objects to separate. tune this in steps of 0.01 | |
COLLISION_SLOP = 0.1 # amount shapes are allowed to overlap without triggering correction. helps avoid position jitter | |
COLLISION_ITERATIONS = 10 # how many times to run the solver. a good range is between 5 and 15 | |
def tick args | |
args.gtk.reset if args.inputs.keyboard.r | |
# Create some circles |
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 | |
# Create some circles | |
args.state.circles ||= 10.map_with_ys 2 do |x, y| | |
radius = 32 | |
diameter = radius * 2 | |
# for static objects use mass = Float::INFINITY | |
mass = Math::PI * radius * radius | |
path = 'sprites/circle/blue.png' | |
offset_x = (1280 - ((diameter + radius) * 10)) / 2 |
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
module GTK | |
class Runtime | |
def draw_circle c | |
radius = c.radius.to_i || 0 | |
xc = c.x.to_i + radius | |
yc = c.y.to_i + radius | |
t = c.thickness || 1 | |
r = c.r || 0 | |
g = c.g || 0 | |
b = c.b || 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
def create_vertices rect | |
x = rect.x; y = rect.y | |
w = rect.w; h = rect.h | |
cx = x + w * 0.5; cy = y + h * 0.5 | |
sin = Math.sin (rect.angle || 0.0).to_radians; cos = Math.cos (rect.angle || 0.0).to_radians | |
[ | |
[(x - cx) * cos - (y + h - cy) * sin + cx, (x - cx) * sin + (y + h - cy) * cos + cy], # Top Left | |
[(x + w - cx) * cos - (y + h - cy) * sin + cx, (x + w - cx) * sin + (y + h - cy) * cos + cy], # Top Right | |
[(x + w - cx) * cos - (y - cy) * sin + cx, (x + w - cx) * sin + (y - cy) * cos + cy], # Bottom Right | |
[(x - cx) * cos - (y - cy) * sin + cx, (x - cx) * sin + (y - cy) * cos + cy] # Bottom Left |
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
SCALE = 175.0 | |
LOD = 0.005 | |
MAX_Z_FAR = 600.0 | |
MIN_Z_FAR = 175.0 | |
MIN_SCREEN_W = 70 | |
MIN_SCREEN_H = 60 | |
MAX_SCREEN_W = 360 | |
MAX_SCREEN_H = 120 | |
DRS_FRAME_WINDOW = 10 | |
Z_FAR_ADJUST_SPEED = 1 |
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 MatrixFunctions | |
# Math constants | |
K_INV_6 = 1.0 / 6.0 | |
K_2_OVER_3 = 2.0 / 3.0 | |
K_2_PI = Math::PI * 2.0 | |
K_SQRT_3 = Math.sqrt 3.0 | |
K_NEG_1_OVER_3 = -1.0 / 3.0 | |
K_DEG2RAD = Math::PI / 180.0 | |
K_RAD2DEG = 360.0 / (2.0 * Math::PI) |
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
args.gtk.method(:write_file).parameters.map(&:last).map { |p| p.to_s } |
NewerOlder