So it turns out what I wrote was a fluke and wasn't correct at all then!
I have made this effort at correcting my code but it clearly has some work to be done yet as I don't see anything being drawn to the screen.
Yes, I'm just trying to move 1x 8x8 sprite around the screen. In one of you snippets you mention `sprites[3]` but I'm not sure what that is referring to, how your are intending that be instantiated.
Here is my latest attempt that builds but doesn't show anything. I used mysprites for the variable name in tileset.inc.
I think a working version of this would be make a good demo to include in the repo as a mid-point example between hello world and pong.
Code: Select all
#include <stdint.h>
#include <stdbool.h>
#include <avr/io.h>
#include <stdlib.h>
#include <string.h>
#include <avr/pgmspace.h>
#include <uzebox.h>
#include "data/tileset.inc"
int btnPrev = 0; // Previous button
int btnHeld = 0; // buttons that are held right now
int btnPressed = 0; // buttons that were pressed this frame
int btnReleased = 0; // buttons that were released this frame
struct PlayerStruct
{
u8 x;
u8 y;
u8 tileIndex;
u8 flags;
};
struct PlayerStruct Player;
int main()
{
ClearVram();
SetSpritesTileBank(0, mysprites);
Player.x = 100;
Player.y = 100;
Player.tileIndex = 1;
SetSpriteVisibility(true);
while(1){
WaitVsync(1);
btnHeld = ReadJoypad(0);
btnPressed = btnHeld & (btnHeld ^ btnPrev);
btnReleased = btnPrev & (btnHeld ^ btnPrev);
if(btnHeld & BTN_RIGHT){
Player.x+=3;
}
if(btnHeld & BTN_LEFT){
Player.x-=3;
}
if(btnHeld & BTN_UP){
Player.y-=3;
}
if(btnHeld & BTN_DOWN){
Player.y+=3;
}
btnPrev = btnHeld;
}
}