Discussion about software development for the old-school Gameboys, ranging from the "Gray brick" to Gameboy Color
(Launched in 2008)
You are not logged in.
Hey!
I am Combou and i am new in this forum.I was searching for a way to create and move sprites, so i found that: http://gbdk.sourceforge.net/doc/html/c0504.html
There is some useful commands there, but i don't know how to use them.I was wondering if someone could help me.
I already know how to create a background and move it.If you don't know, i can try to help you
I will make a txt tutorial if I find out how to do it.
Sorry for bad english, i am from Brazil
Thanks!
Offline
Your looking for move_sprite() and scroll_sprite().
move_sprite(number_of_sprite_to_move, new_x_coordinate, new_y_coordinate) - This will move the specified sprite to (X,Y) on the screen (i.e. an absolute move).
scroll_sprite(number_of_sprite_to_move, move_on_x_axis_this_much, move_on_y_axis_this_much) - This will move the sprite based on it's current location (i.e. a relative move).
Offline
Cool!
But you know how to declare a sprite? Like using: set_sprite_tile()
Thanks!
Offline
First, load your sprite datas like you would do for tiles data :
set_sprite_data(UBYTE first_tile, UBYTE number_of_tiles, unsigned char *data);
Then, you have to choose if you want 8*8 or 8*16 sprites. You can do so with :
SPRITES_8x8 or SPRITES_8x16
And after that, set your sprites from previously loaded datas :
set_sprite_tile(UBYTE sprite_number, UBYTE tile_number);
Offline
#include <gb/gb.h>
#include <stdio.h>
#include <rand.h>
unsigned char bgtiles1[] =
{
0x00,0xFF,0x20,0xFF,0x42,0xFF,0x04,0xFF,
0x00,0xFF,0x28,0xFF,0x40,0xFF,0x00,0xFF,
0x00,0xFF,0x7E,0xFF,0x7E,0xFF,0x5A,0xDB,
0x7E,0xFF,0x7E,0xFF,0x7E,0xFF,0x3C,0xFF,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0x7E,0xFF,0x66,0xFF,0x66,0xFF,0x66,0xFF,
0x66,0xFF,0x66,0xFF,0x66,0xFF,0x66,0xFF
};
unsigned char playertiles1[] =
{
0x00,0xFF,0x7E,0xFF,0x7E,0xFF,0x5A,0xDB,
0x7E,0xFF,0x7E,0xFF,0x7E,0xFF,0x3C,0xFF
};
unsigned char bgmap1[] =
{
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
0x00,0x02,0x00,0x02,0x00,0x02,0x00,0x02,0x00,0x02,
0x00,0x02,0x00,0x02,0x00,0x02,0x00,0x02,0x00,0x02,
0x00,0x03,0x00,0x03,0x00,0x03,0x00,0x03,0x00,0x03,
0x00,0x03,0x00,0x03,0x00,0x03,0x00,0x03,0x00,0x03,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
0x00,0x02,0x00,0x02,0x00,0x02,0x00,0x02,0x00,0x02,
0x00,0x02,0x00,0x02,0x00,0x02,0x00,0x02,0x00,0x02,
0x00,0x03,0x00,0x03,0x00,0x03,0x00,0x03,0x00,0x03,
0x00,0x03,0x00,0x03,0x00,0x03,0x00,0x03,0x00,0x03,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
0x00,0x02,0x00,0x02,0x00,0x02,0x00,0x02,0x00,0x02,
0x00,0x02,0x00,0x02,0x00,0x02,0x00,0x02,0x00,0x02,
0x00,0x03,0x00,0x03,0x00,0x03,0x00,0x03,0x00,0x03,
0x00,0x03,0x00,0x03,0x00,0x03,0x00,0x03,0x00,0x03,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
};
int main(){
set_bkg_data(0, 4, bgtiles1);
set_bkg_tiles(0, 0, 20, 18, bgmap1);
move_bkg(0, 0);
set_sprite_data(1, 1, bgtiles1);
SPRITES_8x8;
set_sprite_tile(1, 1);
move_sprite(1, 10, 12);
SHOW_BKG;
DISPLAY_ON;
return 0;
}
The sprite is not appearing...What did I miss?
Offline
I forgot to mention that you need to use SHOW_SPRITES as for the background and the window x)
Offline
Thanks.
So i have to use set_win_data() and stuff like that?
Offline
If you don't want to display the window, there's no need to use it.
Offline