aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--defs.h9
-rw-r--r--games/gameclicker.c97
-rw-r--r--petratc.c9
-rw-r--r--rat.h6
4 files changed, 106 insertions, 15 deletions
diff --git a/defs.h b/defs.h
deleted file mode 100644
index 00f680c..0000000
--- a/defs.h
+++ /dev/null
@@ -1,9 +0,0 @@
-#ifndef defs_h
-#define defs_h
-
-void gameguess(void);
-void gamecatch(void);
-void gamemaze(void);
-void gameclicker(void);
-
-#endif
diff --git a/games/gameclicker.c b/games/gameclicker.c
index 60bacfa..c20dcbc 100644
--- a/games/gameclicker.c
+++ b/games/gameclicker.c
@@ -18,6 +18,89 @@ static void stop() {
running = 0;
}
+/*
+ //i need to make a system based on intergers to represent non-int numbers like 0.5 or five trillion as 5T instead of 500000000000 or whatever
+ //how do i tell a computer that 1000 = 1k and 10000 = 10k and 1000000 = 1M and that etc
+ //i'll use powers of 10
+ //1^10x0 = 1 1^1(10x1) = 10 1^1(10x2) = 100 1^1(10x3) = 1k
+ // x*10^y <-- this is what i store
+ //1 becomes X. x can range from 0 to 999, when it reaches 999 it adds 1 to y and x goes back to 0
+ //is this memory safe????? yeah sure i don't see why it wouldnt
+ //x is a float or a double i think a double yeah a double
+ //
+ //and then print that as it should so 2.3^10x3 = 2.3k
+ //and also other functions to add or substract from this using regular numbers
+
+ //wait i could just do powers of 1000
+ //x is still 0.0 - 999.999 but it's x*1000^y
+ //55.3* 1000^2 = 55300000
+ //
+ //once x reaches 999.999 it wraps back to 0 and adds 1 to y
+ //then check y so that y = 0 is units, y = 1 is k, y = 2 is M, y = 3 is B, y = 4 is T, etc
+*/
+
+/*
+//a bignum is just a scientific notation number
+// x ^ 1000^y
+// 55300 = 55.3*1000^1
+// double x = 55.3
+// int y = 1
+*/
+typedef struct bignum{
+ double x;
+ int y;
+}bignum;
+
+static char *digit[] = {
+ "", "K", "M", "B", "T",
+ "Qa", "Qi", "Sx", "Sp",
+ "Oc", "No", "Dc"
+ // up to y=11 (10^36) there's no way someone gets farther than this
+};
+
+static bignum normalize(double regnum){
+ bignum b;
+ double val = regnum;
+ int y = 0;
+
+ while (abs((int)val) >= 1000) {
+ val /= 1000.0;
+ y++;
+ }
+ while (val != 0.0 && abs((int)val) < 1) {
+ val *= 1000.0;
+ y--;
+ }
+
+ b.x = val;
+ b.y = y;
+ return b;
+}
+
+static double weirderize(bignum a){
+ double result = a.x;
+ int y = a.y;
+ while (y > 0) { result *= 1000.0; y--; }
+ while (y < 0) { result /= 1000.0; y++; }
+ return result;
+}
+
+static bignum addbignum(bignum a, bignum b){
+ return normalize(weirderize(a) + weirderize(b));
+}
+
+static bignum subbignum(bignum a, bignum b){
+ return normalize(weirderize(a) - weirderize(b));
+}
+
+static bignum mulbignum(bignum a, bignum b){
+ return normalize(weirderize(a) * weirderize(b));
+}
+
+static bignum divbignum(bignum a, bignum b){
+ return normalize(weirderize(a) / weirderize(b));
+}
+
void gameclicker(){
srand(time(NULL));
@@ -31,8 +114,8 @@ void gameclicker(){
keypad(stdscr, TRUE);
curs_set(0);
- int winh = height * 0.96;
- int winw = width * 0.96;
+ int winh = height * 0.97;
+ int winw = width * 0.97;
int boxy = (height - winh) / 2;
int boxx = (width - winw) / 2;
WINDOW *win = newwin(winh, winw, boxy, boxx);
@@ -40,16 +123,20 @@ void gameclicker(){
box(win, 0, 0); //box?
//should i wrap all this into a macro in rat.h to not have to write all of this every time i make a new game?
+ //or just a function in something like rat.c yeah
- running = 1;
+ running = 1;
+
+ bignum cheeses;
- mvwprintw(win, row ++, 2, "hi");
+ mvwprintw(win, row ++, 4, "hi");
while(running){
if(!running){stop();}
int ch = getch();
+
switch (ch) {
case 'q': case 'Q': stop(); break;
- }
+ }
wrefresh(win);
diff --git a/petratc.c b/petratc.c
index ac40791..440505b 100644
--- a/petratc.c
+++ b/petratc.c
@@ -5,7 +5,6 @@
#include <string.h>
#include <sys/stat.h>
#include "rat.h"
-#include "defs.h"
#ifdef __APPLE__
#define ratpath "%s/Library/Application Support/rat"
@@ -33,6 +32,12 @@
"SQUEAAAKKKKK",
};
+ char *funfact[] = {
+ "press q to exit games !",
+ "rats love cheese!",
+ "i am sleepy.."
+ };
+
void addstat(float *guy){
if(*guy < 98.5){
@@ -117,6 +122,7 @@ void printrat(WINDOW *win){
row++;
int howmany = sizeof(messages) / sizeof(messages[0]);
+ int facts = sizeof(funfact) / sizeof(funfact[0]);
mvwprintw(win, row++, 2, "%s", messages[rand() % howmany]);
row++;
@@ -133,6 +139,7 @@ void printrat(WINDOW *win){
mvwprintw(win, row++, 2, "5: clicker the cheese! (all up)");
mvwprintw(win, row++, 2, "9: print me! (refreshes stats)");
mvwprintw(win, row++, 2, "0: exit...");
+ mvwprintw(win, row++ +1, 1, "fun fact: %s", funfact[rand() % facts]);
wrefresh(win);
}
diff --git a/rat.h b/rat.h
index c35bb51..d887ccb 100644
--- a/rat.h
+++ b/rat.h
@@ -15,4 +15,10 @@ extern char *messages[];
extern Rat rat;
void addstat(float *guy);
+
+void gameguess(void);
+void gamecatch(void);
+void gamemaze(void);
+void gameclicker(void);
+
#endif