Skip to content

New api #15

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 225 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 209 commits
Commits
Show all changes
225 commits
Select commit Hold shift + click to select a range
80f9922
init new-api
milanjrodd Feb 16, 2025
58118d5
fmt new-api
milanjrodd Feb 16, 2025
126c085
fix types
milanjrodd Feb 16, 2025
fe7fcc1
refactors
milanjrodd Feb 16, 2025
90aaba4
feat scenes
milanjrodd Feb 17, 2025
97fed6d
refactor playerSystem
milanjrodd Feb 17, 2025
abd6532
init velocity system in desktop-game.go
milanjrodd Feb 17, 2025
b4ed6e1
refactor scenes and implement dynamic auto imports for components in …
milanjrodd Feb 18, 2025
234100b
remove pointers to component managers in component list
milanjrodd Feb 18, 2025
a81ce79
update go version and deps
milanjrodd Feb 19, 2025
36292ac
update github master_workflow.yml
milanjrodd Feb 19, 2025
4e22a6b
fix memory issues
milanjrodd Feb 19, 2025
6034af3
refactor huge renaming breaking changes
milanjrodd Feb 20, 2025
962e6e2
feat new api
milanjrodd Feb 21, 2025
ef9f8e0
small changes
milanjrodd Feb 21, 2025
547d9f0
new engine runner
milanjrodd Feb 22, 2025
e845554
refactor render lerp with exp decay function
milanjrodd Feb 22, 2025
997493d
optimize some issues
milanjrodd Feb 23, 2025
e346698
fix pointers
milanjrodd Feb 25, 2025
219d814
fix issues
milanjrodd Feb 25, 2025
35a958f
feat dist build tasks
milanjrodd Feb 26, 2025
05bad1d
feat mem pprof
milanjrodd Feb 26, 2025
e138759
fix huge amount of memory allocation
milanjrodd Feb 26, 2025
9e8e8e4
sandbox sdl and c
milanjrodd Feb 27, 2025
0d4cc5d
feat internal sdl3 cgo test
milanjrodd Feb 28, 2025
c8bacb0
refactor render -> rl-render.go
milanjrodd Feb 28, 2025
debd54a
sdl rulit
milanjrodd Feb 28, 2025
e38f5c9
add HromRu@twitch to the history B)
milanjrodd Mar 1, 2025
e3b4898
feat component-manager-shared.go
milanjrodd Mar 3, 2025
90ac2cd
feat new render.go with sprite sorting
milanjrodd Mar 3, 2025
acd7633
feat ysort system and component
milanjrodd Mar 5, 2025
a58d91f
feat simple collision system
milanjrodd Mar 5, 2025
891a7e5
feat collision events
milanjrodd Mar 6, 2025
640b2c5
feat spatial collision and grid
milanjrodd Mar 6, 2025
6015d46
feat collision-detection.go
milanjrodd Mar 7, 2025
08dfdf0
implement multithreading in collision-detection.go
milanjrodd Mar 8, 2025
fc605fc
hot fix entity array out of bounds collision-detection.go
milanjrodd Mar 9, 2025
92850e3
fix collision-detection, set proper amount of workers, and check enti…
rkuzovlev Mar 9, 2025
ae4a1dc
collision-detection do not process same entity in different workers
rkuzovlev Mar 9, 2025
bd93006
feat assterodd game
milanjrodd Mar 9, 2025
0d58cb8
change batch size + move wg.Add
rkuzovlev Mar 10, 2025
0219b26
Merge pull request #16 from rkuzovlev/new-api
milanjrodd Mar 10, 2025
60fe87d
include donations 10.03.2025
milanjrodd Mar 11, 2025
d0098e8
yolo
milanjrodd Mar 13, 2025
f0ac2b8
feat bvh system collision-detection-bvh.go
milanjrodd Mar 14, 2025
fc7d3d3
refactor collision-detection-bvh.go to use stack instead of function …
milanjrodd Mar 14, 2025
d746766
small optimizations
milanjrodd Mar 14, 2025
b833dab
refactor collision-detection-bvh.go - implement layers for trees
milanjrodd Mar 15, 2025
c233834
optimize bvh tree
milanjrodd Mar 15, 2025
9bb6f60
fix window render
milanjrodd Mar 15, 2025
4a27e59
better collision mask and layer system
milanjrodd Mar 15, 2025
7be447d
add steamworks api
milanjrodd Mar 18, 2025
49d79dd
collision-detection-bvh.go implement GJK
milanjrodd Mar 18, 2025
9c57aa4
collision-detection-bvh.go implement epa - collision depth and normal
milanjrodd Mar 18, 2025
7301dd7
collision-detection-bvh.go fix bvh and epa for 2d space
milanjrodd Mar 20, 2025
0f3af9e
collision-detection-bvh.go fix tp issue
milanjrodd Mar 20, 2025
967a546
collision-detection-bvh.go 4 hours of aabb size fixing, please help
milanjrodd Mar 22, 2025
614dbd8
collision-detection-bvh.go small fixes
milanjrodd Mar 23, 2025
f3564a6
fix naming collisions
milanjrodd Mar 23, 2025
46ff981
fix taskfile dev cmd
milanjrodd Mar 23, 2025
3f5683e
feat gjk package amd refactor collision detection system
milanjrodd Mar 24, 2025
86730e6
update vscode settings
milanjrodd Mar 25, 2025
3f266a9
upd epa
milanjrodd Mar 25, 2025
1bfcac6
refactor epa
milanjrodd Mar 25, 2025
096b09b
add gjk+epa doc links
milanjrodd Mar 25, 2025
7b81b41
fix epa teleportation and panic
milanjrodd Mar 25, 2025
32d8273
implement circle colliders
milanjrodd Mar 25, 2025
93b4499
update mac build task
milanjrodd Mar 25, 2025
03746fb
refactor - small changes
milanjrodd Mar 25, 2025
ab5c159
gjk - fix circle collider support function
milanjrodd Mar 26, 2025
0bed522
feat(audio): added some self-made SFX for asterodds
thearturca Mar 26, 2025
96aae0b
rigid body mass fun
bitver Mar 26, 2025
e91a0b2
Merge remote-tracking branch 'rodd-oss/new-api' into new-api
bitver Mar 26, 2025
f204b34
upd chatting
milanjrodd Mar 26, 2025
28bb6e6
Merge pull request #17 from thearturca/feat/new-api-audio-system
milanjrodd Mar 26, 2025
835fc8e
Merge remote-tracking branch 'origin/new-api' into new-api
bitver Mar 26, 2025
5832860
rigid body mass fun
bitver Mar 26, 2025
3bd3d51
Merge pull request #19 from bitver/new-api
milanjrodd Mar 26, 2025
dcea177
optimize collision detection system
milanjrodd Mar 26, 2025
95a7805
implement circle to circle collision strategy
milanjrodd Mar 26, 2025
66bb6a5
upd tree
milanjrodd Mar 27, 2025
6d816f2
update bvhtree
milanjrodd Mar 27, 2025
be1cb24
upd bvhtree
milanjrodd Mar 27, 2025
53918e3
remove deprecated
milanjrodd Mar 27, 2025
af70d93
rename bvh tree
milanjrodd Mar 27, 2025
d27aad4
small updates
milanjrodd Mar 27, 2025
0a03a29
refactor bvh tree build function - x9 performance
milanjrodd Mar 28, 2025
abe69dd
refactor bvh tree - use pagedArray for nodes
milanjrodd Mar 28, 2025
383adee
refactor bvh tree - from slices to pagedArrays
milanjrodd Mar 28, 2025
03cbe5c
feat collision sleep system
milanjrodd Mar 30, 2025
0b257f5
refactor(audio): implements audio in ecs-way
thearturca Mar 30, 2025
7e0a145
update sdl3 purego and cgo internals
milanjrodd Mar 30, 2025
e53a3e9
fix: minor rename
thearturca Mar 30, 2025
26c4984
Merge pull request #20 from thearturca/feat/ecs-implement-of-audio-sy…
milanjrodd Mar 30, 2025
7e2fa06
fix(sound-effects-manager): rename component id
thearturca Mar 30, 2025
3cd53f0
Merge pull request #21 from thearturca/feat/ecs-implement-of-audio-sy…
milanjrodd Mar 30, 2025
6a6ec9e
update sdl3 purego and cgo internals
milanjrodd Mar 30, 2025
2fd7689
feat sdl purego zukko internal test
milanjrodd Mar 30, 2025
9835d08
feat ebiten internal test
milanjrodd Mar 30, 2025
f63de3f
feat sdl2 internal test
milanjrodd Mar 31, 2025
4dd954d
+perf
bitver Mar 31, 2025
2436b07
Merge pull request #22 from bitver/new-api-test
milanjrodd Mar 31, 2025
76d17e6
upd bvh tree
milanjrodd Mar 31, 2025
f309722
upd collision detection massive reallocations
milanjrodd Mar 31, 2025
b9205b1
pre bvh tree fix
milanjrodd Apr 1, 2025
3ed7154
bvh tree fix
milanjrodd Apr 1, 2025
792a64b
fix bvh collision checks
milanjrodd Apr 1, 2025
66e4bad
add leaf aabb check to bvh tree
milanjrodd Apr 1, 2025
ac4214c
upd
milanjrodd Apr 4, 2025
4b00a45
fix collider.go cgo issue
milanjrodd Apr 4, 2025
33c80f3
feat velocity system asserts
milanjrodd Apr 5, 2025
eebf4fe
feat debugTree const for collision-detection-bvh.go
milanjrodd Apr 5, 2025
2288801
feat bvh tree asserts
milanjrodd Apr 5, 2025
0326177
update asterodd.go inits
milanjrodd Apr 5, 2025
b6228f2
init game refactor
milanjrodd Apr 5, 2025
77cc919
refactor world to render injection
milanjrodd Apr 6, 2025
7b1edde
ftm game.go
milanjrodd Apr 6, 2025
3aafeb4
fix fixUpdate rapid effect after fps drop
milanjrodd Apr 6, 2025
80d576a
init grid and bvh component
milanjrodd Apr 6, 2025
d33f37f
upd collision-detection.go implement grid and tree setup sub system
milanjrodd Apr 7, 2025
2268368
init slice.go
milanjrodd Apr 9, 2025
3632e01
upd ecs slice
milanjrodd Apr 9, 2025
1a52849
feat slice.go
milanjrodd Apr 9, 2025
6837164
upd collision-detection.go
milanjrodd Apr 10, 2025
044bdf8
+cameras
bitver Apr 10, 2025
a347763
Merge branch 'new-api' into local-new-api
bitver Apr 10, 2025
c2a1653
merge fix
bitver Apr 10, 2025
9221749
fix bvh-tree.go stack limit
milanjrodd Apr 11, 2025
1a18f56
lil optimization
bitver Apr 11, 2025
fd6b4c6
pre-merge
bitver Apr 12, 2025
f4bf154
Merge branch 'new-api' into local-new-api
bitver Apr 12, 2025
3587716
pre-merge
bitver Apr 12, 2025
054973b
random crash fix
bitver Apr 12, 2025
b8a760c
return non-perfomant systems
bitver Apr 12, 2025
62cb525
clean
bitver Apr 12, 2025
7a02935
wip
bitver Apr 12, 2025
5d74d64
center
bitver Apr 12, 2025
8613555
mini fix
bitver Apr 12, 2025
88de518
mini fix
bitver Apr 12, 2025
d1706cd
update lvl
milanjrodd Apr 12, 2025
ed432cb
Merge pull request #26 from bitver/local-new-api
milanjrodd Apr 12, 2025
fee320e
Merge pull request #27 from rodd-oss/local-new-api
milanjrodd Apr 12, 2025
90cacc7
refactor render-2d-cameras.go for better performance
milanjrodd Apr 12, 2025
3442d49
breaking changes - component-manager.go rename Get() to GetUnsafe()
milanjrodd Apr 14, 2025
747ff47
component-manager.go add safe Get() method
milanjrodd Apr 14, 2025
bc754c4
breaking changes component-manager.go rename Remove() to Delete()
milanjrodd Apr 14, 2025
f8be29b
breaking changes component-manager.go each parallel batchsize -> numW…
milanjrodd Apr 14, 2025
248bfb8
breaking changes paged-array.go rename iters
milanjrodd Apr 14, 2025
b3a6479
breaking changes - refactor iterators
milanjrodd Apr 14, 2025
43e6fbb
massive optimizations
milanjrodd Apr 14, 2025
29dd608
small memaloc fixes
milanjrodd Apr 14, 2025
77d3926
+perf?
bitver Apr 15, 2025
4d383a0
Merge pull request #23 from bitver/new-api
milanjrodd Apr 15, 2025
bedf07e
init pkg/worker - pool, task & worker
milanjrodd Apr 15, 2025
dea9544
feat workers
milanjrodd Apr 17, 2025
1c34304
fix numworkers
milanjrodd Apr 17, 2025
9123a49
update worker pool performance
milanjrodd Apr 17, 2025
a869059
add donations
milanjrodd Apr 19, 2025
e61194c
fmt
milanjrodd Apr 19, 2025
7d654b5
update workers and pool
milanjrodd Apr 19, 2025
ff9bd06
breaking changes - iter EachParallel is now Process method
milanjrodd Apr 20, 2025
a0e7a74
fix pool nil pointer
milanjrodd Apr 20, 2025
233d4f3
feat worker pool GroupAdd() method
milanjrodd Apr 20, 2025
21141e3
optimize memory allocation
milanjrodd Apr 20, 2025
4a31572
implement map.go - which is LESS PERFORMANT than paged-map.go
milanjrodd Apr 20, 2025
752cf05
implement flat multithreaded collision setup in collision-detection.go
milanjrodd Apr 23, 2025
0852389
rename collision-detection.go to collision-setup.go
milanjrodd Apr 24, 2025
7edccb6
feat collision-detection.go
milanjrodd Apr 24, 2025
3804dd0
fix allocation issues
milanjrodd Apr 24, 2025
1e60961
fix: value direct memory call
milanjrodd Apr 24, 2025
21f6bd0
docs - add comments
milanjrodd Apr 25, 2025
a08654f
fix multithreading
milanjrodd Apr 25, 2025
75fb158
fewer allocations
bitver Apr 25, 2025
80af469
Merge branch 'new-api' into new-api-local
bitver Apr 25, 2025
17ae43a
feat: chunked bit table
bitver Apr 26, 2025
643fe0d
feat i <3 my twitch chat babies
milanjrodd Apr 26, 2025
25dbcc5
update race_test.go
milanjrodd Apr 26, 2025
275b015
update race_test.go
milanjrodd Apr 26, 2025
4bd1159
add: component-byte-table.go
bitver Apr 26, 2025
8b25a13
tests
bitver Apr 26, 2025
9ee0fdb
tests
bitver Apr 26, 2025
e688d4f
Merge pull request #28 from bitver/new-api-local
milanjrodd Apr 26, 2025
a729294
scroll
bitver Apr 26, 2025
6dd64e8
Merge pull request #29 from bitver/new-api-local
milanjrodd Apr 26, 2025
f7902cf
fix culling
bitver Apr 26, 2025
7c5422b
Merge pull request #30 from bitver/new-api-local
milanjrodd Apr 26, 2025
db10d9a
fix scroll
milanjrodd Apr 27, 2025
4198977
faster and more reliable bitset
bitver Apr 30, 2025
8bbb574
rocket science
bitver Apr 30, 2025
d291a00
bench test the goasm and cgo calls
milanjrodd May 2, 2025
ec96dab
wanna perf?
bitver May 2, 2025
a18d097
Merge pull request #32 from bitver/bittable
milanjrodd May 2, 2025
067abb9
Merge remote-tracking branch 'origin/new-api' into new-api
milanjrodd May 2, 2025
cf84f1b
micro optimizations
bitver May 2, 2025
3a43bf9
fps
bitver May 2, 2025
b22473f
Merge remote-tracking branch 'origin/new-api' into new-api
bitver May 2, 2025
b66ec1f
Merge pull request #33 from bitver/fps
milanjrodd May 3, 2025
4bade53
Merge remote-tracking branch 'origin/new-api' into new-api
milanjrodd May 3, 2025
a491066
feat collision-setup.go
milanjrodd May 3, 2025
88eff30
Merge remote-tracking branch 'origin/new-api' into new-api
bitver May 3, 2025
0a4c967
refactor(spatial-audio): adds volume calculation and fix volume control
thearturca Apr 27, 2025
4de6c17
chore(dev): adds asserts on GetUnsafe components
thearturca Apr 27, 2025
5744efe
docs(sound-effect): adds more description on component fields
thearturca Apr 27, 2025
46aa58f
refactor(spatial-audio): rewrite SpatialAudioSystem to parallel proce…
thearturca Apr 27, 2025
697ed2a
feat(sound-effects): adds sound for satellite to demo SpatialAudioSystem
thearturca Apr 27, 2025
1b6234b
refactor(audio-system): rewrite AudioSystem to use parallel processing
thearturca Apr 27, 2025
0b80f39
lowest
bitver May 4, 2025
7b92d84
Merge pull request #34 from bitver/bittable
milanjrodd May 4, 2025
c75a82e
fastest log2 on wild west
bitver May 4, 2025
b7e2a51
minor changes
milanjrodd May 4, 2025
096131f
Merge remote-tracking branch 'origin/new-api' into new-api
bitver May 4, 2025
ca8bdc8
fastest log2 on wild west
bitver May 4, 2025
8f3526d
Merge pull request #35 from bitver/bittable
milanjrodd May 4, 2025
cf54441
feat collision-detection.go
milanjrodd May 4, 2025
5404d06
optimizations for collision detection
milanjrodd May 4, 2025
e63b1a4
Merge pull request #31 from thearturca/refactor/audio-system
milanjrodd May 5, 2025
430d201
optimizations for collision detection
milanjrodd May 5, 2025
2b7ca75
resize
bitver May 6, 2025
e55bb98
Merge pull request #36 from bitver/bittable
milanjrodd May 8, 2025
f5d9ed9
minor chores
milanjrodd May 8, 2025
fe01bd8
init internal wasyan
milanjrodd May 14, 2025
f22852b
revert to old iterators
bitver May 14, 2025
2b6cdb6
add test wasyan
milanjrodd May 15, 2025
c5b5650
update wasyan
milanjrodd May 15, 2025
10ccef8
Merge pull request #37 from bitver/new-api
milanjrodd May 16, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/master_workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
fail-fast: false
matrix:
os: [ 'ubuntu-latest' ]
go-version: [ '1.23.5' ]
go-version: [ '1.24.0' ]
uses: ./.github/workflows/go_ci.yml
with:
go-version: ${{ matrix.go-version }}
Expand All @@ -21,4 +21,4 @@ jobs:
security-analysis:
uses: ./.github/workflows/gosec_security_check.yml
with:
go-version: '1.23.5'
go-version: '1.24.0'
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"request": "launch",
"mode": "debug",
"buildFlags": "-tags 'assert'",
"program": "./cmd/raylib-ecs"
"program": "./examples/new-api"
}
]
}
Binary file added Roboto-SemiBold.ttf
Binary file not shown.
181 changes: 181 additions & 0 deletions aos_soa_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,181 @@
/*
This Source Code Form is subject to the terms of the Mozilla
Public License, v. 2.0. If a copy of the MPL was not distributed
with this file, You can obtain one at http://mozilla.org/MPL/2.0/.

===-===-===-===-===-===-===-===-===-===
Donations during this file development:
-===-===-===-===-===-===-===-===-===-===

none :)

Thank you for your support!
*/

package gomp

import (
"math/rand"
"testing"
)

type Float3 struct {
X, Y, Z float64
}

// Array of Structures (AoS)
type Unit struct {
Pos Float3
Velocity Float3
HP int
Offset [AdditionalDataPer64]int64
}

type UnitsAoS struct {
Units []Unit
}

// Structure of Arrays (SoA)
type UnitsSoA struct {
Positions [][pageSize]Float3
Velocities [][pageSize]Float3
HPs [][pageSize]int
Offsets [][pageSize][AdditionalDataPer64]int64
}

func UpdatePosition(pos *Float3, velocity *Float3) {
pos.X += velocity.X
pos.Y += velocity.Y
pos.Z += velocity.Z
}

func TakeDamage(hp *int, damage int) {
*hp = max(0, *hp-damage)
}

func UpdateOffset(offset *[AdditionalDataPer64]int64) {
for i := range offset {
offset[i]++
}
}

func ShouldRender(pos *Float3) bool {
return pos.X > 10.0 && pos.Y < 5.0 && pos.Z > 0.0
}

func GenerateUnitsAoS(count int) UnitsAoS {
units := UnitsAoS{Units: make([]Unit, count)}
for i := 0; i < count; i++ {
units.Units[i] = Unit{
Pos: Float3{
X: rand.Float64()*40 - 20,
Y: rand.Float64()*40 - 20,
Z: rand.Float64()*40 - 20,
},
Velocity: Float3{
X: rand.Float64()*2 - 1,
Y: rand.Float64()*2 - 1,
Z: rand.Float64()*2 - 1,
},
HP: rand.Intn(151) + 50,
}
}
return units
}

func MakeUnitsSoA(aos UnitsAoS) UnitsSoA {
soa := UnitsSoA{
Positions: make([][pageSize]Float3, len(aos.Units)/pageSize+1),
Velocities: make([][pageSize]Float3, len(aos.Units)/pageSize+1),
HPs: make([][pageSize]int, len(aos.Units)/pageSize+1),
Offsets: make([][pageSize][AdditionalDataPer64]int64, len(aos.Units)/pageSize+1),
}

for i, unit := range aos.Units {
a, b := i>>pageShift, i%pageSize
soa.Positions[a][b] = unit.Pos
soa.Velocities[a][b] = unit.Velocity
soa.HPs[a][b] = unit.HP
soa.Offsets[a][b] = unit.Offset
}
return soa
}

func PositionSystem(positions [][pageSize]Float3, velocities [][pageSize]Float3) {
for i := 0; i < len(positions); i++ {
for j := 0; j < len(positions[i]); j++ {
UpdatePosition(&positions[i][j], &velocities[i][j])
}
}
}

func TakeDamageSystem(hps [][pageSize]int) {
for i := 0; i < len(hps); i++ {
for j := 0; j < len(hps[i]); j++ {
TakeDamage(&hps[i][j], 33)
}
}
}

func OffsetSystem(offsets [][pageSize][AdditionalDataPer64]int64) {
for i := 0; i < len(offsets); i++ {
for j := 0; j < len(offsets[i]); j++ {
UpdateOffset(&offsets[i][j])
}
}
}

func renderSystem(positions [][pageSize]Float3, unitsToRender []int) {
for i := 0; i < len(positions); i++ {
for j := 0; j < len(positions[i]); j++ {
if ShouldRender(&positions[i][j]) {
index := j + i*len(positions[i])
unitsToRender = append(unitsToRender, index)
}
}
}
}

// RuDimbo Team
func BenchmarkUpdateRuDimbo(b *testing.B) {
b.ReportAllocs()

units := GenerateUnitsAoS(NumOfEntities)
unitsToRender := make([]int, 0, NumOfEntities)

for b.Loop() {
for i := range units.Units {
unit := &units.Units[i]
UpdatePosition(&unit.Pos, &unit.Velocity)
if ShouldRender(&unit.Pos) {
unitsToRender = append(unitsToRender, i)
}
TakeDamage(&unit.HP, 33)
UpdateOffset(&unit.Offset)
}
unitsToRender = unitsToRender[:0]
}
}

// Rodd Team
func BenchmarkUpdateRodd(b *testing.B) {
b.ReportAllocs()
soaUnits := MakeUnitsSoA(GenerateUnitsAoS(NumOfEntities))
unitsToRender := make([]int, 0, NumOfEntities)
for b.Loop() {
positions := soaUnits.Positions
velocities := soaUnits.Velocities
hps := soaUnits.HPs
offsets := soaUnits.Offsets
PositionSystem(positions, velocities)
TakeDamageSystem(hps)
OffsetSystem(offsets)
renderSystem(positions, unitsToRender)
unitsToRender = unitsToRender[:0]
}
}

const NumOfEntities = 10_000_000
const AdditionalDataPer64 = 30
const pageShift = 10
const pageSize = 1 << pageShift
12 changes: 5 additions & 7 deletions pkg/ecs/asset-library.go → asset-library.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@ Public License, v. 2.0. If a copy of the MPL was not distributed
with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/

package ecs
package gomp

import (
"fmt"

"github.com/negrel/assert"
)

Expand All @@ -18,8 +16,8 @@ type AnyAssetLibrary interface {
UnloadAll()
}

func CreateAssetLibrary[T any](loader func(path string) T, unloader func(path string, asset *T)) *AssetLibrary[T] {
return &AssetLibrary[T]{
func CreateAssetLibrary[T any](loader func(path string) T, unloader func(path string, asset *T)) AssetLibrary[T] {
return AssetLibrary[T]{
data: make(map[string]*T),
loader: loader,
unloader: unloader,
Expand Down Expand Up @@ -47,7 +45,7 @@ func (r *AssetLibrary[T]) Get(path string) *T {

func (r *AssetLibrary[T]) Load(path string) {
_, ok := r.data[path]
assert.False(ok, fmt.Errorf("asset already loaded: %s", path))
assert.False(ok, "asset already loaded")

resource := r.loader(path)
r.data[path] = &resource
Expand All @@ -68,7 +66,7 @@ func (r *AssetLibrary[T]) LoadAll() {

func (r *AssetLibrary[T]) Unload(path string) {
value, ok := r.data[path]
assert.True(ok, fmt.Errorf("asset not loaded: %s", path))
assert.True(ok, "asset not loaded")
r.unloader(path, value)
delete(r.data, path)
}
Expand Down
Binary file added assets/test.ttf
Binary file not shown.
53 changes: 53 additions & 0 deletions desktop-components.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
This Source Code Form is subject to the terms of the Mozilla
Public License, v. 2.0. If a copy of the MPL was not distributed
with this file, You can obtain one at http://mozilla.org/MPL/2.0/.

===-===-===-===-===-===-===-===-===-===
Donations during this file development:
-===-===-===-===-===-===-===-===-===-===

none :)

Thank you for your support!
*/

package gomp

import (
"gomp/stdcomponents"
)

func NewDesktopComponents() DesktopComponents {
return DesktopComponents{
Position: stdcomponents.NewPositionComponentManager(),
Rotation: stdcomponents.NewRotationComponentManager(),
Scale: stdcomponents.NewScaleComponentManager(),
Velocity: stdcomponents.NewVelocityComponentManager(),
Flip: stdcomponents.NewFlipComponentManager(),
Sprite: stdcomponents.NewSpriteComponentManager(),
SpriteSheet: stdcomponents.NewSpriteSheetComponentManager(),
SpriteMatrix: stdcomponents.NewSpriteMatrixComponentManager(),
Tint: stdcomponents.NewTintComponentManager(),
AnimationPlayer: stdcomponents.NewAnimationPlayerComponentManager(),
AnimationState: stdcomponents.NewAnimationStateComponentManager(),
RlTexturePro: stdcomponents.NewRlTextureProComponentManager(),
Network: stdcomponents.NewNetworkComponentManager(),
}
}

type DesktopComponents struct {
Position stdcomponents.PositionComponentManager
Rotation stdcomponents.RotationComponentManager
Scale stdcomponents.ScaleComponentManager
Velocity stdcomponents.VelocityComponentManager
Flip stdcomponents.FlipComponentManager
Sprite stdcomponents.SpriteComponentManager
SpriteSheet stdcomponents.SpriteSheetComponentManager
SpriteMatrix stdcomponents.SpriteMatrixComponentManager
Tint stdcomponents.TintComponentManager
AnimationPlayer stdcomponents.AnimationPlayerComponentManager
AnimationState stdcomponents.AnimationStateComponentManager
RlTexturePro stdcomponents.RLTextureProComponentManager
Network stdcomponents.NetworkComponentManager
}
24 changes: 24 additions & 0 deletions engine.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
This Source Code Form is subject to the terms of the Mozilla
Public License, v. 2.0. If a copy of the MPL was not distributed
with this file, You can obtain one at http://mozilla.org/MPL/2.0/.

===-===-===-===-===-===-===-===-===-===
Donations during this file development:
-===-===-===-===-===-===-===-===-===-===

<- HromRu Donated 2500 RUB
<- HromRu Donated 5000 RUB

Thank you for your support!
*/

package gomp

import (
"gomp/pkg/core"
)

func NewEngine(game core.AnyGame) core.Engine {
return core.NewEngine(game)
}
Loading
Loading