Best PC games New PC games 2020 Best graphics card 2020 Best free games 70 Call Of Duty: Warzone tips Borderlands 3 characters & skill trees


How Spelunky Creates Amazing Unexpected Situations

From code to chaos

Featured post

Spelunky’s entity code

To give you an idea of how Spelunky understands its objects’ properties, Derek Yu and Andy Hull have given RPS access to part of the remake’s source code, something that hasn’t been revealed before. Here are the defining characteristics of Olmec and the shopkeeper.


The ‘tough’ flag denotes that the shopkeeper is impervious to whip attacks. You can also see what governs the fact he has a shotgun and how you can’t pick him up.


em = create_entity_monster(x, y, type, TEX_MONSTERS, ANIMSET_SHOPKEEPER, MONS_SIZE_SMALL, 0.2f, 0.5f, 0.4f, 10, 1, MONS_WEIGHT_MED, 6);
em->canBeStunned = true;
em->tough = true;
em->isHoldable = false;

if (wantedLevel > 0)

em->state = ENT_STATE_PATROL;
em->heldEntity = (EntityItem *)create_entity(x, y, ENT_TYPE_ITEM_SHOTGUN, true);
em->heldEntity->holder = em;
// em->heldEntity->heldOffset = Vector2(0.25f, -0.35f);
em->hasGun = false;
em->state = ENT_STATE_IDLE;
em->hasGun = true;
em->passive = true;
e = (Entity *)em;


You can see the flags that tell the game that you can’t web him, hold him, crush him – the rest of his properties are defined by his true nature as a push-block.


ei = new EntityItem(x, y, 1.0f, 1.0f);
ei->subtype = type;
ei->texture = textureManager->get_texture(TEX_OLMEC);
ei->height = 4.00f;
ei->width = 4.00f;
ei->collisionDown = 4.0f/2.0f;
ei->collisionUp = 3.0f/2.0f;
ei->collisionSide = 3.5f/2.0f;
ei->solid = true;
ei->stunned = true;
ei->canExplode = true;
ei->isHoldable = false;
ei->heavy = 0.0f;
ei->collideWithActive = true;
ei->invincible = true;
ei->canExplode = false;
ei->depth = DEPTH_CLIMBABLE – 0.5f;
ei->crushable = false;
ei->isReflective = true;
ei->state = ENT_STATE_RECOVER;
ei->canBeWebbed = false;
//ei->collideWithFloor = false;
//ei->flying = true;
e = (Entity *)ei;

Page 1Page 2

Tagged with , , , , , .

If you click our links to online stores and make a purchase we may receive a few pennies. Find more information here.

Who am I?

Alex Wiltshire

Mechanic Man

Alex Wiltshire writes about videogames and design, is a former editor of Edge, is author of Minecraft Blockopedia and Mobestiary, and edited Britsoft: An Oral History.

More by me

Support RPS and get an ad-free site, extra articles, and free stuff! Tell me more
Please enable Javascript to view comments.

Comments are now closed. Go have a lie down, Internet.