Skip to content

Instantly share code, notes, and snippets.

View EduardoJM's full-sized avatar

Eduardo Oliveira EduardoJM

View GitHub Profile
@EduardoJM
EduardoJM / Git Comands.md
Last active May 17, 2024 17:35
Git commands
@EduardoJM
EduardoJM / App.tsx
Created April 6, 2021 20:51
rn_text_3
export default function App() {
const [localData, setLocalData] = useState<Data>({
text: 'This is a basic example with text'
});
return (
<View style={styles.container}>
<Text>Open up App.tsx to start working on your app!</Text>
{localData.text && (
<Text>{localData.text}</Text>
@EduardoJM
EduardoJM / App.tsx
Created April 6, 2021 20:48
rn_text_2
interface Data {
text?: string;
}
@EduardoJM
EduardoJM / App.tsx
Created April 6, 2021 20:46
rn_text_1
import React, { useState } from 'react';
import { StatusBar } from 'expo-status-bar';
import { StyleSheet, Text, View } from 'react-native';
@EduardoJM
EduardoJM / sat_8.html
Created July 11, 2020 18:17
Separathing Axis Theorem Testing Html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<canvas id="game" width="512" height="512"></canvas>
@EduardoJM
EduardoJM / sat_7.js
Created July 11, 2020 18:15
Separating Axis Theorem Testing
const canvas = document.getElementById('game');
const context = canvas.getContext('2d');
const polygons = [];
const polygonsColors = [ 'red', 'blue', 'green', 'pink', 'purple', 'cyan' ];
polygons.push(createPolygon([
{ x: 50, y: 50 },
{ x: 100, y: 50 },
{ x: 100, y: 150 },
{ x: 50, y: 150 },
@EduardoJM
EduardoJM / sat_6.js
Created July 11, 2020 18:11
Separating Axis Theorem Collision Testing
polygon.testWith = function (otherPolygon) {
// get all edges
const edges = [];
for (let i = 0; i < polygon.edges.length; i++) {
edges.push(polygon.edges[i]);
}
for (let i = 0; i < otherPolygon.edges.length; i++) {
edges.push(otherPolygon.edges[i]);
}
// build all axis and project
@EduardoJM
EduardoJM / sat_5.js
Created July 11, 2020 18:07
Separating Axis Theorem Polygon in Axis Projection
polygon.projectInAxis = function(x, y) {
let min = 10000000000;
let max = -10000000000;
for (let i = 0; i < polygon.vertices.length; i++) {
let px = polygon.vertices[i].x;
let py = polygon.vertices[i].y;
var projection = (px * x + py * y) / (Math.sqrt(x * x + y * y));
if (projection > max) {
max = projection;
}
@EduardoJM
EduardoJM / sat_4.js
Created July 11, 2020 18:00
Separating Axis Theorem Polygon Render Method
polygon.render = function(context, color) {
context.strokeStyle = color;
context.beginPath();
context.moveTo(
polygon.vertices[0].x,
polygon.vertices[0].y
);
for (let i = 1; i < polygon.vertices.length; i++) {
context.lineTo(
polygon.vertices[i].x,
@EduardoJM
EduardoJM / sat_3.js
Created July 11, 2020 17:59
Separating Axis Theorem Polygon Offset
polygon.offset = function(dx, dy) {
for (let i = 0; i < polygon.vertices.length; i++) {
polygon.vertices[i] = {
x: polygon.vertices[i].x + dx,
y: polygon.vertices[i].y + dy,
};
}
};