Skip to content

Commit 0dfa67e

Browse files
committed
Initial commit
0 parents  commit 0dfa67e

File tree

6 files changed

+74
-0
lines changed

6 files changed

+74
-0
lines changed

.gitattributes

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Auto detect text files and perform LF normalization
2+
* text=auto

.gitignore

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
.DS_Store
2+
applet
3+
application.linux-arm64
4+
application.linux-armv6hf
5+
application.linux32
6+
application.linux64
7+
application.windows32
8+
application.windows64
9+
application.macosx

CreatureSim.pde

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
int rSeed = -1; //if -1 the pseudorandom seed will be set automagically,else, use the seed here
2+
int nSeed = -1; //ditto
3+
Tile testTile = new Tile(random(0, 10), false);
4+
void setup() {
5+
size(960, 540, P2D);
6+
if (rSeed != -1) {
7+
randomSeed(rSeed);
8+
}
9+
if (nSeed != -1) {
10+
noiseSeed(nSeed);
11+
}
12+
13+
}
14+
15+
void draw() {
16+
background(255);
17+
fill(0);
18+
rect(0, 0, height, height);
19+
testTile.Tick();
20+
}

Map.pde

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
class Map{
2+
}

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# CreatureSim

Tile.pde

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
class Tile {
2+
float theight; //0-10; inverse of fertility
3+
float fertility; //calculated based on height
4+
boolean isWater;
5+
boolean canHaveFood;
6+
boolean hasFood; //currently
7+
int timerForFood; //if it is -1 it either already has food or has no food
8+
//decreases every tick, when is zero set hasFood to zero
9+
10+
Tile(float givenHeight, boolean gisWater) {
11+
theight = givenHeight;
12+
isWater = gisWater;
13+
fertility = map(theight, 0, 10, 10, 0);
14+
if (isWater) {
15+
canHaveFood = false;
16+
timerForFood = -1;
17+
} else {
18+
if (random(0, 10) < fertility) {
19+
canHaveFood = true;
20+
timerForFood = (int)map(fertility, 0, 10, 1, 50);
21+
} else {
22+
canHaveFood = false;
23+
timerForFood = -1;
24+
}
25+
}
26+
}
27+
28+
void Tick() {
29+
if(canHaveFood & !hasFood){
30+
timerForFood--;
31+
if (timerForFood == -1){
32+
hasFood = true;
33+
}
34+
35+
}
36+
println(canHaveFood);
37+
println(hasFood);
38+
println(timerForFood);
39+
}
40+
}

0 commit comments

Comments
 (0)