AVI

My website code stuff


Project maintained by Locust0 Hosted on GitHub Pages — Theme by mattgraham

HOME


Bombs, Magic and Dialogue

May 18, 2019

I’ve been working hard writing some beautiful code this past week or so. I’ve added bombs which can be remotely detonated and leave realistic trails, magic which absorbs damage and looks awesome, and a new dialogue system.

Bombs

Output sample

First up, bombs. These move until they collide with something or are triggered with another click. They cost a bunch of mana and can’t therefore be spammed. When they explode, they perform a Breadth First Search at their position which respects the solid layer of the world. They then damage all damageable blocks including magic. This method of damage instancing means that only solid blocks prevent explosion damage and all other blocks are damaged as if they weren’t there at all.

Recall that the player never moves, the environment does. So how does the bomb create a trail since its actual pattern of movement isn’t in a straight line? In the following gif I turned on an accurate trail which tracks the actual movement of the bomb in the world.

Output sample

As you can see, the movement of the bomb must account for the movement of the player in order to appear as if it is moving in a straight line. To further this illusion, I wrote some code which forces the bomb’s position to always be relative to the player instead of being relative to the world. I also wrote code which keeps track of the initial angle it was launched at and maintains that so the particle effect will always come out of the back of the bomb.

These two effects make the bomb appear to travel in a straight line.

Fun fact: I needed similar code to force the explosion of the bomb to appear to be stationary.

Output sample

I also added the ability to blow up the bomb in mid-flight. When I implement enemies, I would like the player to be able to damage them with bombs. Ideally, a miss shouldn’t remove all potential damage of that bomb (given how costly they are). The solution is that an additional left click detonates it.


Magic

Output sample

The magic is applied to a new layer of the world with that awesome animated texture. It moves as the other 2 layers do and thus appears grounded. Magic costs mana which is currently represented by the purple glow around the player. This obviously needs to be made much more apparent. Magic also dissipates over time.

The player can draw lines with the right click button which can block damage or cutoff an enemy’s escape.

Another cool idea for magic is the ability to draw runes with the mouse which might have some cool effect.


Dialogue

Output sample

Dialogue is all stored in json format in the project. Essentially, every NPC with dialogue has a name and a list of paragraphs. Each paragraph corresponds to a state and contains a list of sentences to be spoken by that NPC. There is also the optional addition of repeating sentences which will summarize what the NPC just said if spoken to again.

The fact that it’s stored in json means that all dialogue can be in a single location if it ever needs to be translated.

A new problem I’ve been considering recently is how to encode how NPCs transition from state to state. I may encode this information in the json. Each new paragraph would then consist of previous states which transition to this one and condition keywords which represent actions in the game.


HOME