Love2d: Haxe: Ray-circle intersection test


HaxeNME version. Love2d version works equally to this.
Click and drag different parts for interaction.

By user request on Love2d IRC channel, yesterday I've made this nice function to do intersection/collision check between a ray (for clearance, here, a ray is a infinite line with starting point but no end point) and a circle.
Underlying code is fairly simple, though it does not even require understanding to use the function.
Love2d version takes advantage of multi-return values.
Haxe version has slightly longer code due for more optimal implementation of interface.

Download Haxe .hx
Download Love2d .love

Love2d: Semi-turn-based platformer

A very rushed Haxe version to demonstrate how it looks in motion.
Does not necessarily represent features of love2d version in this post.

This was originally going to be a short reply-fix for a topic on love2d forum, but it seems that author did get somewhere with figuring that out on ones own, and I've quite overdone it in terms of a simple answer, so I formatted the code nicely, added several more features, and made this example.

Just in case above demonstration does not work, this example demonstrates a specific approach to game dynamic, where game logic occurs once per interval, while things are drawn and receive input at higher rate. I do not recall any actual platformer games that would use this principle, but a good example of such game is Snake (original grid-based version).
Example includes grid-to-point collision checking, actual specific platformer behaviour (with adjustable values), and value tweening (to make player movement nice & smooth).

Download (2KB .love)

Lua: Serializer


Actually text has limited relation to that thing on right side

Today I wrote a serializer function for Lua. A brief research has shown that not too many people know what this should do in first place. So, to theory:
For example, you have this table definition:
local o = {
	1, 2, 3,
	one = 1,
	['Lua is'] = 'cool',
	[true] = true,
	{ 'this', 'is', 'a', 'table' }
}
At the time of 'compilation' (translation to VM bytecode) it is translated into non-textual representation that you can't tell a lot about, and probably should not worry about.
However, what if you want to get your modified table back, as text? That's where a bit of puzzle appears, since there isn't a standard routine to do that. And also where scope of using this function starts.
Continue reading

Love2d: A game in 8 minutes


A video.

Yesterday I've made a game in Love2d. In a bit over 8 minutes.
Originally I planned to get everything done in 5 minutes (similar to previous GameMaker-related post), however I somewhat overrated my ability to type 3-segment function names that I'm not that similar with.

Love2d: Shooting things


Simple

As it was asked few times, how exactly bullets are handled in love.blast(), I suppose that this deserves a separate post.
Thing to say about source of love.blast(), is that with great performance optimizations comes great complexity of code.
Thus, here things will stay simpler, and probably a bit slower, however you probably will not notice that until having thousands of bullets on screen at once.

Continue reading

Love2d: Platformer engine


Looks nice enough, right?

In free time of last days I've been developing earlier mentioned thing in Love2d, which is platformer engine.
One provides a simple framework for games that use combination of aligned tiles and dynamic objects.
As well it adds a easily modifiable system to load levels from strings, giving freedom for implementing level editors.

You can download a compiled version here or watch discussion thread on official forum here.

Love2d: Simple compilation to executable

While having a look at LÖVE engine, I've noticed that described compilation method under Windows is not quite fast or fun (because of requiring you to open console and type\paste project-specific code). So I've grabbed my semi-existing Batch coding skills and made a better one:
copy /b love.exe+%1 "%~dpn1.exe"
How to use this:
  1. Create a file called 'compile.bat' in the same directory with Love2d runner.
  2. Paste above code into it.
  3. To compile a game, drag it's .love\.zip onto your compile.bat - an executable (compiled game) will appear next to it, named after game's file.
That's it. Couldn't be easier.