Skip to content

Commit

Permalink
Merge pull request Revolutionary-Games#172 from Revolutionary-Games/1…
Browse files Browse the repository at this point in the history
…46-photosynthesis

Photosynthesis added. This also involves a refactor to how organelles are created, they now use factory for normalized creation.
  • Loading branch information
jjonj committed Jul 2, 2014
2 parents fcfadbd + 264c964 commit ba903ed
Show file tree
Hide file tree
Showing 8 changed files with 286 additions and 215 deletions.
17 changes: 15 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
# Asset directory
assets/*
# We want certain xmls though
!assets/definitions/
!assets/definitions/*.xml
# maybe add these in later
#!assets/gui/layouts/*.layout

# Website directory

website/*
index.html

# Standard stuff
Thumbs.db
*.obj
Expand Down Expand Up @@ -72,5 +85,5 @@ nbproject/
# Vim swap files
*.swp

# Asset directory
assets/*
# Temporary/backup files
*~
47 changes: 47 additions & 0 deletions assets/definitions/compounds.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?xml version="1.0" ?>
<Compounds>
<Compound name="atp" weight="1">
<Display text="ATP">
<Model file="atp.mesh" size="0.1" />
</Display>
</Compound>
<Compound name="oxygen" weight="1">
<Display text="Oxygen" >
<Model file="molecule.mesh" size="0.3" />
</Display>
</Compound>
<Compound name="reproductase" weight="1">
<Display text="Reproductase" >
<Model file="hex.mesh" size="0.3" />
</Display>
</Compound>
<Compound name="aminoacids" weight="1">
<Display text="Amino Acids">
<Model file="hex.mesh" size="0.3" />
</Display>
</Compound>
<Compound name="ammonia" weight="1">
<Display text="Ammonia" >
<Model file="hex.mesh" size="0.3" />
</Display>
</Compound>
<Compound name="glucose" weight="1">
<Display text="Glucose" >
<Model file="glucose.mesh" size="0.3" />
</Display>
</Compound>
<Compound name="co2" weight="1">
<Display text="CO2" >
<Model file="co2.mesh" size="0.16" />
</Display>
</Compound>

<AgentCompounds>
<Agent name="oxytoxy" weight="1">
<Display text="OxyToxy NT" >
<Model file="oxytoxy.mesh" size="0.3" />
</Display>
<Effect function="oxytoxyEffect" />
</Agent>
</AgentCompounds>
</Compounds>
52 changes: 52 additions & 0 deletions assets/definitions/processes.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?xml version="1.0" ?>
<Processes>
<Process name="Respiration" speedFactor="0.5" energyCost="0">
<Inputs>
<Input compound="glucose" amount="1"/>
<Input compound="oxygen" amount="6"/>
</Inputs>
<Outputs>
<Output compound="co2" amount="6"/>
<Output compound="atp" amount="36"/>
</Outputs>
</Process>
<Process name="ReproductaseSynthesis" speedFactor="2.2" energyCost="30">
<Inputs>
<Input compound="aminoacids" amount="6"/>
<Input compound="glucose" amount="6"/>
<Input compound="oxygen" amount="6"/>
<Input compound="atp" amount="6"/>
</Inputs>
<Outputs>
<Output compound="reproductase" amount="1"/>
</Outputs>
</Process>
<Process name="AminoAcidSynthesis" speedFactor="3.5" energyCost="0">
<Inputs>
<Input compound="glucose" amount="1"/>
<Input compound="ammonia" amount="1"/>
</Inputs>
<Outputs>
<Output compound="co2" amount="1"/>
<Output compound="atp" amount="2"/>
<Output compound="aminoacids" amount="1"/>
</Outputs>
</Process>
<Process name="OxyToxySynthesis" speedFactor="0.1" energyCost="1">
<Inputs>
<Input compound="oxygen" amount="3"/>
</Inputs>
<Outputs>
<Output compound="oxytoxy" amount="1"/>
</Outputs>
</Process>
<Process name="Photosynthesis" speedFactor="0.2" energyCost="0">
<Inputs>
<Input compound="co2" amount="6"/>
</Inputs>
<Outputs>
<Output compound="glucose" amount="1"/>
<Output compound="oxygen" amount="6"/>
</Outputs>
</Process>
</Processes>
47 changes: 11 additions & 36 deletions scripts/microbe_editor/microbe_editor.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ function MicrobeEditor:__init(hudSystem)
self.placementFunctions = {["nucleus"] = MicrobeEditor.createNewMicrobe,
["flagelium"] = MicrobeEditor.addMovementOrganelle,
["mitochondria"] = MicrobeEditor.addProcessOrganelle,
["chloroplast"] = MicrobeEditor.addProcessOrganelle,
["toxin"] = MicrobeEditor.addAgentVacuole,

["vacuole"] = MicrobeEditor.addStorageOrganelle,
Expand Down Expand Up @@ -92,10 +93,7 @@ function MicrobeEditor:addStorageOrganelle(organelleType)
-- self.currentMicrobe = Microbe(Entity("working_microbe", GameState.MICROBE))
local q, r = self:getMouseHex()
if self.currentMicrobe:getOrganelleAt(q, r) == nil then
local storageOrganelle = StorageOrganelle(100.0)
storageOrganelle:addHex(0, 0)
storageOrganelle:setColour(ColourValue(0, 1, 0, 1))
self.currentMicrobe:addOrganelle(q, r, storageOrganelle)
self.currentMicrobe:addOrganelle(q, r, OrganelleFactory.makeVacuole())
self.organelleCount = self.organelleCount + 1
end
end
Expand All @@ -104,35 +102,19 @@ end
function MicrobeEditor:addMovementOrganelle(organelleType)
local q, r = self:getMouseHex()
if self.currentMicrobe:getOrganelleAt(q, r) == nil then
-- Calculate the momentum of the movement organelle based on angle towards nucleus
local organelleX, organelleY = axialToCartesian(q, r)
local nucleusX, nucleusY = axialToCartesian(0, 0)
local deltaX = nucleusX - organelleX
local deltaY = nucleusY - organelleY
local dist = math.sqrt(deltaX^2 + deltaY^2) -- For normalizing vector
local momentumX = deltaX / dist * FLAGELIUM_MOMENTUM
local momentumY = deltaY / dist * FLAGELIUM_MOMENTUM
local movementOrganelle = MovementOrganelle(
Vector3(momentumX, momentumY, 0.0),
300
)
movementOrganelle:addHex(0, 0)
movementOrganelle:setColour(ColourValue(0.8, 0.3, 0.3, 1))
self.currentMicrobe:addOrganelle(q,r, movementOrganelle)
self.currentMicrobe:addOrganelle(q,r, OrganelleFactory.makeFlagellum(q,r))
self.organelleCount = self.organelleCount + 1
end
end

function MicrobeEditor:addProcessOrganelle(organelleType)
local q, r = self:getMouseHex()
if self.currentMicrobe:getOrganelleAt(q, r) == nil then
local processOrganelle = ProcessOrganelle()
if organelleType == "mitochondria" then
processOrganelle:addProcess(global_processMap["Respiration"])
processOrganelle:addHex(0, 0)
processOrganelle:setColour(ColourValue(0.8, 0.4, 0.5, 0))

self.currentMicrobe:addOrganelle(q,r, processOrganelle)

if organelleType == "mitochondria" then
self.currentMicrobe:addOrganelle(q,r, OrganelleFactory.makeMitochondrion())
elseif organelleType == "chloroplast" then
self.currentMicrobe:addOrganelle(q,r, OrganelleFactory.makeChloroplast())
else
assert(false, "organelleType did not exist")
end
Expand All @@ -144,23 +126,16 @@ function MicrobeEditor:addAgentVacuole(organelleType)
if organelleType == "toxin" then
local q, r = self:getMouseHex()
if self.currentMicrobe:getOrganelleAt(q, r) == nil then
local agentVacuole = AgentVacuole(CompoundRegistry.getCompoundId("oxytoxy"), global_processMap["OxyToxySynthesis"])
agentVacuole:addHex(0, 0)
agentVacuole:setColour(ColourValue(0, 1, 1, 0))
self.currentMicrobe:addOrganelle(q, r, agentVacuole)
self.currentMicrobe:addOrganelle(q, r, OrganelleFactory.makeOxytoxyVacuole())
self.organelleCount = self.organelleCount + 1
end
end
self.organelleCount = self.organelleCount + 1
end

function MicrobeEditor:addNucleus()
local nucleusOrganelle = NucleusOrganelle()
nucleusOrganelle:addHex(0, 0)
nucleusOrganelle:setColour(ColourValue(0.8, 0.2, 0.8, 1))
local nucleusOrganelle = OrganelleFactory.makeNucleus()
self.currentMicrobe:addOrganelle(0, 0, nucleusOrganelle)
nucleusOrganelle:addProcess(global_processMap["ReproductaseSynthesis"])
nucleusOrganelle:addProcess(global_processMap["AminoAcidSynthesis"])
end

function MicrobeEditor:createNewMicrobe()
Expand All @@ -175,4 +150,4 @@ function MicrobeEditor:createNewMicrobe()
self.currentMicrobe.collisionHandler:addCollisionGroup("powerupable")
self:addNucleus()

end
end
Loading

0 comments on commit ba903ed

Please sign in to comment.