main.c 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. #include <tice.h>
  2. #include <graphx.h>
  3. #include <keypadc.h>
  4. #include "gfx/main_gfx.h"
  5. gfx_sprite_t* sprite;
  6. float scale = 3;
  7. int max_width = LCD_WIDTH;
  8. int max_height = LCD_HEIGHT;
  9. kb_key_t arrows;
  10. int x = 0;
  11. int y = 0;
  12. int frame = 0;
  13. void draw_sprite(){
  14. gfx_FillScreen(0);
  15. gfx_ScaledSprite_NoClip(sprite, x, y, scale, scale);
  16. gfx_BlitBuffer();
  17. }
  18. int main(void){
  19. if(bm3->height > bm5->height){
  20. max_height -= bm3->height * scale;
  21. }else{
  22. max_height -= bm5->height * scale;
  23. }
  24. if(bm11->width > bm13->width){
  25. max_width -= bm11->width * scale;
  26. }else{
  27. max_width -= bm13->width * scale;
  28. }
  29. gfx_Begin();
  30. gfx_SetPalette(main_palette, sizeof_main_palette, 0);
  31. gfx_SetDrawBuffer();
  32. draw_sprite();
  33. do{
  34. sprite = bm1;
  35. kb_Scan();
  36. arrows = kb_Data[7];
  37. if(arrows & kb_Down){
  38. if(y < max_height){
  39. y++;
  40. if(frame > 2){
  41. sprite = bm3;
  42. }else{
  43. sprite = bm5;
  44. }
  45. }
  46. }else if(arrows & kb_Up){
  47. if(y > 0){
  48. y--;
  49. if(frame > 2){
  50. sprite = bm15;
  51. }else{
  52. sprite = bm17;
  53. }
  54. }
  55. }
  56. if(arrows & kb_Right){
  57. if(x < max_width){
  58. x++;
  59. if(frame > 2){
  60. sprite = bm11;
  61. }else{
  62. sprite = bm13;
  63. }
  64. }
  65. }else if(arrows & kb_Left){
  66. if(x > 0){
  67. x--;
  68. if(frame > 2){
  69. sprite = bm7;
  70. }else{
  71. sprite = bm9;
  72. }
  73. }
  74. }
  75. draw_sprite();
  76. frame++;
  77. if(frame > 5){
  78. frame = 0;
  79. }
  80. }while (arrows != sk_Enter);
  81. gfx_End();
  82. return 0;
  83. }