Skip to content

Instantly share code, notes, and snippets.

@nandakoryaaa
nandakoryaaa / main.rs
Created June 23, 2025 11:00
Implementing display object list, drawabe & behaviour traits for abstract game in Rust
#[derive (Copy, Clone)]
struct Rect {
w: u32,
h: i32
}
struct Renderer {
canvas: u32 // not used
}
@nandakoryaaa
nandakoryaaa / 5_utf16.c
Created June 11, 2025 15:56
A simple game of guessing 5-letter Russian words (final)
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <process.h>
#include <time.h>
#include <string.h>
#include <windows.h>
#define LETTER_CNT 5
@nandakoryaaa
nandakoryaaa / rus5.txt
Created June 10, 2025 15:00
A list of 5-letter Russian words
абака
аббат
абвер
абзац
аборт
абрек
абрис
абхаз
абцуг
абшид
@nandakoryaaa
nandakoryaaa / dict.c
Last active June 10, 2025 15:01
Tree-based word dictionary as a prototype for 5-letter guessing game
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <windows.h>
#define LETTER_CNT 5
#define DICT_NODE_CNT 16384
#define DICT_NIL 16384
@nandakoryaaa
nandakoryaaa / 5_utf16.c
Created June 7, 2025 10:24
A game of guessing 5-letter Russian words - now with Windows Unicode support
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <process.h>
#include <time.h>
#include <string.h>
#include <windows.h>
#define LETTER_CNT 5
@nandakoryaaa
nandakoryaaa / 5.c
Created June 3, 2025 09:17
A game of guessing 5-letter words (prototype)
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <process.h>
#include <time.h>
#include <string.h>
#define LETTER_CNT 5
typedef enum {
@nandakoryaaa
nandakoryaaa / rotate.c
Last active February 14, 2025 22:44
Bitmap rotation in C + SDL2 using Bresenham lines
#define SDL_MAIN_HANDLED
#include <SDL2/SDL.h>
#include <stdio.h>
#include <stdint.h>
#include <math.h>
#define SURF_W 640
#define SURF_H 640
@nandakoryaaa
nandakoryaaa / png2font.php
Last active March 22, 2023 21:41
convert raster font image to array of bitmask bytes
<?php
$infile = $argv[1]; // font image file name
$w = $argv[2]; // font char width
$h = $argv[3]; // font char height
$color_x = $argv[4] ?? 0; // x coordinate of font color sample
$color_y = $argv[5] ?? 0; // y coordinate of font color sample
$img = imagecreatefrompng($infile);
$img_w = imagesx($img);
$img_h = imagesy($img);
@nandakoryaaa
nandakoryaaa / apple.rs
Created March 16, 2023 18:19
Apple game initial implementation
extern crate sdl2;
use sdl2::rect::Rect;
use sdl2::pixels::Color;
use sdl2::render::WindowCanvas;
use std::time::Duration;
trait Renderer {
fn render(
& self, canvas: & mut WindowCanvas,
@nandakoryaaa
nandakoryaaa / merge_sort_bingo.py
Last active February 16, 2023 22:02
Merge sort implementing true external sequential file/stream emulation
def read_chunk(dst, src, chunk_size, pos, len_src):
while chunk_size > 0 and pos < len_src:
dst.append(src[pos])
pos += 1
chunk_size -= 1
return pos
def get_bingo_size(pos, chunk_size, len_src):
if pos + chunk_size > len_src:
return len_src - pos