Compare commits
7 Commits
e0a4d684fc
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 02938c7933 | |||
| b8cd1ce56f | |||
| 1db758543f | |||
| 9ff08e4a91 | |||
| a094105476 | |||
| a1d157c69f | |||
| 89d15fc30b |
@@ -7,6 +7,6 @@
|
|||||||
>[!WARNING]
|
>[!WARNING]
|
||||||
>I have no idea what I'm doing and I'm definitely not a professional
|
>I have no idea what I'm doing and I'm definitely not a professional
|
||||||
|
|
||||||
To read the original post go to [the original post](https://fedi.krzak.org/notes/aikajnzup9za0001) or [its copy](./original_post.mfm)
|
To read the original post go to [the original post](https://fedi.krzak.org/notes/aikajnzup9za0001) or [its copy](./original_post.md)
|
||||||
|
|
||||||
A **C** implementation will **SLOWLY** be done in [./iris_c](./iris_c)
|
A **C** implementation will **SLOWLY** be done in [./iris_c](./iris_c)
|
||||||
|
|||||||
@@ -34,3 +34,11 @@
|
|||||||
### Wormholes
|
### Wormholes
|
||||||
|
|
||||||
- When entering a black hole, the player is teleported to a random white hole. If there are no white holes, the player is teleported to a random quadrant.
|
- When entering a black hole, the player is teleported to a random white hole. If there are no white holes, the player is teleported to a random quadrant.
|
||||||
|
|
||||||
|
## Game Loop
|
||||||
|
|
||||||
|
- Every turn one player action is read and applied
|
||||||
|
|
||||||
|
## Player
|
||||||
|
|
||||||
|
- At startup, the player is created at the world centre (`WORLD_WIDTH / 2`, `WORLD_HEIGHT / 2`).
|
||||||
|
|||||||
@@ -6,8 +6,8 @@ TARGET = main
|
|||||||
|
|
||||||
all: $(TARGET)
|
all: $(TARGET)
|
||||||
|
|
||||||
$(TARGET): main.c random.c random.h world.c world.h
|
$(TARGET): main.c player.c player.h random.c random.h world.c world.h prettynames.c prettynames.h
|
||||||
$(CC) $(CFLAGS) -o $@ main.c random.c world.c
|
$(CC) $(CFLAGS) -o $@ main.c player.c random.c world.c prettynames.c
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f $(TARGET)
|
rm -f $(TARGET)
|
||||||
|
|||||||
@@ -1,31 +1,23 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "prettynames.h"
|
||||||
|
#include "player.h"
|
||||||
#include "random.h"
|
#include "random.h"
|
||||||
#include "world.h"
|
#include "world.h"
|
||||||
|
|
||||||
static const char *quadrant_type_name(quadrant_type type) {
|
|
||||||
switch (type) {
|
|
||||||
case Q_EMPTY: return "Empty";
|
|
||||||
case Q_ASTEROID_FIELD: return "Asteroid field";
|
|
||||||
case Q_STAR_SYSTEM: return "Star system";
|
|
||||||
case Q_NEBULA: return "Nebula";
|
|
||||||
case Q_BLACK_HOLE: return "Black hole";
|
|
||||||
case Q_WHITE_HOLE: return "White hole";
|
|
||||||
case Q_PULSAR: return "Pulsar";
|
|
||||||
case Q_QUASAR: return "Quasar";
|
|
||||||
case Q_SUPERNOVA: return "Supernova";
|
|
||||||
case Q_ANOMALY: return "Anomaly";
|
|
||||||
case Q_SINGULARITY: return "Singularity";
|
|
||||||
case Q_COUNT: return "Count";
|
|
||||||
default: return "Undefined";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
uint32_t seed;
|
uint32_t seed;
|
||||||
printf("Enter seed: ");
|
printf("Enter seed: ");
|
||||||
scanf("%u", &seed);
|
if (scanf("%u", &seed) != 1) {
|
||||||
|
printf("Invalid seed.\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ch = 0;
|
||||||
|
while ((ch = getchar()) != '\n' && ch != EOF) {}
|
||||||
|
|
||||||
set_random_seed(seed);
|
set_random_seed(seed);
|
||||||
|
|
||||||
world_t world;
|
world_t world;
|
||||||
@@ -50,5 +42,16 @@ int main() {
|
|||||||
centre->is_discovered ? "true" : "false"
|
centre->is_discovered ? "true" : "false"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
player_t player = player_create(x, y);
|
||||||
|
char action[128];
|
||||||
|
for (;;) {
|
||||||
|
printf(">");
|
||||||
|
fflush(stdout);
|
||||||
|
if (fgets(action, sizeof(action), stdin) == NULL) break;
|
||||||
|
|
||||||
|
action[strcspn(action, "\n")] = '\0';
|
||||||
|
player_process_action(&player, action);
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
21
iris_c/player.c
Normal file
21
iris_c/player.c
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
#include "player.h"
|
||||||
|
|
||||||
|
#include <stddef.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
player_t player_create(uint16_t x, uint16_t y) {
|
||||||
|
return (player_t){.x = x, .y = y};
|
||||||
|
}
|
||||||
|
|
||||||
|
void player_process_action(player_t *player, const char *action) {
|
||||||
|
// Quit on q
|
||||||
|
|
||||||
|
switch (action[0]) {
|
||||||
|
case 'q':
|
||||||
|
exit(0);
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
(void)player;
|
||||||
|
}
|
||||||
14
iris_c/player.h
Normal file
14
iris_c/player.h
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
#ifndef PLAYER_H
|
||||||
|
#define PLAYER_H
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
uint16_t x;
|
||||||
|
uint16_t y;
|
||||||
|
} player_t;
|
||||||
|
|
||||||
|
player_t player_create(uint16_t x, uint16_t y);
|
||||||
|
void player_process_action(player_t *player, const char *action);
|
||||||
|
|
||||||
|
#endif
|
||||||
19
iris_c/prettynames.c
Normal file
19
iris_c/prettynames.c
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
#include "prettynames.h"
|
||||||
|
|
||||||
|
const char *quadrant_type_name(quadrant_type type) {
|
||||||
|
switch (type) {
|
||||||
|
case Q_EMPTY: return "Empty";
|
||||||
|
case Q_ASTEROID_FIELD: return "Asteroid field";
|
||||||
|
case Q_STAR_SYSTEM: return "Star system";
|
||||||
|
case Q_NEBULA: return "Nebula";
|
||||||
|
case Q_BLACK_HOLE: return "Black hole";
|
||||||
|
case Q_WHITE_HOLE: return "White hole";
|
||||||
|
case Q_PULSAR: return "Pulsar";
|
||||||
|
case Q_QUASAR: return "Quasar";
|
||||||
|
case Q_SUPERNOVA: return "Supernova";
|
||||||
|
case Q_ANOMALY: return "Anomaly";
|
||||||
|
case Q_SINGULARITY: return "Singularity";
|
||||||
|
case Q_COUNT: return "Count";
|
||||||
|
default: return "Undefined";
|
||||||
|
}
|
||||||
|
}
|
||||||
8
iris_c/prettynames.h
Normal file
8
iris_c/prettynames.h
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
#ifndef PRETTYNAMES_H
|
||||||
|
#define PRETTYNAMES_H
|
||||||
|
|
||||||
|
#include "world.h"
|
||||||
|
|
||||||
|
const char *quadrant_type_name(quadrant_type type);
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -14,8 +14,9 @@ static quadrant_type random_quadrant_type(void) {
|
|||||||
if (roll < 70) return Q_BLACK_HOLE;
|
if (roll < 70) return Q_BLACK_HOLE;
|
||||||
if (roll < 80) return Q_WHITE_HOLE;
|
if (roll < 80) return Q_WHITE_HOLE;
|
||||||
if (roll < 85) return Q_PULSAR;
|
if (roll < 85) return Q_PULSAR;
|
||||||
if (roll < 90) return Q_SUPERNOVA;
|
if (roll < 90) return Q_QUASAR;
|
||||||
if (roll < 95) return Q_ANOMALY;
|
if (roll < 95) return Q_SUPERNOVA;
|
||||||
|
if (roll < 99) return Q_ANOMALY;
|
||||||
return Q_SINGULARITY;
|
return Q_SINGULARITY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
I have this giant idea. Essentially, you know how you have the space game easteregg in A15 and 16? I want to make something like that, but not in the normal way. Like, I don't want to just make a similar game. Like, obviously, it'll be bigger and so on. It's meant to be this trading-thing, like, you go from planet to planet, then, text-based, you sell and buy things, get quests, sometimes not quite legal and so on. But why is this a giant idea? You know how you have card games? But not ones with custom cards, things like war or poker, with normal playing cards. What do you get when you 'get' a card game like that? You get a set of rules, maths and so on. I want to make something like that. I want to make that game in a way where you can just go step-by-step, implement each function in any programming language, in any graphics engine and get the same game back. You could do it in JS, you could do it in Godot, you could do it in C and compile for an old console or you could do it in x86 assembly and run it without an operating system, it would still be the exact. same. game. If someone wanted to, they could even follow each rule themselves, with pen and paper, with no electronics and doing the maths in their head and it would still be the same game. Someone could even grow mice neurons in a petri dish and still - the. same. game. that is the plan.
|
I have this giant idea. Essentially, you know how you have the space game easteregg in A15 and 16? I want to make something like that, but not in the normal way. Like, I don't want to just make a similar game. Like, obviously, it'll be bigger and so on. It's meant to be this trading-thing, like, you go from planet to planet, then, text-based, you sell and buy things, get quests, sometimes not quite legal and so on. But why is this a giant idea? You know how you have card games? But not ones with custom cards, things like war or poker, with normal playing cards. What do you get when you 'get' a card game like that? You get a set of rules, maths and so on. I want to make something like that. I want to make that game in a way where you can just go step-by-step, implement each function in any programming language, in any graphics engine and get the same game back. You could do it in JS, you could do it in Godot, you could do it in C and compile for an old console or you could do it in x86 assembly and run it without an operating system, it would still be the exact. same. game. If someone wanted to, they could even follow each rule themselves, with pen and paper, with no electronics and doing the maths in their head and it would still be the same game. Someone could even grow mice neurons in a petri dish and still - the. same. game. that is the plan.
|
||||||
|
|
||||||
|
## I'll write a properly formatting, less rambling version later, I just want to make sure I don't lose this idea
|
||||||
|
|
||||||
$[x2 I'll write a properly formatting, less rambling version later, I just want to make sure I don't lose this idea]
|
[#gamedev](https://fedi.krzak.org/tags/gamedev) [#gamedesign](https://fedi.krzak.org/tags/gamedesign) [#gamedevelopment](https://fedi.krzak.org/tags/gamedevelopment) [#game](https://fedi.krzak.org/tags/game) [#gameidea](https://fedi.krzak.org/tags/gameidea) [#idea](https://fedi.krzak.org/tags/idea) [#ideas](https://fedi.krzak.org/tags/ideas) [#ideas-ill-probably-never-get-to-making-even-though-i-want-to-so-much](https://fedi.krzak.org/tags/ideas-ill-probably-never-get-to-making-even-though-i-want-to-so-much)
|
||||||
|
|
||||||
#gamedev #gamedesign #gamedevelopment #game #gameidea #idea #ideas #ideas-ill-probably-never-get-to-making-even-though-i-want-to-so-much
|
|
||||||
Reference in New Issue
Block a user