Your First Scene

By now, you've successfully set up VNgen and created a simple dialog sequence complete with interactive options for users to choose from. However, if we were to run our example code right now, it would look a little empty: just text! Who are the characters we've created, and what do they look like? Where are they? Visual novels being visual, details like these are most often left to context, so it's important that once the script is in place, other elements are soon to follow.

Fortunately, as previously mentioned, VNgen actions are highly standardized. Now that you have a grasp on creating text, creating other kinds of entities will already be familiar to you. Once you know what entity types are available and what functions they all have, exploring new possibilities is a simple matter of combining your knowledge of the two! Feel free to review Entities & Action Types any time.

Scenes

Let's begin with a scene. VNgen supports highly dynamic environments with multiple parallaxing layers, but for now we'll start with a simple backdrop:

Example

if (vngen_event()) {
vngen_scene_create("bg", spr_background, 0, 0, 0, false, false, trans_fade, 2);
vngen_text_create("text", "John Doe", "Hello, world!", 128, 900, 0, 1664, fnt_Arial, c_white, trans_fade, 2);
vngen_text_modify_style("text", c_white, c_white, c_gray, c_gray, c_black, c_black, 1, 2);
}

In this example, we've returned to our first text event and added a background, or scene. Like text, our scene has an ID, X/Y/Z coordinates, and a transition with a duration of 2 seconds so that out text and environment appear synchronously. Scenes can be created as either backgrounds or foregrounds and also set to endlessly repeat, but aside from these unique properties you'll notice that, for the most part, creating a scene is quite like creating text. The only fundamental difference is that we assign a sprite to the scene rather than a string of text.

Most scenes will be drawn as a single element covering the entire screen, but they don't have to be! Feel free to create additional scenes in your own project with different Z depths to build detailed environments piece-by-piece! It really is as simple as one line of code.

Characters

Creating characters is a similar matter. While you can create characters from a single sprite, chances are you'll want them to be more dynamic than that. Characters are the anchors of your story, and the more dynamic they are, the more your audiences will be engaged. By default, VNgen supports an additional two sprites for facial animations when idle and talking, respectively, which are then composited on top of the main body sprite.

See the new line added to the example event below:

Example

if (vngen_event()) {
vngen_scene_create("bg", spr_background, 0, 0, 0, false, false, trans_fade, 2);
vngen_char_create("John Doe", spr_body, spr_face_idle, spr_face_talk, 0, 1080, 0, 180, 200, false, trans_slide_right, 2);
vngen_text_create("text", "John Doe", "Hello, world!", 128, 900, 0, 1664, fnt_Arial, c_white, trans_fade, 2);
vngen_text_modify_style("text", c_white, c_white, c_gray, c_gray, c_black, c_black, 1, 2);
}

Note how the character create action in this example has the same ID as the speaker name assigned in the text action. In order for automatic facial animations to function, both names must match exactly. If they don't, both the text and character will still display, but facial animations will not be played in-sync with text.

Typically, faces should be rendered separate from the body in their own sprites, which are then composited onto the body in real-time in VNgen. This avoids unnecessarily drawing the body over and over while only the face is changing, constituting wasted performance and storage space. Face sprites need not even match body sprite dimensions, since vngen_char_create includes a second set of X/Y coordinates just for positioning the face relative to the body sprite.

And that's not all. We can save even more performance when creating our other character in the next Quantum event as well:

if (vngen_event()) {
vngen_char_create("Jane Doe", spr_body, spr_face_idle, spr_face_talk, 0, 1080, 0, 180, 200, true, trans_slide_left, 2);
vngen_text_replace("text", "Jane Doe", "I'm good, thanks! How about you?", previous, previous, 1);
}

Notice anything different? Aside from the name, another subtle change here makes a big difference in how our second character is displayed. Note the true value here--as explained in the full reference guide, this value enables flipping the character horizontally so that only one version of a character needs to be created to face both directions. VNgen will mirror the character in real-time.

Textbox

At this point, our scene is beginning to look much more alive! Perhaps even a bit too much. Busy backdrops can often lack contrast with text, making it difficult or unpleasant to read. Fortunately, the solution is simple. That's right: a textbox.

if (vngen_event()) {
vngen_scene_create("bg", spr_background, 0, 0, 0, false, false, trans_fade, 2);
vngen_char_create("John Doe", spr_body, spr_face_idle, spr_face_talk, 0, 1080, 0, 180, 200, false, trans_slide_right, 2);
vngen_textbox_create("textbox", spr_textbox, 0, 1080, 0, trans_wipe_right, 2);
vngen_text_create("text", "John Doe", "Hello, world!", 128, 900, 0, 1664, fnt_Arial, c_white, trans_fade, 2);
vngen_text_modify_style("text", c_white, c_white, c_gray, c_gray, c_black, c_black, 1, 2);
}

As textboxes are purely decorative, they are one of the simplest and most standard of all VNgen entities. You should recognize every argument in the textbox create action: ID, sprite, X/Y/Z coordinates, transition, and duration--that's it!

Text is not physically confined to textboxes in any way, but they still serve an important role in making text readable. As the largest single UI element, textboxes also portray the mood and style for your particular story and setting. Don't think of this as just a finishing touch; it's just the beginning of a much bigger design language encompassing your entire user interface!

Action!

And indeed, this is only scratching the surface. From here, the possibilities are practically endless! From further UI elements like prompts, to animated emotes, to advanced character attachments, with an understanding of the fundamental principles of VNgen content creation, the power is yours to build engaging, interactive narratives full of dynamic characters and environments. Take the knowledge you've gained from creating your first visual novel and you'll be a master storyteller in no time!