main.c 2.0 KB

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