Fast approximate arctan2/atan2 function

(click to interact)

Alternatively titled "exciting adventures in doing trigonometry without CRT".

Continue reading

C/C++: Making a very tiny DLL (in Visual Studio)

Having been making native extensions for GameMaker for years, there is one thing that always bothered me: although the code is often minimal (some of my smaller extensions have less than 100 lines of code!), the DLLs still come out to 70..100KB OR have to depend on Microsoft Visual C++ Runtime Redistributable, which is non-preferable for games that should "just run".

Having finally figured it out, I decided to write a small post about the matter.

Continue reading

GameMaker: Windows-specific functions for Studio

While working on one of recent projects, I've stumbled upon few common issues that many meet - even if you are only targeting Windows in GameMaker: Studio, you cannot access files outside the game's AppData directory (not even in program directory). Neither you can order system to open a file, meaning no external "readmes" to be easily hooked up with game, nor portable configuration files, and some other limitations.
So I took an evening and made a simplistic DLL library to bring equivalents to some functions (sleep, execute_shell, non-sandboxed I/O) back for Windows target. Function list is as following:

Continue reading

CPP – [busy] sleep() function via time.h

As you may know, there are multiple ways to create a sleep\delay function in C++.
These may appeal more or less to you depending on system and libraries available.
The following short function uses functionality of time.h header, which makes it useful for cases when dos.h is missing and you do not want to include windows.h just for a single function.

void sleep(int ms) {
	clock_t target = clock() + ms;
	while (clock() < target) { }
}