Skip to content

Instantly share code, notes, and snippets.

View luizbills's full-sized avatar
🔴
I may be slow to respond.

Luiz Bills luizbills

🔴
I may be slow to respond.
View GitHub Profile
@luizbills
luizbills / code.js
Created July 20, 2024 23:04
hello world in litecanvas
litecanvas()
function update (dt) {
}
function draw () {
cls(0)
text(0, 0, 'Hello World')
}
@luizbills
luizbills / code.js
Created July 20, 2024 22:47
How to draw a line in the direction of a given angle
litecanvas()
let cx, cy, px, py, len=200
function resized () {
cx = CENTERX
cy = CENTERY
}
function update (dt) {
@luizbills
luizbills / style.css
Created July 14, 2024 22:10
CSS blink animation
#text {
animation: blink 1.5s linear infinite;
}
@keyframes blink {
0%,
100% {
opacity: 1;
}
50% {
@luizbills
luizbills / LICENSE
Last active July 12, 2024 01:47
Simple text dungeon crawl made in JavaScript
The MIT License (MIT)
Copyright © 2024 Luiz Bills
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOF
@luizbills
luizbills / catch-errors.js
Created July 7, 2024 19:18
Catch javascript errors
window.addEventListener('error', (e) => {
alert('Error:' + e.message)
return false
})
window.addEventListener('unhandledrejection', function (e) {
alert('Error (in promise): ' + e.reason)
})
@luizbills
luizbills / code.js
Created April 21, 2024 23:52
Draw a cube in canvas #litecanvas
litecanvas()
function init () {
loadScript('https://unpkg.com/@litecanvas/plugin-more-shapes/dist/dist.js', (res) => {
if (res) plugin(pluginMoreShapes)
})
size = 100
x = WIDTH/2 - size/2
y = HEIGHT/2 - size/2
@luizbills
luizbills / code.js
Created April 9, 2024 02:12
move points towards a angle #litecanvas #gamedev
litecanvas();
const max = 3
const dist = 360 / max
function init () {
x = CENTERX
y = CENTERY
a = 0
}
@luizbills
luizbills / code.php
Created February 14, 2024 16:58
Make a woocommerce coupon valid only in certain period of the day
<?php
/**
* @param bool $is_valid
* @param \WC_Coupon $coupon Coupon data.
* @return bool
*/
add_filter( 'woocommerce_coupon_is_valid', function ( $is_valid, $coupon ) {
if ( ! $is_valid ) return false;
@luizbills
luizbills / readme.md
Created December 14, 2023 23:20 — forked from xem/readme.md
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;

@luizbills
luizbills / main.php
Last active December 2, 2023 16:58
Custom shipping method for WooCommerce (minimal boilerplate required)
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
// Hooks
add_action( 'plugins_loaded', 'yourprefix_include_shipping_method' );
add_action( 'woocommerce_shipping_methods', 'yourprefix_register_shipping_method' );