Browse Source

wip noise-based formulations

Tangent 3 years ago
commit
93cba190c0
2 changed files with 196 additions and 0 deletions
  1. 53
    0
      main.moon
  2. 143
    0
      src/main.moon

+ 53
- 0
main.moon View File

@@ -0,0 +1,53 @@
1
+w, h = love.graphics.getDimensions!
2
+
3
+map = {}
4
+map.get = (x, y) -> if map[x] return map[x][y]
5
+map.set = (x, y, v) ->
6
+  map[x] = {} unless map[x]
7
+  map[x][y] = v
8
+seed = love.math.random!
9
+scale = 10
10
+tileSize = 20
11
+camera = { x: 0, y: 0 }
12
+
13
+update = ->
14
+  if love.keyboard.isDown "a"
15
+    camera.x -= 4
16
+  if love.keyboard.isDown "d"
17
+    camera.x += 4
18
+  if love.keyboard.isDown "w"
19
+    camera.y -= 4
20
+  if love.keyboard.isDown "s"
21
+    camera.y += 4
22
+
23
+time, tick = 0, 1/60
24
+love.update = (dt) ->
25
+  time += dt
26
+  if time >= tick
27
+    time -= tick
28
+    update()
29
+
30
+love.draw = ->
31
+  a, b = math.floor(camera.x / tileSize), math.floor(camera.y / tileSize)
32
+  i, j = camera.x % tileSize, camera.y % tileSize
33
+  for x = 0, w / tileSize
34
+    for y = 0, h / tileSize
35
+      n = love.math.noise (x + a + seed) / scale, (y + b + seed) / scale
36
+      m = love.math.noise (x + a + seed) / scale, (y + b + seed) / scale, n
37
+      if m < 0.72
38
+        love.graphics.setColor n, 1, 0, 1
39
+      else
40
+        love.graphics.setColor 1, 1, 1, 1
41
+      X, Y = x * tileSize - i, y * tileSize - j
42
+      love.graphics.rectangle "fill", X, Y, tileSize, tileSize
43
+      if map.get x + a, y + b
44
+        love.graphics.setColor 0, 0, 0, 1
45
+        love.graphics.line X + tileSize / 2, Y + tileSize / 2, X, Y
46
+
47
+love.mousepressed = (x, y, btn) ->
48
+  X, Y = math.floor((x + camera.x) / tileSize), math.floor((y + camera.y) / tileSize)
49
+  print X, Y
50
+  map.set X, Y, true
51
+
52
+love.keypressed = (key) ->
53
+  love.event.quit! if key == "escape"

+ 143
- 0
src/main.moon View File

@@ -0,0 +1,143 @@
1
+SPAWN = {}  -- special value, for things existing naturally
2
+-- <name       tool used (not destroyed, but causes wear)
3
+-- name+       heavy/large variant required
4
+-- name-       light/small or medium variant required (no +/- == medium)
5
+-- name name   multiple types of product / resource required
6
+-- name#int    1 to int produced          / exactly int required
7
+--              unless int==1 -> 0 or 1
8
+--              unless construct-based -> exact numbers
9
+-- name:type   specific subtype produced / specific subtype required
10
+-- :type       produces random type OF subtype / requires any type OF subtype
11
+-- name/name   requires one of specific types / produces one of specific types
12
+
13
+-- NOTE tool use may refer to tools (hand-crafted) and constructs
14
+--       (factory-crafted)
15
+
16
+-- most resources can be a tile, inside a tile (something with capacity), or inside a player
17
+
18
+recipes = {
19
+  tree: SPAWN
20
+  bush: SPAWN
21
+  grass: SPAWN
22
+  tall_grass: SPAWN
23
+  ["log#1 leaf#2 seed#1/fruit#1"]: "tree"
24
+  ["log#2 leaf#5 seed#4/fruit#4"]: "tree <cutter"
25
+  ["leaf#4 fruit#3/herb#3/vegetable#3"]: "bush"
26
+  ["grain#1/herb#1/seed#1"]: "grass"
27
+  ["herb#2/seed#2/grain#3 plant_fiber#1"]: "tall_grass"
28
+  animal: SPAWN
29
+  carcass: "animal" -- must be killed
30
+  ["raw_meat bone#1"]: "carcass"
31
+  ["raw_meat#2 leather#2 bone#2"]: "carcass <cutter-"
32
+  -- TODO cooker is not obtainable
33
+  meat: "raw_meat <cooker-"
34
+  rock: SPAWN
35
+  stone: SPAWN
36
+  ["flint/stone"]: "rock"
37
+  ["stone#3 metal_ore#1/coal#1"]: "stone <digger+"
38
+  -- driftwood: SPAWN
39
+  -- wood: "driftwood"
40
+  -- TODO smelter is not obtainable
41
+  ["metal#1"]: "metal_ore <smelter-"
42
+  ["metal#2"]: "metal_ore <smelter"
43
+  ["metal#4"]: "metal_ore <smelter+"
44
+  ["wood#2"]: "log <cutter"
45
+  -- TODO forge is not obtainable
46
+  -- TODO plastic is not obtainable
47
+  -- TODO molder is not obtainable
48
+  knife: { "flint/stone", "metal_ore/metal <forge-", "plastic <molder", tool: "cutter-" }
49
+  axe: { "log/wood flint/stone", "log/wood metal_ore/metal <forge", "plastic <molder+", tool: "cutter" }
50
+  pickaxe: { "log/wood flint/stone", "log/wood metal_ore/metal <forge", "plastic <molder+", tool: "digger+" }
51
+  -- NOTE there are no container types defined
52
+  milk: { "animal:mammal", fluid: true } -- note: medium or large animal
53
+  egg: "animal:laying"
54
+  ["cheese#1"]: "milk"
55
+  -- TODO bacteria is not obtainable
56
+  ["cheese#2"]: "milk bacteria"
57
+  -- TODO farm is not obtainable
58
+  fertilizer: { SPAWN, "leaf#2/seed#4", "<farm:animal" }
59
+  -- TODO syringe is not obtainable (make sure it requires a needle-)
60
+  -- NOTE organic is not defined
61
+  dna: ":organic <syringe"
62
+  -- TODO cloner is not obtainable
63
+  ["animal#1"]: "dna <cloner"
64
+  ["tree#1/bush#1/tall_grass#1"]: "seed farmland water"
65
+  ["seed#2"]: "fruit/vegetable"
66
+  ["seed#1"]: "herb/grain"
67
+  dirt: { SPAWN, "dirt <digger" }
68
+  farmland: "dirt <tiller"
69
+  hoe: { "log/wood flint/stone", "log/wood metal_ore/metal <forge", "plastic <molder+", tool: "tiller" }
70
+  shovel: { "log/wood flint/stone", "log/wood metal_ore/metal <forge", "plastic <molder+", tool: "digger" }
71
+  sand: { SPAWN, "sand <digger" }
72
+  -- hammer: { "log/wood flint/stone", "log/wood metal_ore/metal <forge", "plastic <molder+", tool: "smasher" }
73
+  -- gravel: { SPAWN, "gravel <digger", "stone <smasher" }
74
+  water: { SPAWN, fluid: true }
75
+  -- salt_water: SPAWN
76
+  ["glass#1"]: "sand <forge-"
77
+  ["glass#2"]: "sand <forge"
78
+  ["glass#4"]: "sand <forge+"
79
+  -- TODO distiller is not obtainable
80
+  alcohol: { "fruit <distiller-", "grain#2 herb water <distiller+", "vegetable <distiller", fluid: true }
81
+  -- NOTE remember that depending on origins, different flavor text for item types will exist
82
+  --       ie: alcohol should be wine, beer, and vodka
83
+  -- TODO mineral is not obtainable (idea: refine from stone)
84
+  -- TODO lab is not obtainable
85
+  medicine: { "herb#3", "mineral plastic water <lab" }
86
+  textile: { "plant_fiber#2/leather <needle-" }
87
+  ["needle#1-"]: "bone/wood/log"
88
+  needle: { "plastic <molder-", "metal_ore/metal <forge-", "bone/wood/log <cutter" }
89
+  ["needle-"]: { "plastic <molder", "metal_ore/metal <forge" }
90
+  backpack: { "textile#2/leather#2 <needle", capacity: 12 } -- base capacity can fluctuate
91
+  ["backpack+"]: { "textile#3/leather#3 <needle-", capacity: 20 }
92
+  sack: { "textile/leather <needle", capacity: 5 }
93
+  belt: { "textile/leather/plant_fiber <needle", capacity: 7 }
94
+  -- crystal: { SPAWN, "crystal <digger+" } -- NOTE will be used in advanced electronics
95
+  -- TODO factory is unobtainable
96
+  microscope: "glass metal/plastic#2 <factory+" -- TODO more advanced recipes for better microscopes
97
+  -- TODO well is unobtainable
98
+  oil: { SPAWN, "oil <well+" }
99
+  ice: SPAWN
100
+  -- ["medicine acid"]: "mineral#5 oil water#2"
101
+  -- TODO gem -> lens
102
+  -- TODO uranium -> centrifuge -> fission reactor -> electricity
103
+  -- TODO oil -> plastic&gasoline&kerosine&tar&methane?
104
+  -- TODO bacteria -> hydrocarbons
105
+  -- TODO oxygen, hydrogen, carbon, methane, carbon dioxide, carbon monoxide, nitrogen, argon, helium
106
+  -- TODO catalytic_metal ?
107
+  -- TODO ??? super strong metal (harvest from gas giant for advanced techs?)
108
+  -- TODO bose-einstein condensate, neutronium, superfluidics, superconductors, quantum lockers
109
+  -- TODO electricity
110
+  -- TODO computer
111
+  -- TODO zero-point energy, casimir energy, fusion energy, he3 mining
112
+  -- TODO battery tech: lead acid, lithium ion, aluminium air, zinc-nickel (metal batteries)
113
+  -- TODO dynamite
114
+  -- TODO machinery :mining,logging,farm
115
+  -- TODO chair,table,dresser,desk,bookshelf,shelf,lamp,locker,door
116
+  -- TODO clothing
117
+  -- TODO medkit: syringes, medicine, textiles
118
+  -- TODO tesla coil
119
+  -- TODO many foodstuffs (bread, pie, stew, pilaf, salad, etc)
120
+  -- TODO offices ?
121
+  -- TODO antimatter generator, particle accelerator, magnetic trap
122
+  -- TODO plasma, alignment crystal, etc, matter transmitter
123
+  -- TODO research subatomic particles
124
+  -- TODO wormhole expansion drive, gravimetric drive, ion drive/photonic drives
125
+  -- TODO quantum drive, reality rupture drive, warp folding drive
126
+
127
+  -- NOTE hay is just a grain type
128
+}
129
+
130
+buildings = { -- listing what constructs are required
131
+  -- NOTE everything requires at least one office and bathroom
132
+  capitol: { "office", "atrium/lounge", optional: { "cafeteria", "garage?" } }
133
+  bank: {}
134
+}
135
+
136
+-- TODO list animal types somewhere
137
+-- NOTE materials have inherint strength, which will effect quality of things
138
+--       produced from them
139
+-- building: enclosed with walls (and door(s)/window(s))
140
+--  and has floors and "roof", two materials per interior tile, one per wall tile :3
141
+-- pen: enclosed with fence (and gate(s))
142
+-- TODO food edibility chart
143
+-- TODO research, universities, prototyping