Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <mokki.h>
- int board_x = 10;
- int board_y = 20;
- int chooser_col = 0;
- int chooser_row = 0;
- int last_btn_state[8] = {0, 0, 0, 0, 0, 0, 0, 0};
- int now_btn_state[8] = {0, 0, 0, 0, 0, 0, 0, 0};
- int draw_rect(int x, int y, int w, int h, int col) {
- for (int j=y; j<y+h; j++) {
- for (int i=x; i<x+w; i++) {
- gfx_set_pixel(i, j, col);
- }
- }
- }
- int draw_board() {
- // first vertical line
- draw_rect(board_x+12, board_y+0, 5, 46, COLOR_WHITE);
- // second vertical line
- draw_rect(board_x+29, board_y+0, 5, 46, COLOR_WHITE);
- // first horizontal line
- draw_rect(board_x+0, board_y+12, 46, 5, COLOR_WHITE);
- // second horizontal line
- draw_rect(board_x+0, board_y+29, 46, 5, COLOR_WHITE);
- }
- int draw_chooser(int column, int row){
- draw_rect(
- board_x + column * 17 + 2,
- board_y + row * 17 + 2,
- 8, 8, COLOR_DARKGRAY
- );
- }
- int main(int event, void* data) {
- for (int i=0; i<8; i++) {
- now_btn_state[i] = btn_get(i);
- }
- while(1) {
- for (int i=0; i<8; i++) {
- last_btn_state[i] = now_btn_state[i];
- now_btn_state[i] = btn_get(i);
- }
- if ( now_btn_state[3]==1 && last_btn_state[3]==0 ) {
- if (chooser_col < 2) {
- chooser_col++;
- }
- }
- if ( now_btn_state[2]==1 && last_btn_state[2]==0 ) {
- chooser_col--;
- }
- gfx_clear();
- draw_board();
- draw_chooser(chooser_col, chooser_row);
- gfx_update();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement