Gameboy Development Forum

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.

Ads

#1 2016-10-30 21:45:36

neyen
New member
Registered: 2016-10-30
Posts: 1

GBDK Tutorial Issue - Background covering sprites

Hi, I recently found the wiki of this site and i'm trying to learn the basics of GBDK to make a video game for GB.

I have read this tutorial How to Write a Simple Side Scrolling Game in GBDK Written Really F**king Simply (sic) which is very interesting, but copying the source code of the tutorial and compiling it I got a game which shows the background map, but no sprites.

Changing some lines of code i found that adding an empty print in the function DoGameplay() the sprites are visible and the game actually works, but in this way the background map is not visible.

Code:

void DoGameplay(void)
    {
        
        Playing = 1; //Sets the UBYTE playing to 1, indicating that the game is playing.

        while(Playing == 1) {
        //This starts a loop so that while playing is equal to 1, the loop will continue to loop. If playing does not equal 1, the loop will stop.

        //Repeat the following steps for the game to play.

            UpdateJoypad(); //This procedure checks the joypad, and moves the players ship according to the results. It also updates the player's shot, if it has been shot, for lack of a better place of sticking it.

            UpdateBadGuy(); //This procedure moves the enemy.
            
            CollisionDetection(); //This is one of the most important procedures. It checks to see if the player has collided with the enemy, along with the player's shot colliding with the badguy.
    
            delay(10); //This is the game's master speed control. It doesn't affect the background scrolling, but does affect the badguy's speed, as well as how responsive the controls are.

            printf(" ");
        }
    }

How can I resolve this? I can post some parts of code if needed.

Offline

 

#2 2016-10-31 22:49:46

w00tguy
New member
Registered: 2016-09-08
Posts: 3

Re: GBDK Tutorial Issue - Background covering sprites

If adding a delay is changing graphics, then that probably means VRAM is being written to outside of VBlank/HBlank.

Make sure that the background and sprite updates happen immediately after VBlank starts, and that the CPU isn't doing more work than it has time for. BGB's CPU meter and VRAM visualizer can help you debug this.

Offline

 

#3 2016-11-18 18:51:13

rychan
Member
From: Paignton, Devon, UK
Registered: 2015-12-16
Posts: 103
Website

Re: GBDK Tutorial Issue - Background covering sprites

replace delay(10); with wait_vbl_done();

and you'll get a much truer representation of things.

Remove the printf(" ") also.

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2005 Rickard Andersson