Cleanup
This commit is contained in:
22
figures.h
22
figures.h
@@ -1,18 +1,18 @@
|
|||||||
const char base_figure[6][8] = {{"======="}, \
|
const char base_figure[6][8] = {{"======="}, \
|
||||||
{"I "}, \
|
{"I "}, \
|
||||||
{"I "}, \
|
{"I "}, \
|
||||||
{"I "}, \
|
{"I "}, \
|
||||||
{"I "}, \
|
{"I "}, \
|
||||||
{"I\\ "}};
|
{"I\\ "}};
|
||||||
|
|
||||||
const char figure[6][5] = {{" O "}, \
|
const char figure[6][5] = {{" O "}, \
|
||||||
{" I "}, \
|
{" I "}, \
|
||||||
{"\\I "}, \
|
{"\\I "}, \
|
||||||
{"\\I/"}, \
|
{"\\I/"}, \
|
||||||
{"/ "}, \
|
{"/ "}, \
|
||||||
{"/ \\"}};
|
{"/ \\"}};
|
||||||
|
|
||||||
|
|
||||||
/* This array represents the layers where the strings
|
/* This array represents the layers where the strings
|
||||||
of the current stage(array index) should be printed*/
|
of the current stage(array index) should be printed */
|
||||||
const int stages[] = {0, 1, 1, 1, 2, 2};
|
const int stages[] = {0, 1, 1, 1, 2, 2};
|
||||||
|
72
hangman.c
72
hangman.c
@@ -1,9 +1,9 @@
|
|||||||
#ifdef _WIN32 //For 32 and 64 bits
|
#ifdef _WIN32 //For 32 and 64 bits
|
||||||
/* pdcurses include */
|
/* pdcurses include */
|
||||||
#include <curses.h>
|
#include <curses.h>
|
||||||
#else
|
#else
|
||||||
/* Linux ncurses include */
|
/* Linux ncurses include */
|
||||||
#include <ncurses.h>
|
#include <ncurses.h>
|
||||||
#endif
|
#endif
|
||||||
#include "hangman.h" //includes time.h
|
#include "hangman.h" //includes time.h
|
||||||
#include <stdlib.h> //atexit
|
#include <stdlib.h> //atexit
|
||||||
@@ -15,7 +15,6 @@
|
|||||||
#include "figures.h"
|
#include "figures.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
|
|
||||||
const char *short_options = "w:hf:ct";
|
const char *short_options = "w:hf:ct";
|
||||||
@@ -178,7 +177,7 @@ void initAlphabet(game_state *gs) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
gs->alphabet = malloc(sizeof(char) * hasNumber ? ALPHABET : ALPHABET_NUM);
|
gs->alphabet = malloc(sizeof(char) * hasNumber ? ALPHABET : ALPHABET_NUM);
|
||||||
strcpy(gs->alphabet, "abcdefghijklmnopqrstuvwxyz");
|
strcpy(gs->alphabet, "abcdefghijklmnopqrstuvwxyz");
|
||||||
|
|
||||||
if (hasNumber) {
|
if (hasNumber) {
|
||||||
strcat(gs->alphabet, "1234567890");
|
strcat(gs->alphabet, "1234567890");
|
||||||
@@ -187,15 +186,15 @@ void initAlphabet(game_state *gs) {
|
|||||||
|
|
||||||
void drawAlphabet(game_state *gs, char usedchar) {
|
void drawAlphabet(game_state *gs, char usedchar) {
|
||||||
int start = centerDiff(gs->centerx, gs->alphabet);
|
int start = centerDiff(gs->centerx, gs->alphabet);
|
||||||
int i;
|
int i;
|
||||||
if (usedchar != 0) { /* 0 is used for initialization */
|
if (usedchar != 0) { /* 0 is used for initialization */
|
||||||
for (i = 0; i < (int)strlen(gs->alphabet); i++) {
|
for (i = 0; i < (int)strlen(gs->alphabet); i++) {
|
||||||
if (gs->alphabet[i] == usedchar) {
|
if (gs->alphabet[i] == usedchar) {
|
||||||
gs->alphabet[i] = '_';
|
gs->alphabet[i] = '_';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mvprintw(1, start, "%s", gs->alphabet);
|
mvprintw(1, start, "%s", gs->alphabet);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -293,7 +292,7 @@ int fillCurrentWord(game_state *gs, char validchar) {
|
|||||||
gs->currentWord[i] = validchar;
|
gs->currentWord[i] = validchar;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
drawAlphabet(gs, validchar);
|
drawAlphabet(gs, validchar);
|
||||||
return 1;
|
return 1;
|
||||||
} else {
|
} else {
|
||||||
return 0;
|
return 0;
|
||||||
@@ -403,8 +402,8 @@ void readRandomLine(char *file, char *result) {
|
|||||||
void trollHitScreen(game_state *gs, hitfeed *hf, int hits) {
|
void trollHitScreen(game_state *gs, hitfeed *hf, int hits) {
|
||||||
if (gs->trollEnabled) {
|
if (gs->trollEnabled) {
|
||||||
char *strings[] = {"Double Hit", "Triple Hit", "Multi Hit", \
|
char *strings[] = {"Double Hit", "Triple Hit", "Multi Hit", \
|
||||||
"Ultra Hit", "Monster Hit", "Rampage", \
|
"Ultra Hit", "Monster Hit", "Rampage", \
|
||||||
"Unstoppable", "Wicked sick", "Godlike"};
|
"Unstoppable", "Wicked sick", "Godlike"};
|
||||||
int selection[] = {2, 3, 4, 5, 6, 7, 8, 9, 10};
|
int selection[] = {2, 3, 4, 5, 6, 7, 8, 9, 10};
|
||||||
int i, found = 0;
|
int i, found = 0;
|
||||||
for (i = 0; i < 9; i++) {
|
for (i = 0; i < 9; i++) {
|
||||||
@@ -489,26 +488,23 @@ void trollHandleImpressive(hitfeed *hf, game_state *gs, int hits) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void drawFigure(game_state *gs, int drawNext) {
|
void drawFigure(game_state *gs, int drawNext) {
|
||||||
int row = 6;
|
int row = 6;
|
||||||
int length = 8;
|
int length = 8;
|
||||||
int i;
|
int i;
|
||||||
static int state = 0;
|
static int state = 0;
|
||||||
if (!state) {
|
if (!state) {
|
||||||
for (i = 0; i < row; i++) {
|
for (i = 0; i < row; i++) {
|
||||||
mvprintw(i, gs->maxx - length - 1, "%s", base_figure[i]);
|
mvprintw(i, gs->maxx - length - 1, "%s", base_figure[i]);
|
||||||
}
|
}
|
||||||
state++;
|
state++;
|
||||||
} else {
|
} else {
|
||||||
/* Draw the stages */
|
/* Draw the stages */
|
||||||
if (drawNext) {
|
if (drawNext) {
|
||||||
mvprintw(stages[state - 1] + 1, gs->maxx - 4, "%s", figure[state - 1]);
|
mvprintw(stages[state - 1] + 1, gs->maxx - 4, "%s", figure[state - 1]);
|
||||||
state++;
|
state++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void animateLineClear(game_state *gs, int line, int offsetMultiplier) {
|
void animateLineClear(game_state *gs, int line, int offsetMultiplier) {
|
||||||
@@ -525,5 +521,3 @@ void animateLineClear(game_state *gs, int line, int offsetMultiplier) {
|
|||||||
mvprintw(line, k, " ");
|
mvprintw(line, k, " ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -1,8 +1,6 @@
|
|||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Defined macros */
|
/* Defined macros */
|
||||||
#define DEFAULTTRIES 6
|
#define DEFAULTTRIES 6
|
||||||
#define MAXWORDLENGTH 200
|
#define MAXWORDLENGTH 200
|
||||||
|
4
prng.c
4
prng.c
@@ -44,7 +44,7 @@ void InitializePRNG(const uint32_t seed)
|
|||||||
index = N;
|
index = N;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void Twist()
|
static void Twist(void)
|
||||||
{
|
{
|
||||||
uint32_t i, x, xA;
|
uint32_t i, x, xA;
|
||||||
|
|
||||||
@@ -64,7 +64,7 @@ static void Twist()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Obtain a 32-bit random number
|
// Obtain a 32-bit random number
|
||||||
uint32_t ExtractU32()
|
uint32_t ExtractU32(void)
|
||||||
{
|
{
|
||||||
uint32_t y;
|
uint32_t y;
|
||||||
int i = index;
|
int i = index;
|
||||||
|
Reference in New Issue
Block a user