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 / gameboy.md
Last active September 16, 2024 13:44
Game Boy Resolutions

Game Boy Resolutions

Game Boy (classic) and Game Boy Color

160x144 pixels (10:9 aspect ratio)

Game Boy Advance

240x160 pixels (3:2 aspect ratio)

@luizbills
luizbills / code.js
Created September 7, 2024 17:01
How to create a tiled background image in litecanvas
let bg, tile
litecanvas()
function init() {
loadImage('https://placehold.co/128', (res) => {
tile = res
bg = paint(WIDTH, HEIGHT, () => {
// cache the tiled image
tiled(0, 0, WIDTH, HEIGHT, tile)
@luizbills
luizbills / code.js
Last active August 12, 2024 14:08
hello world in litecanvas
litecanvas()
function draw () {
cls(0)
text(0, 0, 'Hello World')
}
@luizbills
luizbills / code.js
Last active August 12, 2024 14:07
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 tap(tapx, tapy) {
@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
Last active August 12, 2024 14:04
Draw a cube in canvas #litecanvas
litecanvas()
function init () {
loadScript('https://unpkg.com/@litecanvas/plugin-more-shapes/dist/dist.js', (res) => {
if (res) use(pluginMoreShapes)
})
size = 100
x = WIDTH/2 - size/2
y = HEIGHT/2 - size/2
@luizbills
luizbills / code.js
Last active August 12, 2024 14:03
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;