Skip to content

Instantly share code, notes, and snippets.

View DCubix's full-sized avatar
💭
😄

Diego Lopes DCubix

💭
😄
View GitHub Profile
if mouse.events[events.LEFTMOUSE] == 1:
hit = P.mOver.hitObject
if hit is not None:
mesh = hit.meshes[0]
for v in range(mesh.getVertexArrayLength()):
vert = mesh.getVertex(0, v)
uv = vert.getUV()
uv[0] += 0.5
vert.setUV(uv)
#include <string>
#include <fstream>
#include <sstream>
#include "core/tgEngine.h"
#include "core/tgLog.h"
#include "core/tgInput.h"
#include "graphics/tgSpriteBatch.h"
@DCubix
DCubix / Types.h
Last active April 7, 2017 18:05
Vector Implementation for C
#ifndef TYPES_H
#define TYPES_H
#include <stdint.h>
typedef uint32_t uint;
typedef uint8_t bool;
#define true 1
#define false 0
@DCubix
DCubix / glcall.rs
Created December 8, 2017 00:12
Macro to call an OpenGL function, check errors and optionally return a value.
#[macro_export]
macro_rules! GL {
($fun:ident ( $($arg:expr),*)) => {{
unsafe {
let result = ::gl::$fun( $($arg),* );
let err = ::gl::GetError();
if err != ::gl::NO_ERROR {
let err_str = match err {
::gl::INVALID_OPERATION => "Invalid Operation",
::gl::INVALID_ENUM => "Invalid Enum",
#include "Logger.h"
#include <fstream>
#include <assert.h>
#include "termcolor.hpp"
namespace tfx {
#ifdef TFX_DEBUG
Logger Logger::logger = Logger();
@DCubix
DCubix / lde.c
Last active April 21, 2018 00:52
Lista Duplamente Encadeada
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
typedef struct Node_t {
int value;
struct Node_t* next;
struct Node_t* prev;
} Node;
@DCubix
DCubix / cube.obj
Created April 20, 2018 19:53
Cube
v 1.000000 -1.000000 -1.000000
v 1.000000 -1.000000 1.000000
v -1.000000 -1.000000 1.000000
v -1.000000 -1.000000 -1.000000
v 1.000000 1.000000 -0.999999
v 0.999999 1.000000 1.000001
v -1.000000 1.000000 1.000000
v -1.000000 1.000000 -1.000000
vt 1.000000 0.000000
vt 0.000000 1.000000
@DCubix
DCubix / mesher.cpp
Created April 20, 2018 20:05
Mesher
#include "mesher.h"
#include "../core/logging/log.h"
NS_BEGIN
void VertexFormat::put(const String& name, AttributeType type, bool normalized, i32 location) {
VertexAttribute attr;
attr.size = type;
attr.normalized = normalized;
@DCubix
DCubix / example.java
Created April 30, 2018 22:11
Clipping for GUI
public boolean beginClipping(int x, int y, int w, int h) {
IDevice dev = Age.Device;
if (!dev.isEnabled(Feature.Scissor)) {
dev.setFeatures(true, Feature.Scissor);
}
if (!clipRectStack.isEmpty()) {
Rectangle parent = clipRectStack.lastElement();
int minX = Math.max(parent.x, x);
int maxX = Math.min(parent.x + parent.width, x + w);
if (maxX - minX < 1) return false;
@DCubix
DCubix / namegen.py
Last active May 1, 2018 21:33
Name generation in Python
import random
from datetime import datetime
random.seed(datetime.now())
CONSONANTS = list("bcdfghjklmnpqrstvwyxz")
VOWELS = list("aeiou")
ALPHABET = CONSONANTS + VOWELS
THIRD_LETTER_PROB = 0.15