gbadev
Game Boy Advance homebrew development forum
Member
Joined:
Posts: 2

My Code:

#include "bn_core.h"
#include "bn_log.h"
#include "bn_sprite_ptr.h"
#include "bn_sprite_items_egg.h"

int window_x = 240;
int window_y = 160;

int main()
{
    bn::core::init();
    bn::sprite_ptr egg_sprite = bn::sprite_items::egg.create_sprite(0, 0);
    int direction = 1;
    int speed = 1;

    while (true)
    {
        // how to print egg_sprite.x()

        if ((egg_sprite.x() >= window_x / 2))
            direction = -1;
        else if (egg_sprite.x() <= -window_x / 2)
            direction = 1;

        egg_sprite.set_x(egg_sprite.x() + speed * direction);
        bn::core::update();
     }
}

I tried bn::log(egg_sprite.x()); but it gave me this error: no suitable user-defined conversion from "bn::fixed" (aka "bn::fixed_t<12>") to "const bn::istring_base" exists.
I checked out the logging example for butano, but I was so confused and couldn't understand the code.
Thank you.

Administrator
avatar
Joined:
Posts: 49

Afska answered this on Discord but I'm putting it here for posterity:

The solution is to use the BN_LOG macro which is able to handle data types other than strings:

BN_LOG(egg_sprite.x());
Member
Joined:
Posts: 2

Yes, thank you.