Mercurial > games > semicongine
changeset 912:c72b246d8413
add: config loader; fix: circle-mesh
author | Sam <sam@basx.dev> |
---|---|
date | Sun, 10 Mar 2024 20:02:11 +0700 |
parents | 0a1e68f32fca |
children | b19faed54b14 |
files | semicongine/mesh.nim semicongine/resources.nim |
diffstat | 2 files changed, 11 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/semicongine/mesh.nim Sat Mar 09 23:06:27 2024 +0700 +++ b/semicongine/mesh.nim Sun Mar 10 20:02:11 2024 +0700 @@ -492,17 +492,17 @@ inc instanceCounter let - half_w = width / 2 - half_h = height / 2 + rX = width / 2 + rY = height / 2 c = toRGBA(color) step = (2'f32 * PI) / float32(nSegments) var - pos = @[newVec3f(0, 0), newVec3f(0, half_h)] + pos = @[newVec3f(0, 0), newVec3f(rX, 0)] col = @[c, c] - for i in 0 .. nSegments: - pos.add newVec3f(cos(float32(i) * step) * half_w, sin(float32(i) * step) * half_h) + for i in 1 .. nSegments: + pos.add newVec3f(cos(float32(i) * step) * rX, sin(float32(i) * step) * rY) col.add c - result[].smallIndices.add [uint16(0), uint16(i + 1), uint16(i + 2)] + result[].smallIndices.add [uint16(0), uint16(i), uint16(i + 1)] result[].initVertexAttribute(DEFAULT_POSITION_ATTRIBUTE, pos) result[].initVertexAttribute("color", col)
--- a/semicongine/resources.nim Sat Mar 09 23:06:27 2024 +0700 +++ b/semicongine/resources.nim Sun Mar 10 20:02:11 2024 +0700 @@ -1,6 +1,7 @@ +import std/parsecfg import std/streams +import std/algorithm import std/json -import std/algorithm import std/strutils import std/sequtils import std/strformat @@ -183,6 +184,9 @@ proc loadJson*(path: string, package = DEFAULT_PACKAGE): JsonNode = path.loadResource_intern(package = package).readAll().parseJson() +proc loadConfig*(path: string, package = DEFAULT_PACKAGE): Config = + path.loadResource_intern(package = package).loadConfig(filename = path) + proc loadFont*( path: string, name = "",