Changeset a35b458 in mainline for uspace/dist/src/c/demos/tetris/scores.c
- Timestamp:
- 2018-03-02T20:10:49Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- f1380b7
- Parents:
- 3061bc1
- git-author:
- Jiří Zárevúcky <zarevucky.jiri@…> (2018-02-28 17:38:31)
- git-committer:
- Jiří Zárevúcky <zarevucky.jiri@…> (2018-03-02 20:10:49)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/dist/src/c/demos/tetris/scores.c
r3061bc1 ra35b458 99 99 { 100 100 int i; 101 101 102 102 clear_screen(); 103 103 moveto(10, 0); 104 104 printf("\tRank \tLevel \tName\t points\n"); 105 105 printf("\t========================================================\n"); 106 106 107 107 for (i = 0; i < NUMSPOTS - 1; i++) 108 108 printf("\t%6d %6d %-16s %20d\n", 109 109 i + 1, scores[i].hs_level, scores[i].hs_name, scores[i].hs_score); 110 110 111 111 if (!firstgame) { 112 112 printf("\t========================================================\n"); … … 114 114 scores[NUMSPOTS - 1].hs_level, scores[NUMSPOTS - 1].hs_name, scores[NUMSPOTS - 1].hs_score); 115 115 } 116 116 117 117 printf("\n\n\n\n\tPress any key to return to main menu."); 118 118 getchar(); … … 126 126 cons_event_t ev; 127 127 kbd_event_t *kev; 128 128 129 129 clear_screen(); 130 130 moveto(10, 10); … … 134 134 i = 6; 135 135 off = 6; 136 136 137 137 moveto(10 , 28); 138 138 printf("%s%.*s", scores[NUMSPOTS - 1].hs_name, MAXLOGNAME-i, 139 139 "........................................"); 140 140 141 141 while (1) { 142 142 console_flush(console); 143 143 if (!console_get_event(console, &ev)) 144 144 exit(1); 145 145 146 146 if (ev.type != CEV_KEY || ev.ev.key.type == KEY_RELEASE) 147 147 continue; 148 148 149 149 kev = &ev.ev.key; 150 150 151 151 if (kev->key == KC_ENTER || kev->key == KC_NENTER) 152 152 break; 153 153 154 154 if (kev->key == KC_BACKSPACE) { 155 155 if (i > 0) { 156 156 wchar_t uc; 157 157 158 158 --i; 159 159 while (off > 0) { … … 165 165 break; 166 166 } 167 167 168 168 scores[NUMSPOTS - 1].hs_name[off] = '\0'; 169 169 } … … 177 177 } 178 178 } 179 179 180 180 moveto(10, 28); 181 181 printf("%s%.*s", scores[NUMSPOTS - 1].hs_name, MAXLOGNAME - i, 182 182 "........................................"); 183 183 } 184 184 185 185 scores[NUMSPOTS - 1].hs_score = score; 186 186 scores[NUMSPOTS - 1].hs_level = level; 187 187 188 188 i = NUMSPOTS - 1; 189 189 while ((i > 0) && (scores[i - 1].hs_score < score)) 190 190 i--; 191 191 192 192 for (j = NUMSPOTS - 2; j > i; j--) 193 193 copyhiscore(j, j-1); 194 194 195 195 copyhiscore(i, NUMSPOTS - 1); 196 196 } … … 236 236 return; 237 237 } 238 238 239 239 cnt = fwrite(scores, sizeof(struct highscore), NUMSPOTS, f); 240 240 rc = fclose(f);
Note:
See TracChangeset
for help on using the changeset viewer.