Turn-Based Battle - Keyboard Controls & Textboxes

14

Index

Attached Files

The following files have been attached to this tutorial:

.c3p

tb-battletextbox.c3p

Download now 169.34 KB

Stats

3,402 visits, 6,516 views

Tools

Translations

This tutorial hasn't been translated.

License

This tutorial is licensed under CC BY 4.0. Please refer to the license text if you wish to reuse, share or remix the content contained within this tutorial.

Published on 24 Mar, 2021.

The event sheet is largely the same in overall structure, but we need to make some changes to accommodate the keyboard controls and changes to global variables.

The On Start of Layout event has gained a couple of extra actions along with the function mapping. We now need to also set the CurState variable to "PickAction" to allow for a battle turn to start, and set the text in the BattleText object to a simple opening line.

As we're now using a specific key to control most of the project, everything that relates to the Z key is nested in a single event:

Condition

Keyboard ▶︎ On Z Key pressed

BattleText ▶︎ Typewriter text "Welcome to the test. Use the Z key to start the battle. See if you can beat your opponent." over 2 seconds

Sub-event Condition

System ▶︎ CurState = "PlayerTurn"

OR

System ▶︎ CurState = "OppTurn"

Sub-event Condition

System ▶︎ NextState = "PlayerTurn"

Sub-event Action

Function ▶︎ Call PlayerAttack

Sub-event Condition

System ▶︎ NextState = "OppTurn"

Sub-event Action

Function ▶︎ Call OppAttack

Sub-event Condition

System ▶︎ NextState = "EndTurn"

Sub-event Action

Function ▶︎ Call EndTurn

A second sub-event under the Z key level then handles the text progression events:

Sub-event Condition

System ▶︎ CurState = "PickAction"

Sub-event Action

Function ▶︎ Call TurnStart

The typewriter text is how we control when the player can advance the text and therefore the battle turn. As a part of that, the Continue sprite acts as a visual cue for when they can press the Z key and progress. This is managed by a single event:

Condition

BattleText ▶︎ On typewriter text finished

Action

Continue ▶︎ Set visibility to Visible

The typewriter text is also used as a condition to check when to call the EndTurn function. When NextState is "EndTurn" then the function is only called if the typewriter text has finished:

Condition

System ▶︎ NextState = "EndTurn"

BattleText ▶︎ On typewriter text finished

Action

System ▶︎ CurState = "EndTurn"

Function ▶︎ Call EndTurn

Next Tutorial In Course

Turn-Based Battle - Damage Calculations 04:41

Set damage would make a battle pretty boring, so this tutorial looks at changing the way damage is handled.

  • 3 Comments

  • Order by
Want to leave a comment? Login or Register an account!
  • Epic! Thanks for the cool update! Also, Please know that the Dark Mode on your website is 90% of the Reason I will support you guys forever. Its the small details that show you care. ;)

  • hey can you please make a tutorial for a final fantasy tactics grid system movement & attack , i can pay you please

  • nice :)