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.
Hello, so I was following some tutorials to make meta-sprites, and well, it works at the way I wanted, it's a tennis game, shows up the 2 players, but when i tried to put the ball it replace the id from the player, I don't know if I'm skipping something or it's a GBDK bug, still I hope someone could help me
#include<gb/gb.h> #include<stdio.h> #include "uhoh.c" #include "tennis.c" #include "tennis_couch1.c" #include "GameCharacter.c" struct GameCharacter player; struct GameCharacter actor; struct GameCharacter ball; UBYTE spritesize = 8; void movegamecharacter(struct GameCharacter* character, UINT8 x, UINT8 y){ move_sprite(character->spritids[0], x, y); move_sprite(character->spritids[1], x + spritesize, y); } void setupplayer(){ player.x = 80; player.y = 130; player.width = 16; player.height = 8; set_sprite_tile(0, 0); player.spritids[0] = 0; set_sprite_tile(1, 1); player.spritids[1] = 1; movegamecharacter(&player, player.x, player.y); } void setupactor(){ actor.x = 80; actor.y = 30; actor.width = 16; actor.height = 8; set_sprite_tile(2, 2); actor.spritids[0] = 2; set_sprite_tile(3, 3); actor.spritids[1] = 3; movegamecharacter(&actor, actor.x, actor.y); } void setupball(){ ball.x = 80; ball.y = 130; ball.width = 8; ball.height = 8; set_sprite_tile(4, 4); ball.spritids[0] = 4; movegamecharacter(&ball, ball.x, ball.y); } void main(){ set_bkg_data(0, 12, tennis); set_bkg_tiles(0, 0, 20, 18, tennis_couch1); SHOW_BKG; DISPLAY_ON; set_sprite_data(0, 5, uhoh); setupplayer(); setupactor(); setupball(); SHOW_SPRITES; }
Last edited by l130 (2020-01-30 14:17:09)
Offline
And some screenshots, as you can see, the character is overlayed on the ball
https://imgur.com/a/IMAUvHh
Offline
It looks like your method "movegamecharacter" always moves 2 sprites. You're only initializing one for the ball, and so the other defaults to 0, thus moving the player sprite.
Offline
Thanks! Now it works well
Offline