Skip to content

Instantly share code, notes, and snippets.

View EncodeTheCode's full-sized avatar
💭
Coding useful tools for workflow.

EncodeTheCode

💭
Coding useful tools for workflow.
View GitHub Profile
import pygame
class BitmapFont:
def __init__(self, font_image, char_width, char_height):
self.font_image = pygame.image.load(font_image).convert()
self.char_width = char_width
self.char_height = char_height
self.font_image.set_colorkey((0, 0, 0)) # Black = transparent
self.char_map = self.build_char_map()
import pygame
class BitmapFont:
def __init__(self, font_image, char_width, char_height):
self.font_image = pygame.image.load(font_image).convert()
self.char_width = char_width
self.char_height = char_height
self.font_image.set_colorkey((0, 0, 0)) # Black background made transparent
# Define the mapping from characters to their index in the bitmap
import pygame
class BitmapFont:
def __init__(self, font_image, char_width, char_height, chars_per_row, chars_per_col):
self.font_image = pygame.image.load(font_image) # Load the bitmap font image
self.char_width = char_width # Width of each character
self.char_height = char_height # Height of each character
self.chars_per_row = chars_per_row # How many characters per row in the bitmap
self.chars_per_col = chars_per_col # How many characters per column in the bitmap
self.char_map = self.create_char_map() # Map each character to a grid position in the bitmap
import pygame
class BitmapFont:
def __init__(self, font_image, char_width, char_height, num_chars):
self.font_image = pygame.image.load(font_image) # Load the bitmap font image
self.char_width = char_width # Width of each character
self.char_height = char_height # Height of each character
self.num_chars = num_chars # Total number of characters in the bitmap
self.character_images = self.extract_characters() # Extract and process each character
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Top-down Shadows with Gradient Fading and Interactive Lighting</title>
<style>
body { margin: 0; background: #222; }
canvas { display: block; margin: auto; background: #333; }
</style>
</head>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Top-down Shadows with Gradient Fading and Interactive Lighting</title>
<style>
body { margin: 0; background: #222; }
canvas { display: block; margin: auto; background: #333; }
</style>
</head>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Top-down Shadows with Gradient Fading and Interactive Lighting</title>
<style>
body { margin: 0; background: #222; }
canvas { display: block; margin: auto; background: #333; }
</style>
</head>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Top-down Shadows with Gradient Fading and Interactive Lighting</title>
<style>
body { margin: 0; background: #222; }
canvas { display: block; margin: auto; background: #333; }
</style>
</head>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Top-down Shadows with Gradient Fading and Interactive Lighting</title>
<style>
body { margin: 0; background: #222; }
canvas { display: block; margin: auto; background: #333; }
</style>
</head>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Oval Wall Shadows</title>
<style>
body { margin: 0; background: #222; }
canvas { display: block; margin: auto; background: #333; }
</style>
</head>