Beta 0.1 DUAL SPRITES for NFLIB


/ Published in: C
Save to your folder(s)

Beta 1 of my fuctions.


Copy this code and paste it in your HTML
  1. int Ancho[128];
  2. int Alto[128];
  3.  
  4. bool screen;
  5.  
  6. #define UP true
  7. #define DOWN false
  8.  
  9. #define ERROR {consoleDemoInit();iprintf("ERROR");while(1){swiWaitForVBlank();}}
  10.  
  11. void ODI_CreateDualSprite (uint8_t id , uint8_t gfx, uint8_t pal, uint8_t ancho, uint8_t alto) /*Será el mismo arriba que abajo*/
  12. {
  13. NF_CreateSprite(0, id, gfx, pal, 0, 0);
  14. NF_CreateSprite(1, id, gfx, pal, 0-ancho, 0-alto);
  15. Ancho[id] = ancho;
  16. Alto[id] = alto;
  17. }
  18.  
  19. void ODI_MoveDualSprite (uint8_t id, int x, int y )
  20. {
  21. if (x < 0-Ancho[id])ERROR;
  22. if (x > 256)ERROR;
  23. if (y < 0-Alto[id])ERROR;
  24. if (y > 384)ERROR;
  25.  
  26. if (y <= 191)screen = UP;
  27. else if (y >= 192)screen = DOWN;
  28.  
  29. if (screen == UP)
  30. {
  31. NF_MoveSprite(0,id,x,y-192);
  32. NF_MoveSprite(1,id,0-Ancho[id],0-Alto[id]);
  33. }
  34. else if (screen == DOWN)
  35. {
  36. NF_MoveSprite(1,id,x,y-192);
  37. NF_MoveSprite(0,id,0-Ancho[id],0-Alto[id]);
  38. }
  39. }
  40.  
  41. void ODI_DualSpriteLayer (uint8_t id, uint8_t layer)
  42. {
  43. NF_SpriteLayer( 0,id,layer);
  44. NF_SpriteLayer( 1,id,layer);
  45. }
  46.  
  47. void ODI_ShowDualSprite (uint8_t id, bool show )
  48. {
  49. NF_ShowSprite(0,id,show);
  50. NF_ShowSprite(1,id,show);
  51. }
  52.  
  53. void ODI_DualSpriteHflip (uint8_t id, bool hflip)
  54. {
  55. NF_HflipSprite(0,id,hflip);
  56. NF_HflipSprite(1,id,hflip);
  57. }
  58.  
  59. void ODI_DualSpriteVflip (uint8_t id, bool vflip)
  60. {
  61. NF_VflipSprite(0,id,vflip);
  62. NF_VflipSprite(1,id,vflip);
  63. }
  64.  
  65. void ODI_DualSpriteFrame (uint8_t id, uint8_t frame )
  66. {
  67. NF_SpriteFrame(0,id,frame);
  68. NF_SpriteFrame(1,id,frame);
  69. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.