-
Notifications
You must be signed in to change notification settings - Fork 8
/
print.c
83 lines (74 loc) · 1.89 KB
/
print.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
//
// File: print.c
// print.c handles printing of pre-game strings
// @author Josh Bicking <josh1147582>
// // // // // // // // // // // // // // // // // // // // // // //
#define _BSD_SOURCE /* for unistd.h */
#ifdef _WIN32
# include <Windows.h>
# include <curses.h>
# define SLEEP(delay) Sleep(delay/1000)
#else
# include <ncurses.h>
# include <unistd.h>
# define SLEEP(delay) usleep(delay)
#endif
#include <stdlib.h>
#include <time.h>
#include <string.h>
#include "print.h"
#include "pass.h"
void slowPrint(char arr[], int line){
for(int i=0; (unsigned long)i<strlen(arr); i++){
/* Print the current character in the current position. */
mvprintw(line,i,"%c",arr[i]);
/* Move the cursor to the next position */
move(line, i+1);
refresh();
/* If any keyboard input was recieved, go directly to pass(), otherwise continue */
if(kbhit()){
pass();
}
SLEEP(20000);
}
return;
}
void slowType(char arr[], int line){
for(int i=0; (unsigned long)i<strlen(arr); i++){
mvprintw(line,i+1,"%c",arr[i]);
move(line, i+2);
refresh();
if(kbhit()){
pass();
}
SLEEP(70000);
}
return;
}
void passPrint(char arr[], int line){
for(int i=0; (unsigned long)i<strlen(arr); i++){
mvprintw(line,i,"%c",arr[i]);
move(line, i+1);
refresh();
SLEEP(20000);
}
}
int kbhit(){
/* Get the current char. */
int ch = getch();
/* Returns true if a key has been hit. False if it hasn't. */
if (ch != ERR) {
return 1;
} else {
return 0;
}
}
void printChoices(int hex, char arr[], int line, int offset){
mvprintw(line,offset,"0x%X", hex);
for(int i=0; i<12; i++)
mvprintw(line,7+offset+i,"%c",arr[i]);
move(line, 20+offset);
refresh();
SLEEP(30000);
}
// end