Advertisement
Guest User

Untitled

a guest
Dec 12th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  1. #include <mokki.h>
  2.  
  3. int board_x = 10;
  4. int board_y = 20;
  5.  
  6. int chooser_col = 0;
  7. int chooser_row = 0;
  8.  
  9. int last_btn_state[8] = {0, 0, 0, 0, 0, 0, 0, 0};
  10. int now_btn_state[8] = {0, 0, 0, 0, 0, 0, 0, 0};
  11.  
  12. int draw_rect(int x, int y, int w, int h, int col) {
  13. for (int j=y; j<y+h; j++) {
  14. for (int i=x; i<x+w; i++) {
  15. gfx_set_pixel(i, j, col);
  16. }
  17. }
  18. }
  19.  
  20. int draw_board() {
  21. // first vertical line
  22. draw_rect(board_x+12, board_y+0, 5, 46, COLOR_WHITE);
  23. // second vertical line
  24. draw_rect(board_x+29, board_y+0, 5, 46, COLOR_WHITE);
  25. // first horizontal line
  26. draw_rect(board_x+0, board_y+12, 46, 5, COLOR_WHITE);
  27. // second horizontal line
  28. draw_rect(board_x+0, board_y+29, 46, 5, COLOR_WHITE);
  29. }
  30.  
  31. int draw_chooser(int column, int row){
  32. draw_rect(
  33. board_x + column * 17 + 2,
  34. board_y + row * 17 + 2,
  35. 8, 8, COLOR_DARKGRAY
  36. );
  37. }
  38.  
  39. int main(int event, void* data) {
  40. for (int i=0; i<8; i++) {
  41. now_btn_state[i] = btn_get(i);
  42. }
  43.  
  44. while(1) {
  45. for (int i=0; i<8; i++) {
  46. last_btn_state[i] = now_btn_state[i];
  47. now_btn_state[i] = btn_get(i);
  48. }
  49.  
  50. if ( now_btn_state[3]==1 && last_btn_state[3]==0 ) {
  51. if (chooser_col < 2) {
  52. chooser_col++;
  53. }
  54. }
  55. if ( now_btn_state[2]==1 && last_btn_state[2]==0 ) {
  56. chooser_col--;
  57. }
  58.  
  59. gfx_clear();
  60. draw_board();
  61. draw_chooser(chooser_col, chooser_row);
  62. gfx_update();
  63. }
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement