Crowd Runner. Example with up to 32000 entities

Crowd Runner Example

Defold example with up to 32765 entities support with simple physics

Links:

About

The example was created from this video:

ref_video

And we tried to build the same stuff on Defold. For now it’s kind of example and benchmark to see how we can use a lot of entities at once time.
You can see the code comments and how it’s implemented here: https://github.com/Insality/crowd-runner-defold/blob/main/game/system.script

The example have two toggler:

  • Skip update - the entities which far away from the player call update less frequently (up to zero times)
  • Draw outside - the entities which far away from player is disabled (only sprite component). You can check how it affects on game performance. Since the culling is introduced, seems it’s not very valuable, but anyway increase performance a little

Control:

WASD or touch the screen for move
P - Profiler
Or use on-screen buttons

game

Sprites generated by pixeldudesmaker: pixeldudesmaker by 0x72

29 Likes

I tried running this using 1.9.1 on Ubuntu and it fell over with build errors:

/usr/bin/ld: /var/extender/sdk/691478c02875b80e76da65d2f5756394e7a906b1/defoldsdk//lib/x86_64-linux/libscript_box2d.a(script_box2d_body.cpp.2.o): in function `dmGameSystem::Body_SetTransform(lua_State*)':
	Line 105: undefined reference to `b2Body::SetTransform(b2Vec2 const&, float)'
	Line 105: /usr/bin/ld: /var/extender/sdk/691478c02875b80e76da65d2f5756394e7a906b1/defoldsdk//lib/x86_64-linux/libscript_box2d.a(script_box2d_body.cpp.2.o): in function `b2Body::SetFixedRotation(bool)':
	Line 105: undefined reference to `b2Body::ResetMassData()'
	Line 105: /usr/bin/ld: /var/extender/sdk/691478c02875b80e76da65d2f5756394e7a906b1/defoldsdk//lib/x86_64-linux/libscript_box2d.a(script_box2d_body.cpp.2.o): in function `dmGameSystem::Body_SetActive(lua_State*)':
	Line 105: undefined reference to `b2Body::SetActive(bool)'
	Line 105: /usr/bin/ld: /var/extender/sdk/691478c02875b80e76da65d2f5756394e7a906b1/defoldsdk//lib/x86_64-linux/libscript_box2d.a(script_box2d_body.cpp.2.o): in function `dmGameSystem::Body_SetType(lua_State*)':
	Line 105: undefined reference to `b2Body::SetType(b2BodyType)'
	Line 105: /usr/bin/ld: /var/extender/sdk/691478c02875b80e76da65d2f5756394e7a906b1/defoldsdk//lib/x86_64-linux/libscript_box2d.a(script_box2d_body.cpp.2.o): in function `dmGameSystem::Body_Dump(lua_State*)':
	Line 105: undefined reference to `b2Body::Dump()'
	Line 105: clang++: error: linker command failed with exit code 1 (use -v to see invocation)
	Line 105: com.defold.extender.ExtenderException: java.io.IOException: clang++ -DDLIB_LOG_DOMAIN="UNKNOWN" -DDDF_EXPOSE_DESCRIPTORS -DDM_PLATFORM_LINUX -D__STDC_LIMIT_MACROS  -g -O2 -D__STDC_LIMIT_MACROS -Wall -Werror=format -fno-exceptions -fPIC -fvisibility=hidden   -I/var/extender/sdk/691478c02875b80e76da65d2f5756394e7a906b1/defoldsdk//include -I/var/extender/sdk/691478c02875b80e76da65d2f5756394e7a906b1/defoldsdk//sdk/include -I/var/extender/sdk/691478c02875b80e76da65d2f5756394e7a906b1/defoldsdk//ext/include -I/var/extender/sdk/691478c02875b80e76da65d2f5756394e7a906b1/defoldsdk//include/x86_64-linux  build/main.cpp -c -o build/main_tmp0.o
clang++ build/main_tmp0.o  -o build/dmengine -g -O2  -L/tmp/job3602068856061513152/build  -L/var/extender/sdk/691478c02875b80e76da65d2f5756394e7a906b1/defoldsdk//lib/x86_64-linux -L/var/extender/sdk/691478c02875b80e76da65d2f5756394e7a906b1/defoldsdk//ext/lib/x86_64-linux  -Wl,-Bstatic -Wl,--start-group -lengine -lengine_service -lmbedtls -lzip -lprofile -lremotery -lprofilerext -lgameobject -lddf -lresource -lgamesys -lscript_box2d -lgraphics -lgraphics_transcoder_basisu -lbasis_transcoder -lplatform -lrender -lscript -lluajit-5.1 -lextension -lhid -linput -lparticle -lrig -ldlib -ldmglfw -lgui -lcrashext  -lphysics_null -lrecord_null -lsound_null -lliveupdate_null   -Wl,--end-group -Wl,-Bdynamic -Wl,-rpath=$ORIGIN,--enable-new-dtags  -lopenal -lXext -lX11 -lXi -lGL -lGLU -lpthread -lm -ldl
	Line 105: /usr/bin/ld: /var/extender/sdk/691478c02875b80e76da65d2f5756394e7a906b1/defoldsdk//lib/x86_64-linux/libscript_box2d.a(script_box2d_body.cpp.2.o): in function `dmGameSystem::Body_SetTransform(lua_State*)':

and

/game/system.script
	Line 152: Need check nil.
	Line 152: Undefined field `position_x`.
	Line 153: Need check nil.
	Line 153: Undefined field `position_y`.
	Line 253: Fields cannot be injected into the reference of `nil` for `move_vector_x`. To do so, use `---@class` for `player_entity`.
	Line 257: Fields cannot be injected into the reference of `nil` for `move_vector_x`. To do so, use `---@class` for `player_entity`.
	Line 261: Fields cannot be injected into the reference of `nil` for `move_vector_y`. To do so, use `---@class` for `player_entity`.
	Line 265: Fields cannot be injected into the reference of `nil` for `move_vector_y`. To do so, use `---@class` for `player_entity`.
	Line 275: Fields cannot be injected into the reference of `nil` for `move_vector_x`. To do so, use `---@class` for `player_entity`.
	Line 277: Fields cannot be injected into the reference of `nil` for `move_vector_x`. To do so, use `---@class` for `player_entity`.
	Line 280: Fields cannot be injected into the reference of `nil` for `move_vector_y`. To do so, use `---@class` for `player_entity`.
	Line 282: Fields cannot be injected into the reference of `nil` for `move_vector_y`. To do so, use `---@class` for `player_entity`.

I failed to work out the reason this occurs or how to fix it, any ideas?
Thanks.

The first block said that there is an error in box2d for linux, seems to be Defold related

I updated the example with new appmanifest file which excludes physics library, you can check is it works or not

The second block of errors is only linter related and should be also fixed

2 Likes

Thanks, that fixed it.

2 Likes