Initial commit: Transcience MVP
Top-down twin-stick bullet-hell, Godot 4.7, server-authoritative dedicated server with client-side prediction. Clients send input only; the server resolves every hit for both players and enemies (no PvP). - SimWorld: whole simulation as plain RefCounted objects (no nodes, no physics server), ~0.24ms/tick at peak load -- runs headless for free and drives 78 tests in under a second - BulletPool: struct-of-arrays bullet storage, replicated as spawn/despawn events rather than per-tick state - Emitter framework (Ring/AimedSpread/WallGap/ArcSweep) shared by trash enemies and bosses -- a new boss is data in src/content/content.gd, no simulation changes - The Warden of the Fold: stationary 4-phase boss built entirely on that format - Lobby hub with a portal into on-demand dungeon instances; one process hosts the hub plus every concurrent dungeon - Emergency escape: 3s server-owned channel, cancelled by damage - tools/check.sh, test.sh (GUT), smoke.sh (real server + bot clients over ENet), bench.gd; git hooks wired to the same scripts - docs/ARCHITECTURE.md, NETCODE.md, WORKFLOW.md, ROADMAP.md
This commit is contained in:
commit
c4beeae38f
385 files changed
+28725
No files matched your search
@@ -0,0 +1,60 @@
|
||||
extends MultiMeshInstance2D
|
||||
## Draws the whole bullet field in one draw call.
|
||||
##
|
||||
## A bullet hell routinely has a thousand bullets on screen. One Node2D each
|
||||
## would cost more than the simulation does, so the renderer reads the client's
|
||||
## [BulletPool] arrays directly and pushes them into a MultiMesh. The sprite is
|
||||
## generated at runtime, so the project needs no art to run.
|
||||
|
||||
const TEXTURE_SIZE := 32
|
||||
|
||||
var _colors := {
|
||||
SimConfig.KIND_PLAYER_SHOT: Color(0.45, 0.95, 1.0),
|
||||
SimConfig.KIND_ORB: Color(1.0, 0.35, 0.75),
|
||||
SimConfig.KIND_NEEDLE: Color(1.0, 0.85, 0.3),
|
||||
SimConfig.KIND_HEAVY: Color(1.0, 0.45, 0.2),
|
||||
}
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
texture = _make_dot_texture()
|
||||
var mm := MultiMesh.new()
|
||||
mm.transform_format = MultiMesh.TRANSFORM_2D
|
||||
mm.use_colors = true
|
||||
var quad := QuadMesh.new()
|
||||
quad.size = Vector2.ONE
|
||||
mm.mesh = quad
|
||||
mm.instance_count = SimConfig.MAX_BULLETS
|
||||
mm.visible_instance_count = 0
|
||||
multimesh = mm
|
||||
|
||||
|
||||
## A soft-edged disc with a bright core, so overlapping bullets stay readable.
|
||||
func _make_dot_texture() -> ImageTexture:
|
||||
var img := Image.create(TEXTURE_SIZE, TEXTURE_SIZE, false, Image.FORMAT_RGBA8)
|
||||
var centre := Vector2(TEXTURE_SIZE, TEXTURE_SIZE) * 0.5
|
||||
for y in TEXTURE_SIZE:
|
||||
for x in TEXTURE_SIZE:
|
||||
var d := Vector2(x + 0.5, y + 0.5).distance_to(centre) / (TEXTURE_SIZE * 0.5)
|
||||
var alpha := clampf(1.0 - d, 0.0, 1.0)
|
||||
alpha = pow(alpha, 0.6)
|
||||
var core := clampf(1.0 - d * 1.9, 0.0, 1.0)
|
||||
img.set_pixel(x, y, Color(1.0, 1.0, 1.0, alpha).lerp(Color.WHITE, core * 0.8))
|
||||
return ImageTexture.create_from_image(img)
|
||||
|
||||
|
||||
func render_pool(pool: BulletPool) -> void:
|
||||
var mm := multimesh
|
||||
var n := 0
|
||||
for i in pool.high_water:
|
||||
if pool.alive[i] == 0:
|
||||
continue
|
||||
if n >= SimConfig.MAX_BULLETS:
|
||||
break
|
||||
# The texture's visible disc is about 80% of the quad, so scale up a
|
||||
# little to make the drawn radius match the radius used for hits.
|
||||
var d: float = pool.radius[i] * 2.5
|
||||
mm.set_instance_transform_2d(n, Transform2D(0.0, Vector2(d, d), 0.0, pool.pos[i]))
|
||||
mm.set_instance_color(n, _colors.get(pool.kind[i], Color.WHITE))
|
||||
n += 1
|
||||
mm.visible_instance_count = n
|
||||
Reference in new issue
Block a user