If I’m going to make a game, I’m relatively sure I’m going to need to understand sprites, those little graphics that animate and/or ping about the screen so you know what’s going on.

Handily there’s already a good tutorial for that, so I went through that with a couple of differences, rebel that I am.

I won’t reiterate the contents of the tutorial, but suffice to say that Gameboy Tile Designer is a neat tool and this whole process was an absolute doddle.

eBoy are safe… for now.

The tutorial ran like a dream (once I remembered to export the right number of tiles) and I made a slight variation in order to animate both 8×16 parts of the sprite (as the mouth covers both). I also added basic animation.

#include <gb/gb.h>
#include <gb/drawing.h>
#include "speaky.c"

void main() {
	int speaky_x = 75;
	int speaky_y = 75;
	SPRITES_8x16;
	set_sprite_data(0, 8, speaky);
	set_sprite_tile(0, 0);
	move_sprite(0, speaky_x, speaky_y);
	set_sprite_tile(1, 2);
	move_sprite(1, speaky_x + 8, speaky_y);
	SHOW_SPRITES;

	while(1){
		speaky_x++;
		speaky_y++;
		set_sprite_tile(0, 4);
		set_sprite_tile(1, 6);
		move_sprite(0, speaky_x, speaky_y);
		move_sprite(1, speaky_x + 8, speaky_y);
		delay(500);
		set_sprite_tile(0, 0);
		set_sprite_tile(1, 2);
		delay(500);
	}
}

Incidentally, the character is called “speaky” because I was considering making it open and close its mouth on keypress, making lines of dialog appear. However, with this movement it now reminds me more of something else…

Time Spent: About half an hour.

Leave a comment

Your email address will not be published.