Skip to content

Instantly share code, notes, and snippets.

@YellowAfterlife
YellowAfterlife / pallete.cpp
Created May 19, 2013 18:43
Outputs a "pallete" of colors achievable via WinAPI SetConsoleTextAttribute
/// Outputs a "pallete" of colors achievable via WinAPI SetConsoleTextAttribute
/// Full article:
/// http://ru.yal.cc/cpp-colored-text-via-winapi/ (Russian)
/// http://yal.cc/cpp-colored-text-via-winapi/ (English)
#include <stdio.h>
#include <Windows.h>
int main(int argc, char* argv[]) {
// foreground and background flags:
int fb[4] = { FOREGROUND_RED, FOREGROUND_GREEN, FOREGROUND_BLUE, FOREGROUND_INTENSITY };
int bb[4] = { BACKGROUND_RED, BACKGROUND_GREEN, BACKGROUND_BLUE, BACKGROUND_INTENSITY };
@YellowAfterlife
YellowAfterlife / FTW.hx
Last active December 28, 2015 11:38 — forked from dpeek/FTW.hx
import haxe.macro.Expr;
import haxe.macro.Context;
class FTW {
public static function build() {
return haxe.macro.Context.getBuildFields().map(transformField);
}
static function transformField(field:Field) {
switch (field.kind) {
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.display.Graphics;
import flash.display.Sprite;
import flash.events.KeyboardEvent;
import flash.events.TimerEvent;
import flash.geom.Rectangle;
import flash.Lib;
import flash.text.TextField;
import flash.utils.Timer;
Turn 1:
o
o o
o . o
o o o o
o o o o o
Turn 2:
o
o o
o x o
@YellowAfterlife
YellowAfterlife / Main.hx
Last active August 29, 2015 13:57
Fluent (?) interface trick for Haxe.
using Main.Smartxin;
class A {
public var width:Int;
public function new() { }
}
class B extends A {
public var height:Int;
public function new() super();
@YellowAfterlife
YellowAfterlife / Main.hx
Last active July 4, 2020 08:43
Simplistic .properties parser
class Main {
static function parseProperties(text:String):Map<String, String> {
var map:Map<String, String> = new Map(),
ofs:Int = 0,
len:Int = text.length,
i:Int, j:Int,
endl:Int;
while (ofs < len) {
// find line end offset:
endl = text.indexOf("\n", ofs);
объявить поле(4)(4)(4) % поле с номерами пятнашек
объявить стр(2), стл(2) % строка, столбец
объявить симв(128) % массив символов
объявить а(8), б(8), к(8) % временные переменные
симв = #" 123456789ABCDEF"
поле(0)(0)= 0; поле(0)(1)= 1; поле(0)(2)= 2; поле(0)(3)= 3;
поле(1)(0)= 4; поле(1)(1)= 5; поле(1)(2)= 6; поле(1)(3)= 7;
поле(2)(0)= 8; поле(2)(1)= 9; поле(2)(2)=10; поле(2)(3)=11;
поле(3)(0)=12; поле(3)(1)=13; поле(3)(2)=14; поле(3)(3)=15;
игра:
dllx char* file_text_get(char* file) {
FILE *f;
char *r;
long fl;
fopen_s(&f, file, "r");
if (f) {
fseek(f, 0L, SEEK_END);
fl = ftell(f);
rewind(f);
if (r = (char*)calloc(1, fl + 1)) {
case "intro":
map([
[ 000, 031, 031, 031, 000, ],
[ 031, 014, 014, 031, ],
[ 031, 014, 184, 014, 184, ],
[ 031, 014, 014, 042, ],
[ 000, 031, 031, 031, 000, ],
[ 312, 000, 000, 000, ],
], 4);
put(2, 2);
--[[
1.118
1.411
5.35
]]--
function set_field(t, f, v)
t[f] = v
return v
end
local n = 10000000