Sprites not showing even though everything seems to be fine (using NightFox's Lib)

theMADturtle

New Member
OP
Newbie
Joined
Feb 18, 2023
Messages
1
Trophies
0
Age
17
XP
24
Country
Israel
here is my code, I basically want a simple sprite with some top down movement, but I just can't make sprite show up on screen.

C++:
#include <nds.h>
#include <gl2d.h>
#include <stdio.h>
#include <nf_lib.h>
#include <nf_sprite256.h>

//player vars
float playerX = 0;
float playerY = 0;
int playerW = 16;
int playerH = 16;
int playerSpeed = 2;

void playerMovement(){
        //moves the player
        u32 keysDown = keysHeld();
        
        if (keysDown & (KEY_LEFT | KEY_RIGHT | KEY_UP | KEY_DOWN)) {
            if (keysDown & KEY_LEFT) {
                playerX-=playerSpeed;
            } else if (keysDown & KEY_RIGHT) {
                playerX+=playerSpeed;
            } else if (keysDown & KEY_DOWN) {
                playerY+=playerSpeed;
            } else if (keysDown & KEY_UP) {
                playerY-=playerSpeed;
            }
        }
        if(keysDown){
            if (keysDown & KEY_UP){
                if (keysDown & KEY_RIGHT){
                    playerY-=playerSpeed/2;
                    playerX+=playerSpeed/8;
                }
            }
            if (keysDown & KEY_UP){
                if (keysDown & KEY_LEFT){
                    playerY-=playerSpeed/2;
                    playerX-=playerSpeed/8;
                }
            }
            if (keysDown & KEY_DOWN){
                if (keysDown & KEY_RIGHT){
                    playerY+=playerSpeed/2;
                    playerX+=playerSpeed/8;
                }
            }
            if (keysDown & KEY_DOWN){
                if (keysDown & KEY_LEFT){
                    playerY+=playerSpeed/2;
                    playerX-=playerSpeed/8;
                }
            }
        }
}

int main(void) {
    NF_SetRootFolder("NITROFS");
    NF_Set2D(0, 0);   
    swiWaitForVBlank();

    // Initialize the Tiled Sprites System on the Bottom Screen
    NF_InitSpriteBuffers();
    NF_InitSpriteSys(0);
    
     NF_LoadSpriteGfx("player",0,16,16);
    NF_LoadSpritePal("palette",0);
    
    NF_VramSpriteGfx(0,0,0,false);
    NF_VramSpritePal(0,0,0);
    
    NF_CreateSprite(0,0,0,0,playerX,playerY);
    NF_SpriteOamSet(0);
    swiWaitForVBlank();
    oamUpdate(&oamMain);
    while(1) {
        scanKeys();
        glBegin2D();
        
        //render player
        NF_CreateSprite(0,0,0,0,playerX,playerY);
        playerMovement();
        
        NF_SpriteOamSet(0);
        swiWaitForVBlank();
        oamUpdate(&oamMain);
    }
}
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
  • K3Nv2 @ K3Nv2:
    Crazy people actually spend $50 on that stuff
  • BigOnYa @ BigOnYa:
    Towelie runs my farm, he's awesome.
  • SylverReZ @ SylverReZ:
    @K3Nv2, Polly is still around from what I've heard.
  • K3Nv2 @ K3Nv2:
    @SylverReZ, is Pollys alt I knew it
  • BigOnYa @ BigOnYa:
    Yea I see him every once whi!e , incognito
  • SylverReZ @ SylverReZ:
    @K3Nv2, I'm not him. Keep looking.
    +1
  • K3Nv2 @ K3Nv2:
    Still don't know why he left unless someone really hurt his feelings
  • K3Nv2 @ K3Nv2:
    Don't know why people get so emotional online just get over it ffs
    +2
  • BigOnYa @ BigOnYa:
    He was the ass of gbatemp, everyone knocked on him, I honestly felt bad, even though I was guilty myself, but he egged it all on himself,
  • BigOnYa @ BigOnYa:
    But he still here, but under dif name, he pm me sometimes still even.
  • K3Nv2 @ K3Nv2:
    It's like they think we'll be in their bed pissing on it the next day
  • BigOnYa @ BigOnYa:
    I feel like gbatemp should make t-shirts or memorabilia to remember the lost ones. I bet the Polly shirts would sell out quick.
  • K3Nv2 @ K3Nv2:
    Nah that could actually bring lawsuits
  • K3Nv2 @ K3Nv2:
    Tempsuits
  • BigOnYa @ BigOnYa:
    PollySuits
  • BigOnYa @ BigOnYa:
    Your correct, Somebody would be guilty and there would be riots, then they storm the gbatemp capitol,
  • K3Nv2 @ K3Nv2:
    Online or not there are still certain rights that judges would have no issue handing out a warrant over
  • K3Nv2 @ K3Nv2:
    Just look at Kim dotcom
  • BigOnYa @ BigOnYa:
    Honestly I'm scared to, from you, but ok, lemme turn on vpn, virtual machine, private browser first
  • K3Nv2 @ K3Nv2:
    Remember that Alexa robot I gifted you
  • K3Nv2 @ K3Nv2:
    And that laptop Webcam you never tapped up
  • BigOnYa @ BigOnYa:
    That robot is here somewhere, I hear it moving around at night, but I haven't seen it for months.
  • BigOnYa @ BigOnYa:
    Oh that laptop I give to ancientboi, so you been watching him for months, and he's been watching you
  • K3Nv2 @ K3Nv2:
    Oh good more than enough material for the fbi
    +1
  • BigOnYa @ BigOnYa:
    Damn its 5 in morn, I gotta Go wake your mum and send her to work. Check ya later.
    BigOnYa @ BigOnYa: Damn its 5 in morn, I gotta Go wake your mum and send her to work. Check ya later.