Skip to content

Instantly share code, notes, and snippets.

View RafaelOliveira's full-sized avatar

Rafael Oliveira RafaelOliveira

View GitHub Profile
@kobalicek
kobalicek / blend2d-sdl2-sample.cpp
Created November 12, 2020 11:10
Blend2D & SDL Sample
#include <blend2d.h>
#include <SDL.h>
#define ARRAY_SIZE(X) uint32_t(sizeof(X) / sizeof(X[0]))
// ============================================================================
// [SDL_Application]
// ============================================================================
class SDL_Application {
@chrisdill
chrisdill / RayForm.cs
Last active June 6, 2024 15:34
Using raylib from inside a win forms application
using System;
using System.Drawing;
using System.Runtime.InteropServices;
using System.Windows.Forms;
using Raylib_cs;
using Color = Raylib_cs.Color;
namespace Rayforms
{
public class RayForm : Form
@romamik
romamik / KhaImageFromEncodedBytes.hx
Created January 11, 2017 08:29
Create kha image from encoded (png, jpg, etc...) bytes
package;
import haxe.io.Bytes;
import kha.Image;
#if sys_kore
@:cppFileCode('
#include <Kore/Graphics/stb_image.h>
#ifndef INCLUDED_kha_graphics4_TextureFormat
#include <kha/graphics4/TextureFormat.h>
@marcgg
marcgg / notevalues.json
Created November 1, 2016 10:56
note frequency value
var noteValues = {
'C0': 16.35,
'C#0': 17.32,
'Db0': 17.32,
'D0': 18.35,
'D#0': 19.45,
'Eb0': 19.45,
'E0': 20.60,
'F0': 21.83,
'F#0': 23.12,

Let's do some cppia

Note! Created a repo to replace this gist: https://github.com/cambiata/Haxe-Cppia-Basics Easier to testrun, fork and pr! Thanks, @PDeveloper!

This is a simple testproject created for the single purpose of learning how to use cppia, the scripable "cpp subtarget" for Haxe, created by Hugh Sanderson.

Info about cppia can be found in Hugh's WWX2015 talk (cppia part starts around 15:45).

Please note that this is WORK IN PROGRESS, and that I haven't yet found out to create a working cppia host..! Please step in with discussion and contributions!

@xem
xem / readme.md
Last active May 11, 2024 23:57
Maths & trigonometry cheat sheet for 2D & 3D games

Conventions

  • A = [xA, yA] is a point on the 2D plane. Same for B, C, ...
  • lengths are in any unit (ex: pixels)
  • code snippets are in JavaScript

Degrees to radians

angleRad = angleDeg * Math.PI / 180;

@wighawag
wighawag / Main.hx
Last active March 21, 2017 17:50
Kha White Noise
import kha.System;
import kha.Scheduler;
class Main{
public static function main(){
System.init({
title: "dsp",
width: 800,
height: 600,
}, initialized);
@zaynyatyi
zaynyatyi / Game.hx
Last active June 28, 2019 21:37
Actuate in kha using manual update
package;
import motion.actuators.SimpleActuator;
class Game
{
public function new()
{
}
@user890104
user890104 / si7021.c
Last active September 5, 2017 08:06
Si7021 Linux app
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
#include <string.h>
#include <fcntl.h>
#include <errno.h>
#include <linux/i2c-dev.h>
#define BYTES2SHORT(X) (X[0] << 8 | X[1])
@mrcdk
mrcdk / OneOf.hx
Last active July 9, 2020 03:20
OneOf abstract: An abstract that uses haxe.ds.Either as its base type and hides the explicit use of it. http://try.haxe.org/#c0557
import haxe.ds.Either;
abstract OneOf<A, B>(Either<A, B>) from Either<A, B> to Either<A, B> {
@:from inline static function fromA<A, B>(a:A) : OneOf<A, B> return Left(a);
@:from inline static function fromB<A, B>(b:B) : OneOf<A, B> return Right(b);
@:to inline function toA():Null<A> return switch(this) {case Left(a): a; default: null;}
@:to inline function toB():Null<B> return switch(this) {case Right(b): b; default: null;}
}