This commit is contained in:
2017-08-23 21:15:18 +02:00
parent 6c168a8618
commit d9f9acc87c
5 changed files with 76 additions and 84 deletions

View File

@@ -1,18 +1,18 @@
const char base_figure[6][8] = {{"======="}, \
{"I "}, \
{"I "}, \
{"I "}, \
{"I "}, \
{"I\\ "}};
{"I "}, \
{"I "}, \
{"I "}, \
{"I "}, \
{"I\\ "}};
const char figure[6][5] = {{" O "}, \
{" I "}, \
{"\\I "}, \
{"\\I/"}, \
{"/ "}, \
{"/ \\"}};
{" I "}, \
{"\\I "}, \
{"\\I/"}, \
{"/ "}, \
{"/ \\"}};
/* 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};

View File

@@ -1,9 +1,9 @@
#ifdef _WIN32 //For 32 and 64 bits
/* pdcurses include */
#include <curses.h>
/* pdcurses include */
#include <curses.h>
#else
/* Linux ncurses include */
#include <ncurses.h>
/* Linux ncurses include */
#include <ncurses.h>
#endif
#include "hangman.h" //includes time.h
#include <stdlib.h> //atexit
@@ -15,7 +15,6 @@
#include "figures.h"
int main(int argc, char **argv) {
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);
strcpy(gs->alphabet, "abcdefghijklmnopqrstuvwxyz");
strcpy(gs->alphabet, "abcdefghijklmnopqrstuvwxyz");
if (hasNumber) {
strcat(gs->alphabet, "1234567890");
@@ -187,15 +186,15 @@ void initAlphabet(game_state *gs) {
void drawAlphabet(game_state *gs, char usedchar) {
int start = centerDiff(gs->centerx, gs->alphabet);
int i;
if (usedchar != 0) { /* 0 is used for initialization */
for (i = 0; i < (int)strlen(gs->alphabet); i++) {
if (gs->alphabet[i] == usedchar) {
gs->alphabet[i] = '_';
break;
}
}
}
int i;
if (usedchar != 0) { /* 0 is used for initialization */
for (i = 0; i < (int)strlen(gs->alphabet); i++) {
if (gs->alphabet[i] == usedchar) {
gs->alphabet[i] = '_';
break;
}
}
}
mvprintw(1, start, "%s", gs->alphabet);
}
@@ -293,7 +292,7 @@ int fillCurrentWord(game_state *gs, char validchar) {
gs->currentWord[i] = validchar;
}
}
drawAlphabet(gs, validchar);
drawAlphabet(gs, validchar);
return 1;
} else {
return 0;
@@ -403,8 +402,8 @@ void readRandomLine(char *file, char *result) {
void trollHitScreen(game_state *gs, hitfeed *hf, int hits) {
if (gs->trollEnabled) {
char *strings[] = {"Double Hit", "Triple Hit", "Multi Hit", \
"Ultra Hit", "Monster Hit", "Rampage", \
"Unstoppable", "Wicked sick", "Godlike"};
"Ultra Hit", "Monster Hit", "Rampage", \
"Unstoppable", "Wicked sick", "Godlike"};
int selection[] = {2, 3, 4, 5, 6, 7, 8, 9, 10};
int i, found = 0;
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) {
int row = 6;
int length = 8;
int i;
static int state = 0;
if (!state) {
for (i = 0; i < row; i++) {
mvprintw(i, gs->maxx - length - 1, "%s", base_figure[i]);
}
state++;
} else {
/* Draw the stages */
if (drawNext) {
mvprintw(stages[state - 1] + 1, gs->maxx - 4, "%s", figure[state - 1]);
state++;
}
}
int row = 6;
int length = 8;
int i;
static int state = 0;
if (!state) {
for (i = 0; i < row; i++) {
mvprintw(i, gs->maxx - length - 1, "%s", base_figure[i]);
}
state++;
} else {
/* Draw the stages */
if (drawNext) {
mvprintw(stages[state - 1] + 1, gs->maxx - 4, "%s", figure[state - 1]);
state++;
}
}
}
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, " ");
}
}

View File

@@ -1,8 +1,6 @@
#include <time.h>
/* Defined macros */
#define DEFAULTTRIES 6
#define MAXWORDLENGTH 200

4
prng.c
View File

@@ -44,7 +44,7 @@ void InitializePRNG(const uint32_t seed)
index = N;
}
static void Twist()
static void Twist(void)
{
uint32_t i, x, xA;
@@ -64,7 +64,7 @@ static void Twist()
}
// Obtain a 32-bit random number
uint32_t ExtractU32()
uint32_t ExtractU32(void)
{
uint32_t y;
int i = index;

2
prng.h
View File

@@ -5,5 +5,5 @@
#include <stdint.h>
void InitializePRNG(const uint32_t seed);
uint32_t ExtractU32();
uint32_t ExtractU32(void);
int getrandom(int low, int high);