This file contains hidden or 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
| const checkCollision = (p1x, p1y, r1, p2x, p2y, r2) => ((r1 + r2) ** 2 > (p1x - p2x) ** 2 + (p1y - p2y) ** 2) | |
| var collision = checkCollision(5, 500, 10, 1000, 1500, 1500); | |
| console.log(collision); |
This file contains hidden or 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
| using UnityEngine; | |
| public class EnemySpawner : MonoBehaviour | |
| { | |
| public GameObject enemyPrefab; | |
| public Transform[] spawnPoints; | |
| public float spawnInterval = 2.0f; | |
| private float spawnTimer = 0.0f; |
This file contains hidden or 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
| // object to css | |
| Object.prototype.css = function() {return Object.entries(this).map(([k, v]) => `${k}:${v}`).join(';')} | |
| // css to object | |
| String.prototype.obj = function() { | |
| let obj = {} | |
| let parts = this.split(";") | |
| for(let part of parts){ | |
| let prop = part.split(':') | |
| obj[prop[0]] = prop[1] |
This file contains hidden or 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
| // Is x really array? | |
| Array.isArray(x) | |
| // Add array y to the end of x | |
| x.concat(y) | |
| // Is y in x? | |
| x.includes(y) | |
| // Which index is y? |
This file contains hidden or 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
| { | |
| "keys": { | |
| "0": "C-1", | |
| "1": "C#-1", | |
| "2": "D-1", | |
| "3": "D#-1", | |
| "4": "E-1", | |
| "5": "F-1", | |
| "6": "F#-1", | |
| "7": "G-1", |
This file contains hidden or 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
| <script> | |
| const hex = (d) => Number(d).toString(16).padStart(2, '0') | |
| const rnd = () => Math.floor(Math.random() * 256) | |
| let color = hex(rnd()) + hex(rnd()) + hex(rnd()) | |
| const gen = () => color = hex(rnd()) + hex(rnd()) + hex(rnd()) | |
| </script> | |
| <style> | |
| .color{display:inline-block; padding:24px; border-radius:50px; vertical-align: middle;} | |
| .text{display:inline-block; font-size:24px; vertical-align: middle;} |
This file contains hidden or 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
| const hex = (num) => num.toString(16).padStart(2, '0') | |
| const num = (hex) => parseInt(hex, 16) |
This file contains hidden or 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
| extends RigidBody2D | |
| var f = 500 | |
| func _ready(): | |
| apply_central_impulse(Vector2(rand_range(-f, f),rand_range(-f,f))) |
This file contains hidden or 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
| var context = new AudioContext(); | |
| var oscillator = context.createOscillator(); | |
| var gainNode = context.createGain(); | |
| oscillator.connect(gainNode); | |
| gainNode.connect(context.destination) | |
| oscillator.start(); | |
| stopButton.addEventListener('click', function() { |
This file contains hidden or 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
| from mido import MidiFile | |
| tempo=0 | |
| noteons = [] | |
| notas = [] | |
| mid = MidiFile('C:/scripts-python/meow.mid') | |
| for evt in mid: | |
| if not evt.is_meta: | |
| tempo += evt.time | |
| if evt.type == 'note_on': |
NewerOlder