mirror of
https://git.squeakyrat.moe/petratc/
synced 2026-11-05 02:45:43 +01:00
moved files around
This commit is contained in:
1 parent
2d61b43a72
commit
be9c7f9280
7 files changed
+83
-63
No files matched your search
@@ -1,7 +1,7 @@
|
|||||||
CC = gcc
|
CC = gcc
|
||||||
CFLAGS = -Wall -Wextra
|
CFLAGS = -Wall -Wextra
|
||||||
TARGET = petratc
|
TARGET = petratc
|
||||||
SRC = petratc.c
|
SRC = petratc.c $(wildcard games/*.c)
|
||||||
PREFIX = /usr/local
|
PREFIX = /usr/local
|
||||||
|
|
||||||
$(TARGET): $(SRC)
|
$(TARGET): $(SRC)
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
#ifndef defs_h
|
||||||
|
#define defs_h
|
||||||
|
|
||||||
|
void gameguess(void);
|
||||||
|
void gamecatch(void);
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include "../rat.h"
|
||||||
|
void gamecatch(){
|
||||||
|
|
||||||
|
printf("67");
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include "../rat.h"
|
||||||
|
|
||||||
|
void gameguess(){
|
||||||
|
int guess;
|
||||||
|
int solved = 0;
|
||||||
|
int range = 100;
|
||||||
|
|
||||||
|
int correct = (rand() % (range + 1));
|
||||||
|
|
||||||
|
printf("let's play a game, squeak!~ you gues a number between 0 and %d!\n", range);
|
||||||
|
|
||||||
|
|
||||||
|
while(solved != 1){
|
||||||
|
|
||||||
|
scanf("%d", &guess);
|
||||||
|
|
||||||
|
if(guess < correct){
|
||||||
|
printf("number too low try again\n");
|
||||||
|
}else if(guess > correct){
|
||||||
|
printf("number too high try again\n");
|
||||||
|
}else {printf("yes!! correct! squeaaakk!~\n"); solved = 1;}
|
||||||
|
}
|
||||||
|
|
||||||
|
addstat(&rat.fun);
|
||||||
|
|
||||||
|
}
|
||||||
@@ -3,6 +3,7 @@
|
|||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include "rat.h"
|
#include "rat.h"
|
||||||
|
#include "defs.h"
|
||||||
|
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
#define ratpath "%s/Library/Application Support/rat"
|
#define ratpath "%s/Library/Application Support/rat"
|
||||||
@@ -12,6 +13,28 @@
|
|||||||
#define ratsave "%s/.local/share/rat/rat.txt"
|
#define ratsave "%s/.local/share/rat/rat.txt"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
char ratart[] =
|
||||||
|
" .---.\n (\\./) \\.......-\n >' '< (__.'\"\"\"\"\"\"\n \" ` \" \"_";
|
||||||
|
|
||||||
|
char *messages[] = {
|
||||||
|
"squeak!",
|
||||||
|
"squeak! !",
|
||||||
|
"squeak",
|
||||||
|
"squeak...",
|
||||||
|
"SQUEAK",
|
||||||
|
"SQUEAK!!",
|
||||||
|
"SQUEAAAKKKKK",
|
||||||
|
};
|
||||||
|
|
||||||
|
void addstat(float *guy){
|
||||||
|
|
||||||
|
if(*guy < 98.5){
|
||||||
|
*guy += 1.5;
|
||||||
|
} else{*guy += 0.05;}
|
||||||
|
}
|
||||||
|
|
||||||
|
Rat rat;
|
||||||
|
|
||||||
void save(void) {
|
void save(void) {
|
||||||
char path[256];
|
char path[256];
|
||||||
snprintf(path, sizeof(path), ratpath, getenv("HOME"));
|
snprintf(path, sizeof(path), ratpath, getenv("HOME"));
|
||||||
@@ -63,13 +86,6 @@ void setstat(){
|
|||||||
rat.age = timenow; //thinking about this makes my cortisol spike so i'll just ignore it even more
|
rat.age = timenow; //thinking about this makes my cortisol spike so i'll just ignore it even more
|
||||||
}
|
}
|
||||||
|
|
||||||
//stupid function but it's smart if you think about it. just ignore it
|
|
||||||
void addstat(float *guy){
|
|
||||||
|
|
||||||
if(*guy < 98.5){
|
|
||||||
*guy += 1.5;
|
|
||||||
} else{*guy += 0.05;}
|
|
||||||
}
|
|
||||||
|
|
||||||
void printrat(){
|
void printrat(){
|
||||||
|
|
||||||
@@ -81,41 +97,6 @@ void printrat(){
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void gameguess(){
|
|
||||||
int guess;
|
|
||||||
int solved = 0;
|
|
||||||
int range = 100;
|
|
||||||
|
|
||||||
int correct = (rand() % (range + 1));
|
|
||||||
|
|
||||||
printf("let's play a game, squeak!~ you gues a number between 0 and %d!\n", range);
|
|
||||||
|
|
||||||
|
|
||||||
while(solved != 1){
|
|
||||||
|
|
||||||
scanf("%d", &guess);
|
|
||||||
|
|
||||||
if(guess < correct){
|
|
||||||
printf("number too low try again\n");
|
|
||||||
}else if(guess > correct){
|
|
||||||
printf("number too high try again\n");
|
|
||||||
}else {printf("yes!! correct! squeaaakk!~\n"); solved = 1;}
|
|
||||||
}
|
|
||||||
|
|
||||||
addstat(&rat.fun);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void showergame(){
|
|
||||||
|
|
||||||
//ignore this i'm working on it
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
addstat(&rat.clean);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int main(){
|
int main(){
|
||||||
srand(time(NULL));
|
srand(time(NULL));
|
||||||
@@ -132,7 +113,7 @@ int truing = 1;
|
|||||||
switch(choice){
|
switch(choice){
|
||||||
|
|
||||||
case 1: gameguess(); break;
|
case 1: gameguess(); break;
|
||||||
case 4: showergame(); break;
|
case 4: gamecatch(); break;
|
||||||
case 8: printf("%d\n", rat.age); break;
|
case 8: printf("%d\n", rat.age); break;
|
||||||
case 9: printrat(); break;
|
case 9: printrat(); break;
|
||||||
case 0: truing = 0; break;
|
case 0: truing = 0; break;
|
||||||
|
|||||||
@@ -1,22 +1,18 @@
|
|||||||
char ratart[] =
|
#ifndef rat_h
|
||||||
" .---.\n (\\./) \\.......-\n >' '< (__.'\"\"\"\"\"\"\n \" ` \" \"_";
|
#define rat_h
|
||||||
|
|
||||||
char *messages[] = {
|
typedef struct {
|
||||||
"squeak!",
|
float hunger;
|
||||||
"squeak! !",
|
float love;
|
||||||
"squeak",
|
float fun;
|
||||||
"squeak...",
|
float clean;
|
||||||
"SQUEAK",
|
float health;
|
||||||
"SQUEAK!!",
|
int age;
|
||||||
"SQUEAAAKKKKK",
|
} Rat;
|
||||||
};
|
|
||||||
|
|
||||||
struct{
|
extern char ratart[];
|
||||||
float hunger;
|
extern char *messages[];
|
||||||
float love;
|
extern Rat rat;
|
||||||
float fun;
|
void addstat(float *guy);
|
||||||
float clean;
|
|
||||||
float health;
|
|
||||||
int age;
|
|
||||||
|
|
||||||
}rat;
|
#endif
|
||||||
Reference in new issue
Block a user