Small Dragons for more movement

Small Dragons for more movement

To add a bit more movement to the image, I animated little dragons. Their sole purpose is to break up the game’s visuals a bit.

Fairy Dragons

Initially, I planned only one species of dragon, which then evolved into three more—at the current stage. I plan to create many more later, as it’s fun to interpret new fairy dragons.

To start with, I created three fairy dragons with very different colors. This helped me write the function for automatic allocation. The small dragons are called into the picture using a single variable. This means I set State.Schmetterlinge = 149, and each of the dragons gets 49 partners of its species. The remaining two dragons are allocated to the first species. In the end, there are 49 monarch butterfly dragons, 49 bumblebee dragons, and 52 swallowtail dragons within the player’s camera range.

The large number here is just for illustration; I use 3 to 15 butterflies in the game, depending on my progress. The number of dragons will also be based on a karma system. I plan to increase the number of dragons if the player behaves positively towards the game world. If the player behaves negatively, an event is also planned for the system, but that still needs to be finalized.

The fairy dragons will despawn when they are outside the player’s camera and respawn at a random location on the edge of the camera. This prevents the dragons from consuming memory outside the camera and from all being on one side of the map.

Behavior towards the user interface

In the game, the little dragons are positioned above the player, making them appear as if they’re flying. However, it’s also important that they’re positioned below the text box or other user interface elements. Otherwise, they would hinder the readability of the user interface.

I solved this by placing the game and user interface in separate scenes with different z-indexes.

The text box was covered in another article:
RPG – Textbox and how it was implemented

func spawnBox():
	if State.Shared_Character_Position != null:
		if global_position.x >= State.Shared_Character_Position.x + spawnBoxVector.x or global_position.x <= State.Shared_Character_Position.x - spawnBoxVector.x or global_position.y >=  State.Shared_Character_Position.y + spawnBoxVector.y or global_position.y <= State.Shared_Character_Position.y - spawnBoxVector.y:
			if $"..".rollPosition == 0:
				global_position = Vector2(State.Shared_Character_Position.x + spawnBoxVector.x -10, randi_range(State.Shared_Character_Position.y - spawnBoxVector.y, State.Shared_Character_Position.y + spawnBoxVector.y)) #Rechts
			elif $"..".rollPosition == 1:
				global_position = Vector2(State.Shared_Character_Position.x - spawnBoxVector.x +10,randi_range(State.Shared_Character_Position.y - spawnBoxVector.y, State.Shared_Character_Position.y + spawnBoxVector.y)) #Links
			elif  $"..".rollPosition == 2:
				global_position = Vector2(randi_range(State.Shared_Character_Position.x - spawnBoxVector.x, State.Shared_Character_Position.x + spawnBoxVector.x),State.Shared_Character_Position.y + spawnBoxVector.y -10) #Unten
			elif $"..".rollPosition == 3:
				global_position = Vector2(randi_range(State.Shared_Character_Position.x - spawnBoxVector.x, State.Shared_Character_Position.x + spawnBoxVector.x),State.Shared_Character_Position.y - spawnBoxVector.y +10) #Oben

Spawn Zone

To keep the dragons smaller and prevent them from moving around the map, I created a spawn and despawn zone. This zone is simply a box of coordinates with no dragons behind it. This box moves with the player.

First, it checks whether the dragon is outside the box. If so, it is moved to a different position.

The position is rerolled every 0.2 seconds using a timer to save some processing power. The roll can produce a number from 0 to 3, which determines the direction of the new position.

With the new position, the dragons are moved a few pixels further towards the center to prevent them from despawning and respawning too quickly.

Conclusion

The little dragons, with their simple little animations, add a bit of movement to the game that was previously missing. The background system offers opportunities for further development, like the karma system mentioned above, which currently only exists in my head. Fairy dragons are also a nice change of pace and occasionally appear in my art and development streams, as it’s not too much work to integrate them into the game. I’m planning further projects with the fairy dragon assets I’ve created, but that’s in the distant future.

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply

Your email address will not be published. Required fields are marked *