-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
42 changed files
with
878 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
title: Start | ||
--- | ||
This is the example project for displaying sprites from speakerdata. | ||
Apple[Happy]: Hi! I'm Apple. I'm here as an example of how Chatterbox can display sprites! | ||
Apple[Amazed]: Isn't that so cool!? | ||
Elppa[Happy]: A bit of an overreaction, don't you think? | ||
Apple[Ashamed]: Ahem. Anyways, that's how it works, pretty neat, right? | ||
Elppa[Crying]: This is an example of it using a fallback sprite when the requested sprite can't be found. | ||
Allpe: This is an example of it using the fallback character for a character not defined in the actors list. | ||
=== |
File renamed without changes.
File renamed without changes.
File renamed without changes.
18 changes: 9 additions & 9 deletions
18
objects/oExample/oExample.yy → objects/oExampleBasic/oExampleBasic.yy
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
//A struct that contains the speaker names, and their possible sprites, with a fallback. | ||
//Written by Scott | ||
|
||
actorsList = { | ||
"Apple": { | ||
sprites: { | ||
"Amazed" : sAppleAmazed, | ||
"Ashamed" : sAppleAshamed, | ||
"Happy" : sAppleHappy, | ||
"Fallback" : sAppleBase, | ||
} | ||
}, | ||
"Elppa": { | ||
sprites: { | ||
"Amazed" : sElppaAmazed, | ||
"Ashamed" : sElppaAshamed, | ||
"Happy" : sElppaHappy, | ||
"Fallback" : sElppaBase, | ||
} | ||
}, | ||
"Fallback" : { | ||
sprites : { | ||
"Fallback": sBlank, | ||
} | ||
} | ||
}; | ||
|
||
|
||
//Load in some source files | ||
ChatterboxLoadFromFile("example_speakerdata_sprite.yarn"); | ||
|
||
//Create a chatterbox | ||
box = ChatterboxCreate("example_speakerdata_sprite.yarn"); | ||
|
||
//Tell the chatterbox to jump to a node | ||
ChatterboxJump(box, "Start"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
draw_set_font(fntDefault); | ||
draw_set_halign(fa_center); | ||
|
||
//Iterate over all text and draw it | ||
var _x = room_width/2; | ||
var _y = room_height/2 + 200; | ||
|
||
if (ChatterboxIsStopped(box)) | ||
{ | ||
//If we're stopped then show that | ||
draw_text(_x, _y, "(Chatterbox stopped)"); | ||
} | ||
else | ||
{ | ||
//All the spoken text | ||
var _i = 0; | ||
repeat(ChatterboxGetContentCount(box)) | ||
{ | ||
var _speaker = ChatterboxGetContentSpeaker(box, _i); //Returns Name ex: NPC[Happy]: Returns NPC: | ||
var _speakerData = ChatterboxGetContentSpeakerData(box, _i); // Returns Data After name ex NPC[Happy]: returns Happy | ||
var _currentActor = actorsList[$ _speaker] ?? actorsList[$ "Fallback"]; //Returns the Actor struct for the specified speaker, with the Fallback. | ||
var _speakerSprite = _currentActor.sprites[$ _speakerData]; //Gets the sprite from the Actor struct. | ||
if (_speakerSprite == undefined) _speakerSprite = _currentActor.sprites.Fallback; //Use the fallback sprite if needed. | ||
var _currentSprite = _speakerSprite; // References the current actor then references which sprite should be used | ||
var _string = ChatterboxGetContentSpeech(box, _i); | ||
draw_text(_x, _y, _speaker); | ||
_y += 40; | ||
draw_text(_x, _y, _string); | ||
draw_sprite(_currentSprite, 0, room_width/2, room_height/2); | ||
_y += string_height(_string); | ||
++_i; | ||
} | ||
|
||
//Bit of spacing... | ||
_y += 40; | ||
|
||
if (ChatterboxIsWaiting(box)) | ||
{ | ||
//If we're in a "waiting" state then prompt the user for basic input | ||
draw_text(_x, _y, "(Press Space)"); | ||
} | ||
else | ||
{ | ||
//All the options | ||
var _i = 0; | ||
repeat(ChatterboxGetOptionCount(box)) | ||
{ | ||
var _string = ChatterboxGetOption(box, _i); | ||
draw_text(_x, _y, string(_i+1) + ") " + _string); | ||
_y += string_height(_string); | ||
++_i; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
if (ChatterboxIsStopped(box)) | ||
{ | ||
//If we're stopped then don't respond to user input | ||
} | ||
else if (ChatterboxIsWaiting(box)) | ||
{ | ||
//If we're in a "waiting" state then let the user press <space> to advance dialogue | ||
if (keyboard_check_released(vk_space)) | ||
{ | ||
ChatterboxContinue(box); | ||
} | ||
else if (keyboard_check_pressed(ord("F"))) | ||
{ | ||
//The user can also press F to fast forward through text until they hit a choice | ||
ChatterboxFastForward(box); | ||
} | ||
} | ||
else | ||
{ | ||
//If we're not waiting then we have some options! | ||
|
||
//Check for any keyboard input | ||
var _index = undefined; | ||
if (keyboard_check_released(ord("1"))) _index = 0; | ||
if (keyboard_check_released(ord("2"))) _index = 1; | ||
if (keyboard_check_released(ord("3"))) _index = 2; | ||
if (keyboard_check_released(ord("4"))) _index = 3; | ||
|
||
//If we've pressed a button, select that option | ||
if (_index != undefined) ChatterboxSelect(box, _index); | ||
} |
35 changes: 35 additions & 0 deletions
35
objects/oExampleSpeakerDataSprite/oExampleSpeakerDataSprite.yy
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.