Profile picture Über mich

sebadorn | blog

js13kGames: Tricks applied in Risky Nav

Game DevInformatik
0

Risky Nav

From the 13th August to the 13th September I participated in the js13kGames competition. My entry Risky Nav can be seen here and the source code is on GitHub here. In this blog post I will explain some of the tricks and techniques I used in making my game.

The game is tile based, so everything – player, monsters, goal – is always positioned at a (x, y) position on a 2D map.

About the background

The background is a single image which is created once right at the beginning. It is drawn on a canvas and each tile is 1px big. In the rendering loop it is then up-scaled to the desired tile size. To avoid a blurry image, it is necessary to disable anti-aliasing.

context.imageSmoothingEnabled = false;

let w = bgCanvas.width * tileWidth;
let h = bgCanvas.height * tileHeight;

function renderLoop() {
    context.drawImage( bgCanvas, 0, 0, w, h );
}

About the fog/shadow

The fog/shadow around the player is done in a similar way as the background. The image is pre-rendered with each tile being 1px and then up-scaled in the main loop. But it moves with the player. The darkness is determined by the euclidean distance from the player.

for( let y = 0; y < fogMapHeight; y++ ) {
    for( let x = 0; x < fogMapWidth; x++ ) {
        // Euclidean distance from origin.
        let de = Math.sqrt( x * x + y * y );

        // Darkness only starts 2 tiles away from the player.
        // f has to be a value between 0 and 1.
        let f = ( de < 2 ) ? 0 : Math.min( 1.15 - Math.min( 3 / de, 1 ), 1 );
        fogCtx.fillStyle = `rgba(0,0,0,${f})`;
        fogCtx.fillRect( x, y, 1, 1 );
    }
}
Read more

Using NW.js to communicate with a DS4 controller

Informatik
0

DS4 green light

NW.js still provides the Chrome Apps API which has been removed from Chrome, but not ChromeOS. This will allow us to access in a platform-independant manner devices which are connected with the PC per USB.

Without this API, a 3rd party Node.js module like node-hid could be used. This will however come with platform-dependant libraries and will have to be updated or rebuild each time the Node.js version changes.

This article concentrates on sending data to the controller. However it is also possible to retrieve data like pressed buttons using the established connection. Aside from using chrome.hid there is also the Gamepad API for read-only access.

Identifying the controller

First we need a way to identify the DS4. Devices come with a vendor Id and product Id. According to the Gentoo Wiki they are as follows:

Device Vendor Id Product Id
DS4 (1st gen) hex 054C / dec 1356 hex 05C4 / dec 1476
DS4 (2nd gen) hex 054C / dec 1356 hex 09CC / dec 2508

Having tested with both devices, I can also confirm the Ids.

Get the device

For all communication with the device, we will use the chrome.hid API. First we define a filter using the vendor and product Id, and then query the available devices:

var filter = {
    filter: [
        { vendorId: 1356, productId: 1476 },
        { vendorId: 1356, productId: 2508 }
    ]
};

chrome.hid.getDevices( filter, ( devices ) => {
    // Error handling.
    if( chrome.runtime.lastError ) {
        console.error( chrome.runtime.lastError );
        return;
    }
    if( !devices ) {
        return;
    }

    var device = devices[0];
    // Next: Connect to the device.
};
Read more

Minecraft: Tastaturprobleme unter Ubuntu [inkl. Lösung]

Informatik
12

Minecraft

Das Problem

Bei mir läuft immer noch der IBus nebenher, da ich gelegentlich auch mal etwas auf Japanisch eintippen möchte[1]. Dummerweise gibt es scheinbar einen Bug[2] zwischen IBus und gewissen Java-Komponenten, wegen dem dann Tastaturereignisse – sprich: Tastendrücke – nicht an die Java-Anwendung weitergereicht werden. Aufgefallen ist mir das bisher in Minecraft.

Bevor ich zur Lösung komme (wer es eilig hat, liest das hier vermutlich ohnehin nicht und scrollt direkt zum Code), ein paar Hinweise. Zum Einen sollte – auch auf Empfehlung von Notch hin[3] – nicht das standardmäßige OpenJDK benutzt werden, sondern Suns JVM. Im Weiteren setze ich auch voraus, dass diese als Default für den Befehl javagesetzt wurde:

sudo update-java-alternatives -s java-6-sun

Der andere Hinweis ist, IBus aktuell zu halten. Obgleich es bisher nicht zur Behebung des Fehlers beitragen konnte. Wie man stets aktuell bleibt, steht auf der IBus-Projektseite.

Read more

[Review] Katanagatari

Anime & Manga
8

Katangatari

GenresAdventure, Drama, Romance
VorlageLight Novel
Episoden12 Folgen à 50 Minuten
StudioWhite Fox
Jahr2010
Opening 1Meiya Kadenrou von Minami Kuribayashi (youtube.com)
Opening 2Katana to Saya von ALI PROJECT (youtube.com)
Endings12 verschiedene
Read more

If you watch this film backwards …

2

Die Backflip-Meme ist das chronologisch umgekehrte Betrachten einer Story. Angefangen hat es auf reddit und wird unter anderem bei Twitter (#backflicks, #backgames) weitergeführt.

If you watch the movie Jaws backwards, it’s a movie about a shark that keeps throwing up people until they have to open a beach.

If you watch LOST backwards you realize it’s the same thing as if you would watch it forward.

If you watch The Curious Case of Benjamin Button backwards it’s about a normal person.

Super Mario Land: Klempner verlässt seine Frau Daisy um Monster in Ebenbilder von ihr zu verwandeln und stöhnt dabei ‚Oh Daisy‘.

Via Nerdcore.


Wem auch ein Backflip einfällt, kann ihn gerne in die Kommentare schreiben.