Experiments in using Lua with sol2 and how best to structure the data. Contains a shoot out of SOA, vs AOS vs. MOA. SOA = Struct of Arrays AOS = Array of Structs MOA = Many Array of Structs (kind of a hybrid)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
sol2_test/tests/soa_tests.lua

25 lines
473 B

function combat(world, index)
world.hp[index] = world.hp[index] - world.damage[index]
end
function cull_dead(world, index)
if world.hp[index] < 0 then
world.dead[index] = true
end
end
function handler(world)
print("world count", world.count)
for i = 1, world.count + 1, 1
do
combat(world, i)
cull_dead(world, i)
print(world.name[i],
"HP now", world.hp[i],
"damage", world.damage[i],
"dead", world.dead[i])
end
end