PDF Unreal Engine 5 Game Development With C++ Scripting: Become A Professional Game Developer and Create Fully Functional, High-Quality Games 1st Edition Zhenyu George Li Download
PDF Unreal Engine 5 Game Development With C++ Scripting: Become A Professional Game Developer and Create Fully Functional, High-Quality Games 1st Edition Zhenyu George Li Download
com
OR CLICK BUTTON
DOWLOAD NOW
https://ebookmeta.com/product/advanced-unity-game-development-
build-professional-games-with-unity-c-and-visual-studio-victor-g-
brusca/
https://ebookmeta.com/product/game-development-with-monogame-
build-a-2d-game-using-your-own-reusable-and-performant-game-
engine-1st-edition-louis-salin/
https://ebookmeta.com/product/advanced-unity-game-development-
build-professional-games-with-unity-c-and-visual-studio-1st-
edition-victor-g-brusca-2/
Advanced Unity Game Development: Build Professional
Games with Unity, C#, and Visual Studio 1st Edition
Victor G Brusca
https://ebookmeta.com/product/advanced-unity-game-development-
build-professional-games-with-unity-c-and-visual-studio-1st-
edition-victor-g-brusca/
https://ebookmeta.com/product/creating-games-with-unreal-engine-
substance-painter-maya-models-textures-animation-blueprint-1st-
edition-jingtian-li/
https://ebookmeta.com/product/beginning-java-game-development-
with-libgdx-create-a-great-variety-of-games-quickly-and-
efficiently-with-libgdx-1st-edition-lee-stemkoski/
https://ebookmeta.com/product/build-your-own-2d-game-engine-and-
create-great-web-games-using-html5-javascript-and-webgl2-kelvin-
sung/
https://ebookmeta.com/product/introduction-to-video-game-engine-
development-learn-to-design-implement-and-use-a-cross-
platform-2d-game-engine-1st-edition-victor-g-brusca/
Unreal Engine 5
Game Development
with C++ Scripting
Zhenyu George Li
BIRMINGHAM—MUMBAI
Unreal Engine 5 Game Development with C++ Scripting
Copyright © 2023 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted
in any form or by any means, without the prior written permission of the publisher, except in the case
of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information
presented. However, the information contained in this book is sold without warranty, either express
or implied. Neither the author, nor Packt Publishing or its dealers and distributors, will be held liable
for any damages caused or alleged to have been caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and
products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot
guarantee the accuracy of this information.
ISBN 978-1-80461-393-1
www.packtpub.com
Foreword
I have known and worked with George Li in various capacities for more than 20 years.
We met first as colleagues at a private college of interactive arts in downtown Vancouver, Canada. I
was a full professor of linguistics at a university in the area, with extensive experience in developing
a cognitive science program at the university. Establishing a curriculum for such a program involved
familiarizing myself with areas well beyond the area of my specific academic position and collaborating
closely with colleagues – particularly in computing science (cognitive), psychology, and philosophy
(particularly concerning socio-epistemological issues such as AI). It was in this spirit that I was happy
to associate myself with a private college, focusing on language study and teaching, together with
preparing students to handle 3D computer applications (e.g., 3ds Max, 3D GameStudio, and Unreal)
and showing them how to generate animation materials for film, TV, and games.
George Li was in charge of all the technical requirements of the college. I very quickly realized that he
was not merely extremely competent and forthcoming (he had already occupied high-level computing-
related positions, software engineering for instance, in China prior to emigrating to Canada) but
also computationally competent and brilliantly innovative. He also had a particular interest in the
development of game engines and was already collaborating with his colleague, Charles Yeh, on a
practical reference book, XNA PC & Xbox360 C# Game Programming, with proprietary-produced
text and games to his credit.
As colleagues in the college, George and I found common, mutually strengthening interests. Eventually,
he and I found ourselves in charge of creating a two-year interactive-arts program curriculum for
the college.
My whole career, at universities in the UK and Canada, and as a member of the editorial boards of
a major academic journal and a very influential series, has closely involved the evaluation of the
intellectual quality of people’s capabilities and work, and in my opinion, George Li’s innate talents
shine out clearly throughout his work and will continue to do so in the future. His ability to express
his knowledge of the subject at hand is outstandingly demonstrated in all his work, performance,
expressions, and character.
This book, like the one co-authored with Yeh, is designed for independent developers and company
training, plus for reference after post-secondary education. The knowledge presented herein is most
intelligently, clearly, and effectively presented so as to be as efficiently applicable and pedagogically
effective as possible on any device or platform, producing high-quality games, accessories, and edits.
This volume will certainly stand the test of time and fulfill the majority of the needs of those working
in the field of gaming. However, I am certain that George will make further, very crucial contributions
to this topic.
Until then, this volume will serve you excellently, helping you enjoy and prosper with your future
activities and products.
I express my gratitude to my wife, Alison Guo, for her support in handling family responsibilities and
for enabling me to dedicate time to completing this book. I also extend my thanks to Sarah Beck and
Willy Campos for their encouragement and support throughout the writing process.
About the reviewers
Aditya Dutta holds a game programming advanced diploma from Humber College and is a highly
accomplished senior software engineer at Archiact Interactive, bringing expertise in Unreal Engine
and C++ system design and implementation.
With a strong collaborative spirit, Aditya leads feature development and takes ownership of tools
while actively improving team processes. These leadership skills were evident during his tenure
as lead programmer at Humber College, where he successfully guided and mentored a team of
programmers, overseeing the technical aspects of significant projects in the virtual production and
architecture industries.
His contributions at UP360 Inc. as a programmer included shipping numerous training VR simulations,
developing iterative tools, and implementing gameplay mechanics using Unreal Engine.
Michael Oakes is a senior software consultant for Unity and has over 27 years of experience in the
IT industry. He has worked with real-time 3D and games for over eight years, specializing in mixed
reality design and development, shader programming, and AI and multiplayer systems.
He has worked as a technical consultant on other titles, including Packt Publishing’s Learn ML-Agents
– Fundamentals of Unity Machine Learning, written by Micheal Lanham.
Table of Contents
Part 1 – Getting Started with Unreal C++
Scripting
1
Creating Your First Unreal C++ Game 3
Technical requirements 3 Ensuring your UE has the source code installed 9
Understanding C++ scripting in Unreal 4 Launching the UE5 editor through the Epic
Games Launcher 10
What is the difference between C++ and
Creating the MyShooter C++ project 10
Blueprint?4
Associating VS with UE5 as the default source
When do you use C++? 5
code editor 12
What is the difference between C++
Opening the C++ source code in VS (optional) 13
programming and C++ scripting? 5
2
Editing C++ Code in Visual Studio 21
Technical requirements 21 Solution Explorer 26
Launching VS 22 Output window 27
Error List window 28
Walking through the VS IDE’s UI 24
Code editor 25 Editing code in VS 29
Menus26 Controlling the caret (input cursor) 30
Search box 26 The text editing keys 30
Toolbar26 Code selection 30
viii Table of Contents
3
Learning C++ and Object-Oriented Programming 43
Technical requirements 44 Working on the improved calculator
What is C++? 44 program66
Exploring the C++ program structure 45 Creating references and pointers 72
Defining C++ functions 46 References73
Pointers74
Defining functions with or without parameters 47
Calling functions 47 Understanding OOP 74
Writing the main() function 47 What is OOP? 75
Working with a basic calculator What are classes and objects? 75
program48 Creating classes in C++ 76
Creating objects in C++ 77
Learning the C++ syntax 49
Using the C++ data types 50 Working on an OOP calculator
Defining variables 51 program78
Using C++ arrays 52 Adding constructor and getter functions for
Using C++ operators 53 the calculator class 83
Accepting user input 57 Creating the CalculatorEx class, which
Adding C++ comments 57 inherits from the Calculator class 84
Controlling the C++ flow 58 Summary88
4
Investigating the Shooter Game’s Generated Project and C++ Code 89
Technical requirements 89 Getting familiar with the source code 95
Understanding the MyShooter C++ MyShooterCharacter.h95
project structure 90 MyShooterCharacter.cpp100
Understanding the game program MyShooterProjectile.h and
structure92 MyShooterProjectile.cpp103
Table of Contents ix
Using the UFUNCTION macro 132 Using the Cast template function 145
The UFUNCTION syntax 132 Summary147
UFUNCTION specifiers and metadata keys 132
Tagging ADefenseTower and APlayerAvatar
member functions as UFUNCTION macros 133
6
Creating Game Actors 149
Technical requirements 149 Replacing the game’s player pawn 160
Setting up the player avatar 150 Creating the player avatar’s
Adding SpringArmComponent and animation blueprint 162
CameraComponent to PlayerAvatar 150 Creating the PlayerAvatarAnimInstance class 163
Initializing the player avatar 154 Creating the ABP_PlayerAvatar blueprint 169
Setting up the character’s Creating the State Machine on ABP_
SkeletalMeshComponent155 PlayerAvatar171
Syncing the movement speed with the
Importing the character model 155
animation instance 174
Using the Hero skeletal mesh in BP_
PlayerAvatar160 Summary176
7
Controlling Characters 179
Technical requirements 180 Implementing the OnStateAnimationEnds
function186
Controlling the player character to
attack180 Destroying actors 187
Adding the Attack action to the action map 180 Creating the enemy character 189
Binding the handler function to the Attack Creating the Enemy class 190
action181
Creating the EnemyController class 195
Implementing the OnAttackPressed() action
Creating the ABP_Enemy animation blueprint 200
handler function 182
Creating the BP_Enemy blueprint 201
Implementing the CanAttack() and Attack()
functions182 Testing the game 203
Processing non-loop animations 184 Summary204
8
Handling Collisions 205
Technical requirements 205 Using collisions for game interactions213
Understanding collision detection 206 Downloading and creating the weapon,
defense tower, and fireball actors 214
Setting the collision presets 210
Table of Contents xi
9
Improving C++ Code Quality 239
Technical requirements 239 Creating a fireball pool 256
Refactoring code 240 Outputting debug messages 263
Combining the PlayerAvatarAnimInstance Using the UE_LOG macro 264
and EnemyAnimInstance classes 240 Printing debug messages to the screen 265
Making PangaeaCharacter the parent class of
APlayerAvatar and AEnemy 243 Checking an Actor instance’s actual
class type 266
Refining code 255
Summary269
Using caching variables 255
11
Controlling the Game Flow 295
Technical requirements 295 Adding the Timer variable to the
APangaeaGameState class 313
Designing the Pangaea game’s flow 296
Making the Timer variable replicable 314
Creating the UI widgets 297
Defining OnTimeChangedDelegate 314
Creating BP_LobbyWidget 298
Creating and binding the custom event to
Creating BP_HUDWidget 301 OnTimeChangedDelegate315
Creating BP_GameOverWidget 303 Counting down the timer 317
Adding networking functions to Designating APangaeaGameState as the
PangaeaGameInstance306 project’s game state class 319
12
Polishing and Packaging the Game 327
Technical requirements 327 Packaging the game 338
Polishing the game 328 Configuring the project settings for packaging 338
Importing and using high-quality game assets 328 Making the build a windowed game 340
Fixing bugs 331 Avoiding the hardcoded path for finding
Profiling and optimization 331 content341
Packaging the project 344
Using Unreal Engine console
commands332 What to do next 347
Exploring modes and console commands 332 Summary348
Executing console commands in C++ 336
Index349
As an Unreal Engine developer, you may have a genuine interest in understanding C++ and how it
integrates with the engine, even if you don’t identify as a software engineer or aspire to become one.
This book is designed to assist you in expanding your knowledge and skills by guiding you through
the necessary steps to create a fully fledged game, covering essential aspects of game development. It
aims to smoothen the learning curve, allowing for a more seamless and efficient grasp of the concepts
presented. The carefully organized topics eliminate the need for random searching and prevent wasted
time on unrelated readings, enabling you to focus on the relevant information. Moreover, this book
serves as a valuable reference manual, offering a comprehensive resource that can be revisited and
utilized for further study.
• Non-engineer game developers, such as game designers and artists who aspire to learn and
comprehend C++ in the context of Unreal Engine development
• Software engineers who may lack prior experience in Unreal Engine C++ programming but
wish to quickly acquire the necessary skills for their next project or job
• Students who are interested in learning and digging into Unreal C++ programming for their
study or personal projects
• Individuals with a keen interest in game development using Unreal Engine will benefit from
the comprehensive knowledge presented within these pages
Chapter 8, Handling Collisions, discusses the engine’s collision system and its configurations for game
interactions. To handle collision events – attack hits and projectile hits, for example – you will learn
how to configure actor colliders and triggers. Using ray casts to check whether a projectile hits the
target is also introduced in this chapter.
Chapter 9, Improving C++ Code Quality, presents how to employ software engineering practices during
code refactoring and refinement. This chapter implements class generalization, caching, and pooling
methods to improve the game code’s quality and performance.
Chapter 10, Making Pangaea a Network Multiplayer Game, starts by introducing the fundamental
concepts related to multiplayer games, including servers, clients, and multiplayer modes. You will
be guided step by step through converting the single-player Pangaea game into a multiplayer game.
Chapter 11, Controlling the Game Flow, intends to make Pangaea a complete multiplayer game, which
has a main menu as the lobby, so that players can decide whether they want to start a host or join
a game session. C++ and Blueprint scripting skills for user interface operations are also revealed in
this chapter.
Chapter 12, Polishing and Packaging the Game, provides resources, methods, and suggestions on how to
polish games from both visual experience and product quality aspects. This chapter also provides steps
for configuring and packaging the Pangaea project to be an executable standalone game for distribution.
If you conduct experiments with the samples on systems other than Microsoft Windows, such as
macOS, please keep in mind that there may be user interface and configuration differences that may
not be addressed in this book.
If you are using the digital version of this book, we advise you to type the code yourself or access
the code from the book’s GitHub repository (a link is available in the next section). Doing so will
help you avoid any potential errors related to the copying and pasting of code.
We also have other code bundles from our rich catalog of books and videos available at https://
github.com/PacktPublishing/. Check them out!
Conventions used
There are a number of text conventions used throughout this book.
Code in text: Indicates code words in text, database table names, folder names, filenames,
file extensions, pathnames, dummy URLs, user input, and Twitter handles. Here is an example:
"The AProjectile class can be inherited as child classes for creating various fireable objects, such as
AFireBall, AMissile, ABomb, and so on."
A block of code is set as follows:
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "DefenseTower.generated.h
When we wish to draw your attention to a particular part of a code block, the relevant lines or items
are set in bold:
void APangaeaCharacter::BeginPlay()
{
…
_AnimInstance = Cast<UPangaeaAnimInstance>(
GetMesh()->GetAnimInstance());
…
}
$ mkdir css
$ cd css
Bold: Indicates a new term, an important word, or words that you see onscreen. For instance, words in
menus or dialog boxes appear in bold. Here is an example: "In the Unreal Project Browser window,
choose the GAMES tab on the left side. Then select the First Person template."
Additionally, the C++ sample code provided in this book adheres primarily to Unreal Engine’s coding
standard, ensuring consistency and minimizing confusion for readers. For detailed information, you
can visit the official Code Standard website here: https://docs.unrealengine.com/5.0/
en-US/epic-cplusplus-coding-standard-for-unreal-engine/.
Exceptions may occur when using compact expressions that are clear and easily understood, allowing the
text to fit within the constraints of the page printing layout without compromising reader comprehension.
For example, the following line of code follows the code standard by explicitly declaring the type of
the assigned GameInst variable:
Get in touch
Feedback from our readers is always welcome.
General feedback: If you have questions about any aspect of this book, email us at
[email protected] and mention the book title in the subject of your
message.
Errata: Although we have taken every care to ensure the accuracy of our content, mistakes do happen.
If you have found a mistake in this book, we would be grateful if you would report this to us. Please
visit www.packtpub.com/support/errata and fill in the form.
Piracy: If you come across any illegal copies of our works in any form on the internet, we would
be grateful if you would provide us with the location address or website name. Please contact us at
[email protected] with a link to the material.
If you are interested in becoming an author: If there is a topic that you have expertise in and you
are interested in either writing or contributing to a book, please visit authors.packtpub.com.
xviii
https://packt.link/free-ebook/9781804613931
In this part, the primary focus will be on providing an introduction to the basics of C++ programming,
specifically for game development with Unreal Engine. You will gain knowledge on creating a C++
game project in Unreal, as well as utilizing MS Visual Studio to access and modify the game’s source
code. Moreover, essential concepts of C++ and object-oriented programming, along with their syntax,
will be introduced. Building upon this foundation, we will examine the generated source code to
conduct an initial investigation into the game project.
This part contains the following chapters:
Technical requirements
As a reader of this book, you will be expected to have common computer operational skills. You
should also have basic knowledge of and experience with the UE5 editor, as well as some Blueprint
scripting skills.
To follow this chapter, you should have installed Epic Games Hub and the 5.03 or later version of
the engine editor on your computer. If you haven’t done so, please go to the official Epic website
(https://www.unrealengine.com/en-US) to register an account and download the Epic
Games Launcher.
4 Creating Your First Unreal C++ Game
C++ code and files can be well-organized based on an entire project’s mechanics. It is easy to globally
search, locate, and access code blocks to edit, maintain, and troubleshoot. In the meantime, it is also
easier to read and understand a big chunk of code that implements complex algorithms and logic.
Blueprint, on the other hand, is a context-sensitive scripting environment. Blueprint graphs are
relatively independent. When a graph needs to solve complex logic, the nodes and the connection
lines create messy spaghetti that can hardly be understood and maintained.
C++ also has some shortcomings. One example is that it may cause critical errors that may crash an
entire system. That is usually caused by the developer’s mistakes. Since Blueprint is a protected layer,
it is safer, and hence, the chances of the system crashing are fewer.
In conclusion, the choice between C++ and Blueprint should be made based on specific development
requirements and conditions, considering the pros and cons of each approach.
• Performance
• Logic and algorithm complexity
• Accessibility to a system’s core functions
• The developer’s experience
If you want higher performance and deal with advanced game logic and system processes, and you
are capable of coding and solving complex problems, you should go for C++.
C++ programming means using the C++ programming language to write code for any purpose; it
doesn’t have to be just for UE projects. C++ scripting, in this book, is a specific dialect of the C++
programming language supported by the UE. It takes advantage of the power of C++ syntax and also
works with UE’s Application Programming Interfaces (APIs), which allow developers to create and
extend the engine’s functionalities for their games and the development environment’s context, such
as objects, graphics, audio, and network communication.
Now that we have a basic overview of C++ and have learned why and when to use C++ for Unreal
game developments, let’s dive deeper into C++ scripting by creating a sample project.
Note
To install VS, a Microsoft account is typically required. If you don’t have a Microsoft account, you
can register using the following page: https://account.microsoft.com/account/.
Next, launch VisualStudioSetup.exe inside the folder where you downloaded the VS installer
(the \Downloads folder, for example).
Enable the two Game development with C++ and Desktop development with C++ checkboxes –
these two options tell the installer to install the C++ compiler and the professional game development
support for UE (see Figure 1.2).
8 Creating Your First Unreal C++ Game
Also, keep an eye on the following options on the Installation details panel that belongs to the Desktop
development with C++ group, and make sure the following are checked:
Then, click the Install button to install the workloads and reboot the system, and then you will see a
prompt from the dialog popup (see Figure 1.3):
The next thing we need to do is to confirm that we have installed the engine source code together
with the UE5 editor. The reason why we need this is that when we generate a new project, the engine
source code can be integrated into the new project; under certain circumstances, we may need to
modify or customize the engine for the game’s specific needs.
1. Click the downward arrow button and choose Options from the drop-down menu.
2. Make sure that the Engine Source option is checked.
3. Press the Apply button:
UE is an ongoing development product, with bugs and defects that may need to be fixed by its users.
Also, professional developers sometimes modify the engine source code to adapt to their specific
needs. An example of this is when we face an issue with geometry instancing (or instanced rendering)
working only in the game’s development build but not in the release build, which is subsequently
resolved by our engineer modifying the engine’s source code.
10 Creating Your First Unreal C++ Game
Note
Geometry instancing is a rendering technique that renders multiple instances of a visual object
in a single draw call and provides each instance with some unique attributes: https://
en.wikipedia.org/wiki/Geometry_instancing.
We are now ready to start the UE editor through the Epic Games Launcher.
Figure 1.5 – Launching the UE5 editor from the Epic Games Launcher
The next thing we want to do is to create a new game project. Let’s name the new project MyShooter.
1. In the Unreal Project Browser window, choose the GAMES tab on the left side.
2. Select the First Person template.
3. Select the C++ button.
Creating your C++ Shooter project from a template 11
4. Choose the project location (for example, C:\UEProjects) and type MyShooter in the
Project Name field.
5. Click the Create button.
The created game project also includes the starter content, which is packaged with assets and resources
that can be used to prototype the game.
The engine will do some initialization work and then open the editor when things are ready. If you
look at the project tree panel’s MyShooter tab in the bottom-left corner of the editor window, you
should see the C++ Classes node on the same layer as the Content node (see Figure 1.7).
12 Creating Your First Unreal C++ Game
Figure 1.7 – The MyShooter C++ project opened in the UE5 editor
The system will automatically launch VS, and the VS editor will open the MyShooterCharacter.
cpp file (see Figure 1.10).
14 Creating Your First Unreal C++ Game
Back in the Unreal editor, click the Play ( ) button to start the game. While playing the game on the battlefield,
you can control your character, move them around, and pick up the gun in front of them (see Figure 1.11).
We have learned how to create a UE C++ project from scratch. However, what if we already have a
Blueprint project and want to convert it to a C++ project? UE allows developers to do it by adding a
new C++ class to the project. Let’s practice converting a MyBPShooter Blueprint project.
1. First of all, you have to create a Blueprint project, MyBPShoopter, under C:\UEProjects
(you can choose a different path to create the new project). Use the same steps introduced in
the Creating the MyShooter C++ project section, but choose BLUEPRINT instead of C++ for
the creation of the MyBPShooter project.
2. Secondly, open the new project in UE5. Pay attention to the project tree; it doesn’t have the
C++ Classes node at this stage.
3. Select Tools | New C++ Class from the editor’s main menu, and then, in the Add C++ Class window
(see Figure 1.14), choose Character as the base class (a class that contains common attributes
and methods that are shared by its derived classes) to create the MyShooterCharacter class.
Converting an existing Blueprint project to a C++ project 17
Figure 1.14 – Adding a new C++ class from the Character class
Once you click the Next> button, it will navigate to the NAME YOUR NEW CHARACTER screen.
4. On the NAME YOUR NEW CHARACTER screen, type MyBPShooterCharacter into
the Name field.
Please pay attention to the path where the header and the source files will be placed. They look
different from the MyShooter project because the C++ node hasn’t been created yet. Don’t worry
about it at the moment. Once the conversion job is done, the system will automatically move
the files to the right place.
5. After clicking the Create Class button, you will see a progress bar.
Figure 1.16 – The MyBPShooterCharacter C++ class Adding code to project… progress bar
Wait for the pop-up message, which indicates that the C++ class job has been added.
Figure 1.17 – A message saying that the MyBPShooterCharacter C++ class is now added
6. Click the OK button. Now, you will see the message dialog, which asks you whether you want
to edit the code (see Figure 1.18). Choose No here.
7. Shut down your UE editor and reopen MyBPShooter. When you see a dialog that asks
whether you want to rebuild the project, answer Yes here.
Converting an existing Blueprint project to a C++ project 19
When it is done, you will find the new C++ Classes node on the project tree, and the
MyShooterCharacter class is already placed in the MyBPShooter folder:
You may have noticed that some other files, such as MyBPShooterGameMode are missing, in
comparison with the MyShooter project. That is because the Blueprint versions already exist, so the
corresponding C++ versions are not automatically generated. You can choose to manually convert
those blueprints to C++ classes only when necessary; otherwise, you just keep the blueprints.
20 Creating Your First Unreal C++ Game
Summary
In this chapter, we introduced C++ and the advantages of using it for professional game development.
Then, you practiced creating the new MyShooter C++ project and converting the MyBPShooter
Blueprint project to a C++ project. Plus, you also set up the development environment with VS and
the C++ solution files.
In the next chapter, we will first walk through each part of the IDE’s user interface. Then, you will
create a C++ project and practice writing some simple C++ code. Some code editing tricks will be
introduced while editing your code.
2
Editing C++ Code in
Visual Studio
Are you new to coding in general? Then you need to use an editing tool!
C++ source code is just regular text files named with some special extension names, such as .cpp, .h,
and so on. You can basically use Windows Notepad to open and edit C++ source code files. However,
since Notepad is a basic editing tool that lacks functionalities, we recommend using Visual Studio
(VS) as the code editor.
Why use VS? VS is a feature-rich integrated development environment (IDE) that supports many
aspects of software development. It empowers you to complete the entire development cycle in one
place. You can use VS to create, edit, debug, test, and build your code. VS also has the most popular
programming language compilers integrated with the installation package so that C++ source code
can be directly compiled to be executable machinery code. Moreover, VS especially supports Unreal
Engine and works well with the engine’s development environment.
By following the step-by-step journey of this chapter, you will get to know the IDE’s user interface
(UI), be capable of creating and writing C++ code, and learn how to build C++ solutions to generate
standalone executables. This chapter includes the following sections:
• Launching VS
• Walking through the VS IDE’s UI
• Editing code in VS
• Practicing C++ coding
Technical requirements
To explore the creation of C++ projects and editing C++ code, it is necessary to have VS installed on
your system.
22 Editing C++ Code in Visual Studio
VS has both Windows and macOS versions. It also has Community, Professional, and Enterprise
editions. The examples of this book are based on the VS 2022 Windows Community edition.
Since VS is an IDE that you will use for C++ scripting, being familiar with the development environment
and the scripting skills is a prerequisite.
The code for this chapter can be found at https://github.com/PacktPublishing/Unreal-
Engine-5-Game-Development-with-C-Scripting/tree/main/Chapter02/MyCPP_01.
Launching VS
In Chapter 1, we went through the installation of VS, so you should already have installed VS on your
system. Since VS is an independent application, you can launch it either from the operating system
(OS) or in Unreal Engine.
In Windows, simply search for virtual studio and pick the version of the IDE that you wish to launch:
Now, let’s practice launching VS in Unreal Engine. Say we want to open the MyShooterCharacter.
cpp file—you first need to find MyShooter/All/C++ Classes/MyShooter on the Content
Drawer, and then you can double-click on the MyShooterCharacter C++ Class item:
This operation will launch VS if it hasn’t been launched yet and open the MyShooterCharacter.
cpp file in the editor:
24 Editing C++ Code in Visual Studio
Now, you should have your Unreal game development environment installed and set up. The engine
editor and VS are both open. Next, we’ll take a close look at the IDE’s UI.
Once you have opened VS, you will see the IDE editor:
Another Random Document on
Scribd Without Any Related Topics
exterorum vero res gestas, neque illas valde insignes, celebrandas in
ea curasse. Equidem hoc ipse possum conjectura assequi, quod
quum Cypselo ejusque majoribus origo fuerit e Gonussa supra
Sicyonem sito oppido et inter abavos eorum numeretur Melas Antasi
filius, (8) hunc Melanem cum agmine suo (uti ante in commentario
de Corinthiorum rebus exposui) recipere in civitatis ejusdem
communionem recusabat Aletes, quod ex Delphici Apollinis quodam
responso fidem ei minus habebat. At enim, quum ille omnibus Aleten
modis sibi conciliare studuisset et rejectus multis cum precibus redire
non dubitasset, ab invito quidem Alete receptus tamen est. Quare
Melanis illas esse copias, quæ in ea parte arcæ spectantur, facile
existimari possit.
CAPUT XIX.
CAPUT XX.
De aliis donariis in æde Junonis Olympiæ, Iphiti disco, et mensa, in qua coronæ
victoribus positæ — de cadavere militis saucii reperto narratio — de Œnomai
columna — templo Matris Deorum, Matroo dicto, et Philippeo.
Spectantur et alia ibi dona, et inprimis modicus quidam lectus ebore
magna ex parte exornatus; Iphiti discus, et mensa, super qua
victoribus coronæ deponuntur. Et lectulum quidem Hippodamiæ
ferunt ludicrum fuisse. Iphiti vero disco induciæ, quas Olympicorum
ludorum tempore provulgant Elei, non recto versuum ductu inscriptæ
sunt, sed literæ in ora disci orbiculari textu exaratæ. (2) Mensa ipsa
partim ex ebore, partim ex auro fabricata est. Opificem fuisse aiunt
Coloten, quem ab Heraclea oriundum affirmant: etsi, quibus fictorum
origines curiosius inquirere curæ fuit, Parium essse, Pasitelis
(Praxitelis?) vero discipulum testantur; Pasitelem (Praxitelem?)
autem per se ipsum artem didicisse. Juno exinde, Juppiter, Deûm
Mater, Mercurius, cum Diana Apollo ficti sunt. In tergo tota ludorum
descriptio. (3) In uno laterum Æsculapius, et filiarum Æsculapii una
Hygiea: Mars præterea, et prope ipsum Agon (Certamen). At in
altero Pluto est et Bacchus; tum Proserpina et Nymphæ duæ,
quarum altera pilam, clavem altera tenet. Est enim clavis Plutonis
insigne: eaque, ut fama est proditum, a Plutone inferorum sedes ita
clausa est, ut nemini inde reditus pateat. (4) Jam vero, quod
Aristarchus rerum Olympicarum interpres memoriæ prodidit, id
nequaquam præterierim. Sua igitur ille ætate, quum Elei Junonis
ædem sartam tectam, quod vitium templi lacunar fecisset, locassent,
inter tabulatum, quod ad speciem expolitum est, et contignationem,
cadaver cum gravi armatura saucii hominis repertum memorat. Hunc
virum existimabamus dimicasse pugna intra Altin ab Eleis contra
Lacedæmonios commissa, (5) et, quum propugnatores templis
deorum et omnibus omnino excelsis locis conscensis hostem
repellerent, vulneribus confectum, jam moribundum illuc
perreptasse, cadaver autem ejus tam diu integrum permansisse,
quod, in illis latebris abditum, nec per æstatem vaporum, nec per
hiemem frigoris noxam contrahere potuerit. Addidit Aristarchus,
elatum cadaver extra Altin et cum iisdem armis humatum fuisse. (6)
Œnomai quam appellant ipsi etiam Elei columnam, ea exstat ab ara
maxima ad Jovis ædem contendentibus. Quattuor erectæ sunt ad
lævam columnæ quibus lacunar sustinetur. Fulciunt eadem ligneam
columnam jam vetustate ruentem et multis locis incinctam vinculis.
Columnam eam fama pervulgavit in Œnomai domo fuisse solamque
stetisse, quum domus reliqua fulmine conflagrasset. (7) In ænea
tabella ante ipsam columnam incisi elegi sunt hujusmodi:
Una columna ex his, hospes, sum sola relicta,
in claris steterunt quæ ædibus Œnomai.
Nunc exsto Jovis in templo circumdata vinctis
nobilior; nec me flamma voravit edax.
CAPUT XXI.
CAPUT XXII.
De aliis Jovis signis Olympiæ positis — signis in basi quadam lapidea — Abantide
regione — signo Jovis a Metapontinis erecto — signo Jovis a Phliasiis et alio a
quibusdam Leontinis posito.
Sunt et alia Jovis simulacra, partim publico, partim vero privato ære
dedicata. Ad aram vero, qui in Alti est, prope aditum eum, qui ad
stadium ducit, nihil ulli deorum immolant Elei: tubicines tantum et
præcones in eo positi prisco ritu de palma certant. Prope eam aram
suggestum est ex ære, et in eo positum Jovis signum, altitudine
cubitûm sex: utraque manu fulmen tenet: dedicarunt Cynæthaenses.
Qui adstat torque cinctus impuber, eum Phliasius Cleolas dicavit. (2)
Jam vero juxta ædem, quod vocant Hippodamium, e lapide
suggestus est, hemicycli forma. In eo Juppiter, et Jovi pro liberûm
salute supplicantes Thetis et Aurora. Hæc signa in medio suggestu
posita sunt: in utroque semicirculi extremo, accincti ad pugnam sunt,
ab altera parte Achilles, Memnon ab altera. Similiter etiam alius alii e
regione oppositus stat, barbarus Græco, Ulysses Heleno, quod hi
sapientiæ laude in suo uterque exercitu præstitere. Jam propter
vetus odium Menelao Paris, Diomedi Æneas, Ajaci Telamonis filio
Deiphobus oppositi. (3) Opera hæc fuere Lycii Myronis filii:
dedicarunt autem Ionii maris accolæ Apolloniatæ, sicuti priscis literis
incisi elegi ad Jovis pedes indicant:
Urbis Apolloniæ sunt hæc monumenta, comatus
Phœbus quam ad pontum condidit Ionium.
Illa manus, veteris quæ cepit Abantidos oras,
cum dis e Thronio pertulit huc decimam.
CAPUT XXIII.
CAPUT XXIV.
Multa alia Jovis signa a populis et singulis hominibus in Alti posita recensentur —
de signo Jovis Horcii in curia posito, ad quod athletæ jurare solent — signo
Alexandri Magni Jovis habitu.
Exin ara est Laœtæ Jovis, Laœtæ etiam Neptuni. Adjuncta est aræ
basis ænea, quæ Jovem sustinet, Corinthiaci populi donum, Musi
opus, quisquis Musus is fuerit. Inde a curia ad magnum templum
contendenti, ad lævam signum est Jovis cum corona velut e floribus;
dextera fulmen tenet. Fuit hoc Ascari Thebani opus, quem docuit
Sicyonius ** et Thessalorum esse dicit. (2) Hi vero si bello quodam
contra Phocenses suscepto e Phocensium manubiis dedicaverunt,
non fuerit id, quod Sacrum vocant, bellum, sed illud, quod
gesserunt, antequam Xerxes cum Persarum copiis in Græciam
transmitteret. Non procul hinc Juppiter positus est, quem ex voto
quum superiores e prœlio discessissent, dedicasse Psophidios
testatur inscriptio. (3) Dextera in parte magni templi ad Solis ortum
Juppiter est altitudinis pedum duodecim: quem dicatum tradunt a
Lacedæmoniis, quum rebellantes Messenios altero bello vindicare
essent adorti. Adscripti elegi sunt:
Hoc sate Saturno signum cape Juppiter alme,
auxiliumque favens fer Lacedæmoniis.
(4) Romanorum omnino nullus, neque privatæ conditionis, neque
senatorius, ante Mummium, quod ego sciam, in Græcorum templis
donum ullum ponendum curavit. Primus Mummius de manubiis
Achæorum Jovem in Olympia æneum dedicavit, ad lævam ejus, qui
a Lacedæmoniis dedicatus fuerat, proxime ad primam templi
columnam. Quod vero maximum omnium æneorum signorum, quæ
in Alti posita sunt, Jovis est signum ab ipsis Eleis confecto Arcadico
bello dedicatum, altitudinis pedum septem et viginti. (5) Justa vero
Pelopis delubrum pila est modice a solo eminens, et super ea
parvum Jovis simulacrum altera manu prolata. Ex adverso alia sunt
perpetua serie collocata signa: inter ea Jovis et Ganymedis. Homerus
quidem carminibus mandavit suis, raptum a diis Ganymedem Jovi ut
pocula ministraret: pro eo vero equos Troi patri datos. Dedicavit
Gnathis Thessalus: fecit Aristocles discipulus et filius Cleœtæ. (6)
Alius ibidem Juppiter est impuber, inter Micythi dona. Quis hic
Micythus fuerit, unde oriundus, et quam ob causam multa in
Olympia dona posuerit, suo loco exponemus. Paululum hinc recta
progressis aliud est Jovis impuberis signum. Dedicarunt Elaitæ, qui
Æolidem tenent primi, si e Caici campo ad mare descendas. (7) Aliud
proxime positum est Jovi signum: inscriptio testatur, Cnidios
Chersonesi incolas de hostium spoliis dedicasse. Jovi hinc Pelopem,
illinc Alpheum amnem apposuerunt. Et Cnidiorum quidem urbis pars
maxima in continenti Cariæ terra condita est, et ibi sunt quæ apud
ipsos habentur maxime memoratu digna. Quæ vero Chersonesus
dicitur, insula est continenti terræ proxima et ponte cum ea
conjuncta. (8) Et ii quidem, qui hic habitant, Olympiæ donaria illa
Jovi dedicaverunt, perinde ac si Ephesiorum ii, qui eam, quæ
Coressus vocatur, urbis partem tenent, communi Ephesiorum nomine
donum se dedicasse dicant. Est etiam ad Altis murum appositus
Juppiter ad solis occasum conversus, sine inscriptione. Vulgavit fama
hunc quoque a Mummio de Achaicis manubiis dicatum. (9) In curia
Jovis est signum specie perfidiosis hominibus quam maxime
formidanda. Horcius ei cognomen, id est Jurisjurandi vindex. Utraque
manu fulmen tenet. Solenne vero athletis omnibus, eorumque
parentibus, fratribus, gymnasii magistris, super exsecti suis testibus
verbis conceptis dejerare, nihil se fraudis facturos, quominus
Olympici ludi rite fiant. Athletæ quidem ipsi hoc amplius jurant, se
decem perpetuos menses accurate meditatos, quæ ad
exercitationem requiruntur. (10) Jurant præterea qui vel de viris, vel
de pullis equorum in certamen prodeuntium pronunciaturi sunt,
judicaturos juste nec ob rem judicandam pecuniam se ullam
capturos: qua vero re adducti quemvis aut probarint aut improbarint,
se non esse in vulgus prolaturos. Jam vero sus ille confecto
athletarum jurejurando cuinam sit usui, percontari in mentem non
venit. Veteri quidem religione sancitum scio, ne victima vescerentur
homines, super qua jusjurandum conceptum fuisset. (11) Id
Homerus etiam perspicue testatur, quum exsectum illum suem,
super quo Agamemnon jusjurandum concepit, Briseidem se non
attigisse, in mare a præcone abjectum dixit:
Hoc ait, atque suis præduro guttura ferro
dissecuit; quem Talthybius contorsit in undas
piscibus æquoreis escam.
Atque hoc quidem prisci fuit ritus institutum. Ante Horcii Jovis pedes
ænea tabella est, in qua incisi elegi sunt ad pejerantium terrorem
compositi. Jam enumeravimus quam accuratissime, quicunque Jovi
intra Altin signa posita sint. Nam quod prope maximum templum
Corinthius quidam dedicavit (non de priscis ille quidem Corinthiis,
sed de iis quos Imperator in urbem deduxit), hoc signum est
Alexander Philippi filius, in Jovis habitum videlicet fictus.
CAPUT XXV.
Alia præter Jovis signa recensentur, signa chori puerorum a Messaniis naufragis
Olympiæ posita — puerorum ab Agrigentinis in muro Altis posita — de populis
qui Siciliam incolunt — binis Herculis signis — signis eorum, qui ad certamen
cum Hectore ineundum sorte ducti sunt — signo Herculis de cingulo cum
Amazone certantis - signo Herculis a Thasiis posito.
Jam vero et ea persequemur signa, quæ Jovem non exprimunt:
imagines autem quæ non religionis causa, sed ad homines
honestandos positæ sunt, eas recensebimus in athletarum
commemoratione. (2) Quum Messanii freti accolæ ex antiquo
instituto Rhegium pueros triginta quinque, cumque his chori
magistrum et tibicinem misissent ad patrios quosdam Rheginorum
ludos, nave fracta, pueri omnes periere et ne unus quidem servatus
est. Est enim fretum illud fœdissimis in toto mari tempestatibus
infame: (3) siquidem venti e diversa superi inferique maris regione
(quæ maria Adriam e Tyrrhenum vocant) spirantes, ab alto undas
cient, et procellis infestissimas reddunt. Quin et quum venti posuere,
ea est influentis et refluentis pelagi concitatio, tam gravis belluarum
magna copia innatantium odor, ut naufragis in hoc freto nulla salutis
reliqua fiat spes. Quodsi navem ibi Ulixes fregisset, non ille quidem
in Italiam incolumis enatasset. Sed nimirum deorum lenitas in
omnibus infortuniis malorum aliquam allevationem affert. (4) Tum
vero Messanii istum puerorum interitum lugebant, et quum alios illis
honores habuere, tum statuam ex ære suam singulis posuere,
cumque iis una chori magistro et tibicini. Vetus inscriptio donum esse
Messaniorum indicat freti accolarum. Interjecto dein tempore,
Hippias, qui inter Græcos sapientiæ laude claruit, elegis titulos
earum statuarum composuit. Sunt illæ quidem Callonis Elei opus. (5)
Est ad Pachynum (immo Lilybæum) Siciliæ promontorium, quod in
Libyam et ad Austros controversum est, Motye urbs, quam Libyes
Pœnis permisti tenent. Cum ea barbarorum civitate Agrigentini bello
commisso et præda ex iis acta, de manubiis puerorum æneas
posuere statuas, dexteras tendentium, et vota se Jovi nuncupare
significantium in ipsis Altis muris: Calamidis opus esse statuas illas et
ipse suspicabar, et hominum sermone vulgatum est. (6) Siciliam
quidem gentes hæ incolunt, Sicani, Siculi, Phryges: et illi quidem ex
Italia, Phryges vero a Scamandro fluvio et Troade regione eo
transmisere. At Libyes et Pœnos una et eadem classe in coloniam
deduxere Carthaginienses. Atque hi quidem e barbaris gentibus
Siciliæ inquilini. E Græcis vero Dores, et Iones eam incolunt, Phocici
etiam et Attici nominis pars non utique magna. (7) In eodem Altis
muro præter Agrigentinorum dona sunt et Herculis signa duo nuda,
ætate puerili: unus idem ad ejus imaginem expressus, qui sagittis in
Nemea leonem confecit. Hunc cum leone dicavit Tarentinus
Hippotion, Nicodami Mænalii opus; alterum vero signum Anaxippi
Mendæi dedicatio fuit, et in hunc locum ab Eleis transportatum est,
quum ante positum esset in fine ejus viæ, quæ in Olympiam ex Elide
ducit, et Sacra dicitur via. (8) Dedicarunt vero communi impensa
Achaici concilii populi eorum signa, qui ex provocatione cum Hectore,
sorte ducti, erant singulari certamine congressuri: atque hi quidem
hastis et clypeis armati prope magnum templum stant: e regione
insistit basi alteri Nestor, conjectis in galeam sortibus. (9) Et sorte
quidem novem exiere, sed octo duntaxat exstant: nam Ulyssem (fuit
enim et ipse in eo numero) Nero Romam asportasse dicitur. Eorum
igitur octo signorum uni tantum, Agamemnoni scilicet, nomen
adscriptum est, a dextera quidem in lævam partem excurrentibus
literis. (10) Et is quidem, cujus in scuto pro insigni gallus gallinaceus,
Idomeneus est Minois nepos, a Pasiphae Solis filia oriundus:
gallinaceum autem Soli sacram avem celebrant, quod cantu solis
ortum nunciet. Incisi sunt hi in basi elegi:
Signa Jovi hæc olim magno posuistis Achivi,
queis genus a divo Tantalida Pelope.
Hoc igitur in illo loco scriptum est: sed opificis nomen in ipso
inscriptum est Idomenei scuto:
Præstans laude operum multorum hoc fecit Onatas,
cui patria Ægine, cuique Micon genitor.
CAPUT XXVI.
(3) Hic est ille equus, cui hippomanes infusum esse Elei tradunt.
Apertum autem nonnisi magi artificio illa equo accidere. Magnitudine
ille quidem et specie inferior est equis plerisque intra Altin positis;
insuper deformiorem cauda præcisa reddit. (4) Sed illum mares equi
non vere tantum, sed plane quavis anni parte et die appetunt.
Irrumpentes enim vel effractis vinculis intra Altin, vel e rectorum
manibus elapsi, illum invadunt, nihil hercle minus furenter, quam si
viventem pulcherrimam equam gregalem inituri adorirentur. Cedunt
illis quidem ungulæ; non prius tamen desinunt hinnitu omnia late
complere, rabidoque impetu identidem in eum insilire, quam scuticis
et acriori aliqua vi edomiti ab illo ære abstrahantur. (5) Atque aliud in
Lydia ipse miraculum vidi, illud quidem a Phormidis equo diversum,
nec tamen minus magorum artis expers. Sunt in Lydis, qui Persici
cognomine vocantur, urbium Hierocæsareæ quæ dicitur et
Hypæporum templa. In utroque templo est cella cum ara; super ea
cinis alio longe colore a vulgari cinere. (6) Huc ingressus magus ubi,
foco aridis lignis impositis, tiara caput velarit, invocat deum nescio
quem: ex libro enim carmen recitat barbaricum, lingua plane ignota
Græcis. Ubi peroravit, sponte sua e lignis, nullo igne admoto,
purissima emicat flamma. Sed ut redeat, unde huc digressa est
oratio, (7) inter Phormidis donaria ipsius Phormidis statua visitur
cum hoste cominus dimicans, uno, et item altero ac tertio.
Adscriptum est, pugnantem illum militem Phormin Mænalium esse:
dedicatum fuisse a Syracusano Lycorta. Satis perspicuum cuivis esse
potest, dedicasse Lycortam necessitudine adductum Phormidis. A
Græcis (Ab Eleis?) tamen, quæ Lycortæ fuerunt dona, Phormidis
appellantur. (8) At Mercurius arietem sub ala portans, galea caput
armatus, idemque amictus tunica et chlamyde, nihil omnino is ad
Phormidis donaria pertinet. Olympio enim Jovi Pheneatæ ex Arcadia
illum dedicarunt. Fecisse Onatam Æginetam, et cum eo simul
Callitelem, indicat inscriptio. Fuit autem Onatæ vel discipulus vel
filius, uti ego arbitror, Calliteles. Non longe a Pheneatarum dono
aliud est Mercurii signum: caduceum is tenet: testatur inscriptio
positum a Glaucia Rhegino, opificem fuisse Callonem Eleum. (9)
Duæ item ex ære boves ibidem sunt: alteram Corcyræi, Eretrienses
alteram dedicarunt, Eretriensis Philesii opus. Quam ob rem vero
Corcyræi bovem in Olympia unam, et unam item Delphis dedicarint,
quum ad Phocensium res pervenerit historia, exponemus. Jam quod
de Olympica eorum bove me audire memini, id hujusmodi est: (10)
parvulum puerum, quum sub ea bove sedens pronus luderet,
sublatum temere caput tam vehementer æri impegisse, ut ex eo
vulnere non ita multis post diebus e vita excesserit. Elei bovem
cædis ream extra Altin exportare in animo habebant; sed Apollinis
Delphici oraculo moniti sunt, ut bovem eo ritu expiarent, quo solent
Græci inconsultæ cædis fraudem eluere. (11) Est sub platanis circa
medium fere Altis ambitum æneum tropæum: titulus in affixo ibi
clypeo incisus docet, Eleos victis Lacedæmoniis illud erexisse. Hæc
nempe illa fuit pugna, in qua miles iste animam exhalavit, cujus
cadaver, quum Junonis templum sartum tectum curarent, inter tecti
fastigium et lacunar cum armis repertum est. (12) Mendæorum, qui
sunt in Thracia, donum propemodum me fefellit, ut quinquertionis
statuam esse putarem. Posita illa quidem est juxta Eleum
Anauchidan, halteres priscos tenens. Verum in ejus femore inscriptio
elegiacis versibus hæc est incisa,
Mendæi, Sipte sævo Mavorte subacta,
primitias summo hic me posuere Jovi.
Sipte Thraciæ castellum vel urbs esse videtur. Mendæi ipsi e Græcia
atque adeo ex Ionia oriundi sunt. Sedes eorum ab eo mari, quod
Ænum urbem alluit, tendunt versus superiorem regionis partem.
PAUSANIÆ DESCRIPTIONIS GRÆCIÆ ELIACA
POSTERIORA SIVE LIB. VI.
CAPUT I.
CAPUT II.
Statuæ Lacedæmoniorum equis alendis inclitorum — de statua Thrasybuli vatis et
prisca ex animalium extis vaticinandi ratione — Iamidis vatibus — Timosthenis
et Antipatri aliorumque statuis — Messenii e Peloponneso ejecti victoriarum in
ludis Olympicis expertes sunt et reducti illarum participes evadunt.
Pancratiastæ vero, quæ proxima est, statuam elaboravit Lysippus.
Primus ille quidem vir quum reliquorum Acarnanum, tum eorum qui
Stratum urbem incolunt palmam pancratii tulit: ** Xenarces ei
nomen; Philandridæ filius fuit, Lacedæmonii certe post irruptionem
Persarum in Græciam Græcis omnibus equos alendi studio
præstitere. Quare, præter eos, quorum superius mentionem feci, hi
alii sunt e Spartanis equis alendis nobilitati, quorum imagines post
Acarnanis athletæ effigiem positæ, Xenarces, Lycinus, Arcesilaus, et
Arcesilai filius Lichas. (2) Et Xenarces quidem insuper etiam
Delphica, Argolica et Corinthiaca victoria claruit. Lycinus quum ad
ludos in Olympiam pullos adduxisset et eorum unus deterior visus
esset, in equorum jam adultorum certamine hos pullos commisit et
per eos victoriam est adeptus. Dedicavit ille in Olympia statuas duas,
quas Myron Atheniensis fecit. Arcesilao Lichæ patri Olympiæ victoriæ
duæ obtigerunt: Lichas vero, quum Lacedæmoniis tunc ludorum
aditu interdictum esset, Thebani populi nomine currum introduxit,
victoremque aurigam sua ipse manu tænia redimivit: atque ob eam
rem flagellarunt eum Hellanodicæ. (3) Hunc propter Licham
Lacedæmonii Agidis regis ductu cum exercitu Eleos invaserunt
pugnamque intra Altin cum eis commiserunt. Finito bello, hoc in loco
statuam Lichas posuit. Indicant Eleorum literæ quibus victores
Olympici recensentur, non Lichæ, sed Thebano populo eam palmam
decretam. (4) Non longe a Licha statua posita est Thrasybulo Æneæ
filio vati, ex Iamidarum familia, qui suam Mantinensibus contra
Agidem Lacedæmoniorum regem, Eudamidæ filium, operam navavit;
qua de re agam pluribus, quum ad Arcadum res venero. Per
Thrasybuli dexterum humerum in effigie stellio repit: prope canis
jacet bipartito dissectus, nudato jecinore. (5) Vetus est et antiquitus
hominibus instituta ex hœdis, agnis, vitulis aruspicina. Suem primi
omnium Cyprii addidere. Cane vero ad extorum significationes nullæ
omnino gentes utuntur. Peculiarem itaque credi facile potest e
caninis visceribus divinationem sibi Thrasybulum instituisse. Vates,
qui Iamidæ nuncupantur, ab Iamo oriundi sunt, quem Apollinis satu
ortum et a patre divinandi peritiam accepisse, carmine prodidit
Pindarus. (6) Prope Thrasybuli effigiem Timosthenes Eleus positus
est, qui pueros in stadio vicit. Milesius deinde Antipater, Clinopatri
filius, qui pueros in pugilatu perculit. Hujus Antipatri patrem Dionysii
Syracusani legati ad Olympium Jovem cum muneribus missi, pecunia
delinitum adduxerant ut filium victorem Syracusanum renunciari
vellet. At Antipater contemptis tyranni donis, Milesium se esse et ex
Ionibus primum in Olympia statuam dedicasse; elogio testatus est.
(7) Fecit eam statuam Polycletus: Timosthenis effigiem elaboravit
Eutychides Sicyonius, Lysippi discipulus. Hic idem Eutychides Syris
quoque Orontæ accolis Fortunæ signum fecit, quod magna cum
religione apud eas gentes colitur. (8) Proxime ad Timosthenis
statuam in Alti Timon positus est, et cum eo Æsepus filius tener
adhuc, equo insidens, qua scilicet ætate equo injuge vicit. Timon
quidem de curuli certamine victor renunciatus est. Ejus et filii
effigiem fecit Dædalus Sicyonius, qui etiam, victis prœlio Laconibus,
tropæum Eleis in Alti erectum elaboravit. (9) Posita etiam est Samio
pugili statua cum inscriptione, quæ dicatam testatur a Mycone
gymnicorum magistro; eademque Samiis in athleticis certaminibus et
navalibus pugnis præ ceteris Ionibus laudem summam tribuit: de
pugile autem ipso nominatim nulla mentio. (10) Positus ibidem est
Messenius Damiscus, qui annos natus duodecim palmam ex
Olympicis ludis tulit. Fuit autem ea mihi res haud minus quam alia
quævis admirationi, quod eadem ferme fortuna Messeniis et patriam
et Olympicorum ludorum gloriam eripuerit. Neque enim postquam e
Peloponneso ejecti sunt, aut ex Naupacto, aut e Sicilia, præter
Leontiscum et Symmachum freti accolas, quisquam e Messeniis
victor declaratus est; quum tamen Siculi hos non Messenios, sed de
priscis Zanclæis fuisse contendant. (11) Sed postquam in
Peloponnesum rediere, pristina etiam eos comitata est fortuna
Olympica: siquidem uno post Messenen restitutam anno ludos Eleis
facientibus hic ipse Damiscus pueros stadio vicit; et quinquertii post
hanc ei partim Nemeæ, partim vero Isthmicæ victoriæ obtigere.
CAPUT III.