Newer
Older
cneboy_games / test / test.c
@Mark Mark on 29 Jul 2022 919 bytes More bitmap tests
#include <client_api.h>
pbm_t* player;
int setup(int a)
{
    player = f_bitmap("/player.pbm");
    if (player) player->data[0] = 1 << 7;
    return 0;
}

float x = 0;
float y = 0;
int rot = 0;

float speed = 80;

bool flipX = false, flipY = false;


int loop(int ms)
{
    d_clear();
    if (player)
    {
        d_pbm((uint16_t)roundf(x), (uint16_t)roundf(y), player, 0, 0, 0, 0, BLACK, WHITE, rot, flipX, flipY);
    }
    if (button_pressed(BUTTON_A))
    {
        rot = (rot + 1) % 4;
    }
    if (button_pressed(BUTTON_B))
    {
        flipX = !flipX;
        if (!flipX)
        {
            flipY = !flipY;
        }
        printf("Flip: %d %d\n", flipX, flipY);
    }

    float t = ms / 1000.0f;
    if (button_down(DPAD_RIGHT)) x += t * speed;
    if (button_down(DPAD_LEFT)) x -= t * speed;
    if (button_down(DPAD_DOWN)) y += t * speed;
    if (button_down(DPAD_UP)) y -= t * speed;
    return 0;
}