Files
untitled2dshooter/src/main.c
2022-06-08 22:57:34 +01:00

52 lines
966 B
C

#include <gb/gb.h>
#include <stdlib.h>
#include "../res/tiles.h"
#include "../res/map.h"
#include"../res/sprites.h"
#include "./flags.h"
#include "./constants.h"
#include "./sprite.h"
#include "./vec.h"
void init_gfx()
{
// Load Background tiles and then map
set_bkg_data(0, 23, tiles);
set_bkg_tiles(0, 0, mapWidth, mapHeight, map);
set_sprite_data(0, 11, sprites);
set_sprite_tile(0, 2);
set_sprite_prop(0, 0);
// Turn the background map on to make it visible
SHOW_BKG;
SHOW_SPRITES;
}
void main(void)
{
unsigned int fc = 0;
struct Sprites sprite;
init_gfx();
sprite.pos.x = 72;
sprite.pos.y = 36;
sprite.vel.x = 0;
sprite.vel.y = 0;
sprite.acc.x = 0;
sprite.acc.y = 0;
move_sprite(0, sprite.pos.x, sprite.pos.y);
// Loop forever
while(1) {
fc++;
sprite_iter_frame(&sprite, map, joypad(), &fc);
move_sprite(0, sprite.pos.x, sprite.pos.y);
// Done processing, yield CPU and wait for start of next frame
wait_vbl_done();
}
}