Skip to content

Instantly share code, notes, and snippets.

View eduardonunesp's full-sized avatar

Eduardo Pereira eduardonunesp

View GitHub Profile
#include <iostream>
#include <random>
#include <vector>
#include <math.h>
#include <sstream>
struct Vector {
int x;
int y;
#include <stdlib.h>
#define GLEW_STATIC
#include <GL/glew.h>
#include <GLFW/glfw3.h>
#include <iostream>
//macro to write shader programs inline
#ifndef GLSL
#define GLSL(version,A) "#version " #version "\n" #A
#endif
@eduardonunesp
eduardonunesp / SwipeDetector.gd
Created April 21, 2020 23:58
Swipe Detector Godot
extends Node2D
signal swipe(direction)
var swipe_start = null
var minimum_drag = 100
func _unhandled_input(event):
if event.is_action_pressed("ui_click"):
swipe_start = get_global_mouse_position()
package main
import (
"fmt"
"regexp"
)
const emailRegex = `^(([^<>()\[\]\.,;:\s@\"]+(\.[^<>()\[\]\.,;:\s@\"]+)*)|(\".+\"))@(([^<>()[\]\.,;:\s@\"]+\.)+[^<>()[\]\.,;:\s@\"]{2,})$`
func printResult(result bool, err error) {
@eduardonunesp
eduardonunesp / observer.go
Created September 24, 2019 18:29
Simple Observer Pattern In Go
package main
import (
"fmt"
"sync"
)
type (
Observable interface {
Add(observer Observer)
@eduardonunesp
eduardonunesp / velocity_towards_angle.cs
Created September 3, 2019 21:51
Velocity Towards Angle
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Player : MonoBehaviour
{
public Rigidbody2D rb;
public float rotateSpeed = 300f;
public float angularSpeed = 10f;
private float yAxis;
@eduardonunesp
eduardonunesp / character_controller.cs
Created September 3, 2019 21:50
Character Controller
using UnityEngine;
using UnityEngine.Events;
public class CharacterController2D : MonoBehaviour
{
[SerializeField] private float m_JumpForce = 400f; // Amount of force added when the player jumps.
[Range(0, 1)] [SerializeField] private float m_CrouchSpeed = .36f; // Amount of maxSpeed applied to crouching movement. 1 = 100%
[Range(0, .3f)] [SerializeField] private float m_MovementSmoothing = .05f; // How much to smooth out the movement
[SerializeField] private bool m_AirControl = false; // Whether or not a player can steer while jumping;
[SerializeField] private LayerMask m_WhatIsGround; // A mask determining what is ground to the character
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Bomb : MonoBehaviour
{
// Use this for initialization
void Start()
{
int seconds = 3;
@eduardonunesp
eduardonunesp / destroy_after_animation_end.cs
Last active September 1, 2022 19:06
Destroy Game Object after animation end
using UnityEngine;
public class ExplosionCenter : MonoBehaviour
{
// Use this for initialization
void Start()
{
Destroy(gameObject, this.GetComponent<Animator>().GetCurrentAnimatorStateInfo(0).length);
}
@eduardonunesp
eduardonunesp / side_collision.cs
Created September 3, 2019 21:49
Detect Side Collision
void OnCollisionEnter2D(Collision2D col)
{
if (col.gameObject.tag.Equals("Wall"))
{
Vector3 hit = col.contacts[0].normal;
Debug.Log(hit);
float angle = Vector3.Angle(hit, Vector3.up);
if (Mathf.Approximately(angle, 0))
{