SlideShare a Scribd company logo
Sponsored by
Using FireMonkey as a game engine
Patrick Prémartin
DELPHICON 2021
The Official Online Conference All About Embarcadero Delphi
delphicon.embarcadero.com
Sponsored by
Agenda
● What is a game engine ?
● What is FireMonkey ?
● Why using FireMonkey to code games ?
● Really ? Games in Delphi FMX ?
● Managing music and sound effects
● Managing backgrounds and scenes
● Managing user interface
● Managing sprites, animations and collisions
● What about 3D ?
● You want more ?
Sponsored by
Speaker
● Patrick Prémartin - MVP Embarcadero
● Freelance Delphi and web developer since 2000
(just after the bug)
● Delphi user since the beginning and before
with Borland / Turbo Pascal.
● Game coder since a little more (TO7-70 J)
Sponsored by
Speaker
● Patrick Prémartin - MVP Embarcadero
● Follow me on :
● GitHub : https://github.com/DeveloppeurPascal
● Itch.io : https://gamolf.itch.io
● Twitch : https://www.twitch.tv/patrickpremartin
● My blog : https://developpeur-pascal.fr
● LinkedIn : https://www.linkedin.com/in/patrickpremartin/
Sponsored by
What is a game engine ?
● A game engine is a library or set of components available to
create games.
● You have code, SDK and sometimes editor tools or you can use
external tools like Tiled to create your scenes and maps.
● A game engine is not a complete game making software like
you have with GameMaker Studio, AppGameKit Studio, Game
Guru, Clickteam Fusion, Unreal Engine or Unity but the code to
work with when creating games.
Sponsored by
What is a game engine ?
● There are a lot of game making software and game engines
coded in Pascal.
● One of the most known is Castle Game Engine available at
https://castle-engine.io/
It now has Delphi compatibility. Look at Michalis Kamburelis
DelphiCon 2021 session to know more about it.
https://delphicon.embarcadero.com/talks/castle-game-engine-
coming-to-delphi/
Sponsored by
What is a game engine ?
● You perhaps eared about some of this other game engines for
Delphi or Pascal developers :
○ Gorilla 3D Framework : https://www.gorilla3d.de
○ Apus Game Engine : https://github.com/Cooler2/ApusGameEngine
○ SDL2 for Pascal : https://github.com/PascalGameDevelopment/SDL2-for-
Pascal
○ Andorra 2D, Turbu, Asphyre, DelphiX, Rage3D, and a lot more listed at
https://wiki.freepascal.org/Game_Engine
Sponsored by
What is FireMonkey ?
● FireMonkey is the multiplatform set of components and
libraries available in Delphi.
● You have VCL for Windows projects since Delphi 1.
● And since Delphi XE2 we have FireMonkey for all major
platforms.
● With Delphi 11 Alexandria you can target Windows, Mac, Linux,
iOS and Android platforms depending on your license level.
Sponsored by
What is FireMonkey ?
● The idea behind FireMonkey is to have one project and one
source code to target all major platforms.
● You don’t need to know “platforms languages” like Objective-C,
Swift, Java, Kotlin, C, C++, C#, .Net, …
Sponsored by
What is FireMonkey ?
● FireMonkey includes classic visual components but also
shapes, animations, visual effects, 3D, access to system API
and other libraries.
● It’s included in all Delphi license level even the Community
Edition (free for personal use) and Academic Edition.
Sponsored by
Why using FireMonkey to code games ?
● The simple answer could be “why not ?” and in fact it’s the first
reason I had to play with it.
● Second answer is more technical :
● FireMonkey draws everything on screen by default.
● Visual components are sets of shapes and effects. They are styled and can
be changed without coding.
● We have 2D and 3D components and layers in standard.
Sponsored by
Why using FireMonkey to code games ?
● The simple answer could be “why not ?” and in fact it’s the first
reason I had to play with it.
● Second answer is more technical :
● Touch, mouse and keyboard are managed by Delphi. It works for classic
programs, so it works for games too.
● We can use properties and events, timers and threads, multi resolution
images and bitmaps, classes and all thinks needed to code games.
Sponsored by
Really ? Games in Delphi FMX ?
● In 2021 I streamed weekly game coding sessions on Twitch,
with Delphi and FireMonkey.
● Published games are available at https://gamolf.itch.io
● Some projects have been open sourced on my GitHub account:
https://github.com/DeveloppeurPascal/DevPas-Games-Pack
● A lots of other projects are available with “delphi-game”
hashtag: https://github.com/topics/delphi-game
Sponsored by
Really ? Games in Delphi FMX ?
● You can also check the showcase part of Embarcadero blogs at
https://blogs.embarcadero.com/category/showcase/
● And more on iOS and Android stores !
● Simply look at the list of games which developers forgot to
change default package name in their project options :
https://www.google.com/search?q=%22com.embarcadero.%22
+game+site%3Aplay.google.com
Please don’t forget to personalize your project version info option page.
Sponsored by
How to ?
● Know, let’s look a little more at developer side of game making
with FireMonkey projects in Delphi.
● You’ll find code samples and usable Delphi units on GitHub at
https://github.com/DeveloppeurPascal/DelphiFMXGameSnippe
ts
Sponsored by
Managing music and sound effects
● Managing sounds in a Delphi project is simple. We have a
component for that : TMediaPlayer.
● In my games I use it to play MP3 music in background. A timer
check if the music is over and restart it for a loop.
● For sound effects, I play WAV files with another TMediaPlayer
(or more than one in a TObjectList<TMediaPlayer> depending
on the game).
● To do the same, use the TMusicLoop class in uMusicLoop.pas
Sponsored by
Managing backgrounds and scenes
● For backgrounds and scenes, I use TImage component, the Fill
property of shapes like TRectangle or TCircle and the TPath to
draw SVG path depending on my needs.
● All FireMonkey visual components are containers. They can be
parents for all other visual components.
● All visual components have opacity, rotation and scale
properties.
Sponsored by
Managing backgrounds and scenes
● We can use nonvisual components to change property values in
a specific duration (TFloatAnimation is very useful).
● We have visual effect as nonvisual components like
TShadowEffect and TGlowEffect, useful for games and classic
programs to show errors or needed edit fields.
● It give us unlimited possibilities without coding anything… and
of course we can code !
Sponsored by
Managing backgrounds and scenes
● For Egg Hunter project, available at https://gamolf.itch.io/egg-
hunter, I needed to manage sprites positions and actions in
different threads.
● I wanted 60 FPS (because we need goals in life).
● I didn’t check if I succeeded but the result is good enough in
term of user experience.
Sponsored by
Managing backgrounds and scenes
● My scene is a TImage. I never draw on it.
● I use a TBitmap in background as a buffer. It’s only refreshed
depending on the viewport position and sprite actions.
● A timer checks every 16ms if I changed the buffer bitmap. If so,
I copy it to the scene image.
● It’s simple. Just need some Booleans and TMutex to avoid
access violations, conflicts and sprites flipping.
Sponsored by
Managing backgrounds and scenes
● In other games, I simply use TLayout on a TForm to simulate a
Z-Index if needed.
● You have a sample at
https://github.com/DeveloppeurPascal/DelphiFMXGameSnippe
ts/tree/main/AnimationVaguesEtCanards
● I used it for Ok Ducky ! game available at
https://gamolf.itch.io/ok-ducky
Sponsored by
Managing user interface
● User interface is simple : I can use styled visual components,
shapes, images, …
● For texts I user TLabel if I want the look and feel of the OS or
TText when I prefer to change color, size and font in my
program.
● For buttons I use TButton, a personalized button style or I
“draw” them in a TFrame with TRectangle, images, effects and
texts.
Sponsored by
Managing user interface
● Have a look at this 2018 CodeRage replay to see how I proceed :
https://serialstreameur.fr/coderage2018-christmasgame-
codereview.php
● This project source code is available on GitHub :
https://github.com/DeveloppeurPascal/CodeRage2018-
ChristmasGame
Sponsored by
Managing sprites, animations and collisions
● For sprites I use the bitmap kind of Fill property from
TRectangle or TCircle components.
● For other visual elements I use TImage with a TImageList or the
background (Fill.Bitmap) of other shapes.
Sponsored by
Managing sprites, animations and collisions
● Animating is easy : FireMonkey give us a TBitmapListAnimation
component which accepts a sprite sheet.
● Look this samples :
https://github.com/DeveloppeurPascal/DelphiFMXGameSnippe
ts/tree/main/AnimSpriteExplosion
and
https://github.com/DeveloppeurPascal/DelphiFMXGameSnippe
ts/tree/main/AnimSpritePersonnage
Sponsored by
Managing sprites, animations and collisions
● To check collisions, I use what Delphi use for the visual
components and testing mouse clicks.
● IntersectRect() is a very useful (too unknown) method to check
if two rectangles collide.
● It’s standard. It works since more than 26 years in the VCL and
now in FMX. Why not using it ?
Sponsored by
Managing sprites, animations and collisions
● For circles I calculate the distance between center of each circle
and compare it to the sum of their radius.
● You have a sample with Soap Bubbles game available at
https://gamolf.itch.io/soap-bubbles
● The base code for this game is available on GitHub :
https://github.com/DeveloppeurPascal/DelphiFMXGameSnippe
ts/tree/main/JeuDesCercles
Sponsored by
Managing sprites, animations and collisions
● For circle versus a rectangle, I calculate the distance between
the circle center and each angle of the rectangle.
● The classic sample for this is a Pong or Breakout game, when
the ball hits a wall or a brick.
● You have the source code of a sample breakout done for Learn
To Code Summer Camp 2021 event at
https://github.com/DeveloppeurPascal/Casse-Briques
Sponsored by
What about 3D ?
● 3D is little more complicated, but FireMonkey includes 3D
viewport and 3D shapes.
● You can use them to create games like did Grégory Bersegeay,
another French Embarcadero MVP, for
○ 3D Pong : a pong game in 3D.
https://github.com/gbegreg/FMXPong
○ FMX Corridor : a The Light Corridor remake.
https://github.com/gbegreg/FMXCorridor
○ FMX Island : an island in 3D, base for FPS games.
https://github.com/gbegreg/FMXISland
Sponsored by
You want more ?
● Did I say it’s simple to use Delphi and FireMonkey for game
coding and deploying them for Windows, Mac, Linux, iOS and
Android devices ?
● With those samples and links, I hope you have all what you need
to understand how to use FireMonkey as a game engine in your
games.
● If not, contact me and tell me what is missing or submit new
feature requests directly in Embarcadero’s Quality Portal.
Sponsored by 31
Q&A
Sponsored by
Q&A
● Sorry, I’m not live for Q&A during DelphiCon 2021 but if you
want to talk, leave me a message on LinkedIn or at
https://developpeur-pascal.fr/contact/
● You also can talk with me on Twitch during a live (game or
other) coding stream at
https://www.twitch.tv/patrickpremartin
● Please write in French or English.
Use https://www.deepl.com/translator tool to translate if
needed.
Sponsored by
THANK YOU!
Ad

Recommended

30.public key infrastructure (pki)
30.public key infrastructure (pki)
Universitas Bina Darma Palembang
 
An Introduction to the Yocto Embedded Framework 2018
An Introduction to the Yocto Embedded Framework 2018
ICS
 
Kriptografi - MD5
Kriptografi - MD5
KuliahKita
 
Talking TUF: Securing Software Distribution
Talking TUF: Securing Software Distribution
Docker, Inc.
 
SFO15-200: Linux kernel generic TEE driver
SFO15-200: Linux kernel generic TEE driver
Linaro
 
LCU14-103: How to create and run Trusted Applications on OP-TEE
LCU14-103: How to create and run Trusted Applications on OP-TEE
Linaro
 
Презентация МЭРТ
Презентация МЭРТ
Ipolito
 
MTs.N Daftar Nomor Telepon
MTs.N Daftar Nomor Telepon
MTs.N Cirebon II
 
Status update-qemu-pcie
Status update-qemu-pcie
The Linux Foundation
 
penyuluhan TPTKP.ppt
penyuluhan TPTKP.ppt
angganovrian665
 
BKK16-110 A Gentle Introduction to Trusted Execution and OP-TEE
BKK16-110 A Gentle Introduction to Trusted Execution and OP-TEE
Linaro
 
HKG15-311: OP-TEE for Beginners and Porting Review
HKG15-311: OP-TEE for Beginners and Porting Review
Linaro
 
Bootstrap process of u boot (NDS32 RISC CPU)
Bootstrap process of u boot (NDS32 RISC CPU)
Macpaul Lin
 
WinFE: The (Almost) Perfect Triage Tool
WinFE: The (Almost) Perfect Triage Tool
Brent Muir
 
MATERI TPTKP.pptx
MATERI TPTKP.pptx
PurnomoBudiSetiyawan
 
Laporan praktikum iv.1 visual
Laporan praktikum iv.1 visual
rahmi wahyuni
 
System Analysis and Design - Unified Modeling Language (UML)
System Analysis and Design - Unified Modeling Language (UML)
Dudy Ali
 
ELF
ELF
Koganti Ravikumar
 
HKG18-402 - Build secure key management services in OP-TEE
HKG18-402 - Build secure key management services in OP-TEE
Linaro
 
11 12 -pengurutan dan-pencarian
11 12 -pengurutan dan-pencarian
Wandi Parlente
 
Easy coding a multi device game with FireMonkey
Easy coding a multi device game with FireMonkey
pprem
 
Game Programming I - GD4N
Game Programming I - GD4N
Francis Seriña
 
Android game engine
Android game engine
Julian Chu
 
Introduction to android (and mobile) game development
Introduction to android (and mobile) game development
Ruslan Novikov
 
The Ring programming language version 1.7 book - Part 53 of 196
The Ring programming language version 1.7 book - Part 53 of 196
Mahmoud Samir Fayed
 
The Ring programming language version 1.2 book - Part 36 of 84
The Ring programming language version 1.2 book - Part 36 of 84
Mahmoud Samir Fayed
 
The Ring programming language version 1.4 book - Part 14 of 30
The Ring programming language version 1.4 book - Part 14 of 30
Mahmoud Samir Fayed
 
Introduction to Game Engine: Concepts & Components
Introduction to Game Engine: Concepts & Components
Pouya Pournasir
 
engine_terminology 2
engine_terminology 2
Alexballantyne
 
Tools for developing Android Games
Tools for developing Android Games
Platty Soft
 

More Related Content

What's hot (12)

Status update-qemu-pcie
Status update-qemu-pcie
The Linux Foundation
 
penyuluhan TPTKP.ppt
penyuluhan TPTKP.ppt
angganovrian665
 
BKK16-110 A Gentle Introduction to Trusted Execution and OP-TEE
BKK16-110 A Gentle Introduction to Trusted Execution and OP-TEE
Linaro
 
HKG15-311: OP-TEE for Beginners and Porting Review
HKG15-311: OP-TEE for Beginners and Porting Review
Linaro
 
Bootstrap process of u boot (NDS32 RISC CPU)
Bootstrap process of u boot (NDS32 RISC CPU)
Macpaul Lin
 
WinFE: The (Almost) Perfect Triage Tool
WinFE: The (Almost) Perfect Triage Tool
Brent Muir
 
MATERI TPTKP.pptx
MATERI TPTKP.pptx
PurnomoBudiSetiyawan
 
Laporan praktikum iv.1 visual
Laporan praktikum iv.1 visual
rahmi wahyuni
 
System Analysis and Design - Unified Modeling Language (UML)
System Analysis and Design - Unified Modeling Language (UML)
Dudy Ali
 
ELF
ELF
Koganti Ravikumar
 
HKG18-402 - Build secure key management services in OP-TEE
HKG18-402 - Build secure key management services in OP-TEE
Linaro
 
11 12 -pengurutan dan-pencarian
11 12 -pengurutan dan-pencarian
Wandi Parlente
 
BKK16-110 A Gentle Introduction to Trusted Execution and OP-TEE
BKK16-110 A Gentle Introduction to Trusted Execution and OP-TEE
Linaro
 
HKG15-311: OP-TEE for Beginners and Porting Review
HKG15-311: OP-TEE for Beginners and Porting Review
Linaro
 
Bootstrap process of u boot (NDS32 RISC CPU)
Bootstrap process of u boot (NDS32 RISC CPU)
Macpaul Lin
 
WinFE: The (Almost) Perfect Triage Tool
WinFE: The (Almost) Perfect Triage Tool
Brent Muir
 
Laporan praktikum iv.1 visual
Laporan praktikum iv.1 visual
rahmi wahyuni
 
System Analysis and Design - Unified Modeling Language (UML)
System Analysis and Design - Unified Modeling Language (UML)
Dudy Ali
 
HKG18-402 - Build secure key management services in OP-TEE
HKG18-402 - Build secure key management services in OP-TEE
Linaro
 
11 12 -pengurutan dan-pencarian
11 12 -pengurutan dan-pencarian
Wandi Parlente
 

Similar to Using FireMonkey as a game engine (20)

Easy coding a multi device game with FireMonkey
Easy coding a multi device game with FireMonkey
pprem
 
Game Programming I - GD4N
Game Programming I - GD4N
Francis Seriña
 
Android game engine
Android game engine
Julian Chu
 
Introduction to android (and mobile) game development
Introduction to android (and mobile) game development
Ruslan Novikov
 
The Ring programming language version 1.7 book - Part 53 of 196
The Ring programming language version 1.7 book - Part 53 of 196
Mahmoud Samir Fayed
 
The Ring programming language version 1.2 book - Part 36 of 84
The Ring programming language version 1.2 book - Part 36 of 84
Mahmoud Samir Fayed
 
The Ring programming language version 1.4 book - Part 14 of 30
The Ring programming language version 1.4 book - Part 14 of 30
Mahmoud Samir Fayed
 
Introduction to Game Engine: Concepts & Components
Introduction to Game Engine: Concepts & Components
Pouya Pournasir
 
engine_terminology 2
engine_terminology 2
Alexballantyne
 
Tools for developing Android Games
Tools for developing Android Games
Platty Soft
 
SDL2 Game Development VT Code Camp 2013
SDL2 Game Development VT Code Camp 2013
Eric Basile
 
PRESENTATION ON Game Engine
PRESENTATION ON Game Engine
Diksha Bhargava
 
Funky game engines
Funky game engines
eduriez
 
Scmad Chapter07
Scmad Chapter07
Marcel Caraciolo
 
Delta Engine @ CeBit 2011
Delta Engine @ CeBit 2011
Karsten Wysk
 
Advanced Castle Game Engine features - forms, 3D generation, shaders, customi...
Advanced Castle Game Engine features - forms, 3D generation, shaders, customi...
Michalis Kamburelis
 
Cocos2d programming
Cocos2d programming
Changwon National University
 
Programmers guide
Programmers guide
Karla Paz Enamorado
 
Game Engine Design: Anatomy of a game engine
Game Engine Design: Anatomy of a game engine
xarawig871
 
Introduction to BlackBerry 10 NDK for Game Developers.
Introduction to BlackBerry 10 NDK for Game Developers.
ardiri
 
Easy coding a multi device game with FireMonkey
Easy coding a multi device game with FireMonkey
pprem
 
Game Programming I - GD4N
Game Programming I - GD4N
Francis Seriña
 
Android game engine
Android game engine
Julian Chu
 
Introduction to android (and mobile) game development
Introduction to android (and mobile) game development
Ruslan Novikov
 
The Ring programming language version 1.7 book - Part 53 of 196
The Ring programming language version 1.7 book - Part 53 of 196
Mahmoud Samir Fayed
 
The Ring programming language version 1.2 book - Part 36 of 84
The Ring programming language version 1.2 book - Part 36 of 84
Mahmoud Samir Fayed
 
The Ring programming language version 1.4 book - Part 14 of 30
The Ring programming language version 1.4 book - Part 14 of 30
Mahmoud Samir Fayed
 
Introduction to Game Engine: Concepts & Components
Introduction to Game Engine: Concepts & Components
Pouya Pournasir
 
Tools for developing Android Games
Tools for developing Android Games
Platty Soft
 
SDL2 Game Development VT Code Camp 2013
SDL2 Game Development VT Code Camp 2013
Eric Basile
 
PRESENTATION ON Game Engine
PRESENTATION ON Game Engine
Diksha Bhargava
 
Funky game engines
Funky game engines
eduriez
 
Delta Engine @ CeBit 2011
Delta Engine @ CeBit 2011
Karsten Wysk
 
Advanced Castle Game Engine features - forms, 3D generation, shaders, customi...
Advanced Castle Game Engine features - forms, 3D generation, shaders, customi...
Michalis Kamburelis
 
Game Engine Design: Anatomy of a game engine
Game Engine Design: Anatomy of a game engine
xarawig871
 
Introduction to BlackBerry 10 NDK for Game Developers.
Introduction to BlackBerry 10 NDK for Game Developers.
ardiri
 
Ad

More from pprem (20)

Apprendre La Programmation Avec Delphi (01/27)
Apprendre La Programmation Avec Delphi (01/27)
pprem
 
Using Delphi as a no code development environment
Using Delphi as a no code development environment
pprem
 
Utiliser FireMonkey comme moteur de jeux vidéo
Utiliser FireMonkey comme moteur de jeux vidéo
pprem
 
Coder sans coder : Delphi en mode no code !
Coder sans coder : Delphi en mode no code !
pprem
 
Quoi de neuf dans la version 11 Alexandria ?
Quoi de neuf dans la version 11 Alexandria ?
pprem
 
Faire des applications web avec Delphi
Faire des applications web avec Delphi
pprem
 
Utilisation de git avec Delphi
Utilisation de git avec Delphi
pprem
 
Diffuser nos logiciels et leurs mises à jour
Diffuser nos logiciels et leurs mises à jour
pprem
 
Delphi et les tests unitaires
Delphi et les tests unitaires
pprem
 
Développer une application pour Android TV avec Delphi
Développer une application pour Android TV avec Delphi
pprem
 
Sauvegarder et restaurer l'état des applications mobiles
Sauvegarder et restaurer l'état des applications mobiles
pprem
 
Gérer le clavier virtuel sous iOS et Android
Gérer le clavier virtuel sous iOS et Android
pprem
 
Internationaliser les projets VCL / FMX
Internationaliser les projets VCL / FMX
pprem
 
Comment développer pour Linux avec Delphi
Comment développer pour Linux avec Delphi
pprem
 
Utiliser des dessins vectoriels à la place d'images
Utiliser des dessins vectoriels à la place d'images
pprem
 
Embarquer une base de données locale dans vos logiciels et applications mobiles
Embarquer une base de données locale dans vos logiciels et applications mobiles
pprem
 
Déploiement et débogage à distance
Déploiement et débogage à distance
pprem
 
Utiliser l'EDI pour développer en multiplateforme
Utiliser l'EDI pour développer en multiplateforme
pprem
 
Faire une interface adaptive avec la VCL
Faire une interface adaptive avec la VCL
pprem
 
Faire une interface adaptive avec FireMonkey
Faire une interface adaptive avec FireMonkey
pprem
 
Apprendre La Programmation Avec Delphi (01/27)
Apprendre La Programmation Avec Delphi (01/27)
pprem
 
Using Delphi as a no code development environment
Using Delphi as a no code development environment
pprem
 
Utiliser FireMonkey comme moteur de jeux vidéo
Utiliser FireMonkey comme moteur de jeux vidéo
pprem
 
Coder sans coder : Delphi en mode no code !
Coder sans coder : Delphi en mode no code !
pprem
 
Quoi de neuf dans la version 11 Alexandria ?
Quoi de neuf dans la version 11 Alexandria ?
pprem
 
Faire des applications web avec Delphi
Faire des applications web avec Delphi
pprem
 
Utilisation de git avec Delphi
Utilisation de git avec Delphi
pprem
 
Diffuser nos logiciels et leurs mises à jour
Diffuser nos logiciels et leurs mises à jour
pprem
 
Delphi et les tests unitaires
Delphi et les tests unitaires
pprem
 
Développer une application pour Android TV avec Delphi
Développer une application pour Android TV avec Delphi
pprem
 
Sauvegarder et restaurer l'état des applications mobiles
Sauvegarder et restaurer l'état des applications mobiles
pprem
 
Gérer le clavier virtuel sous iOS et Android
Gérer le clavier virtuel sous iOS et Android
pprem
 
Internationaliser les projets VCL / FMX
Internationaliser les projets VCL / FMX
pprem
 
Comment développer pour Linux avec Delphi
Comment développer pour Linux avec Delphi
pprem
 
Utiliser des dessins vectoriels à la place d'images
Utiliser des dessins vectoriels à la place d'images
pprem
 
Embarquer une base de données locale dans vos logiciels et applications mobiles
Embarquer une base de données locale dans vos logiciels et applications mobiles
pprem
 
Déploiement et débogage à distance
Déploiement et débogage à distance
pprem
 
Utiliser l'EDI pour développer en multiplateforme
Utiliser l'EDI pour développer en multiplateforme
pprem
 
Faire une interface adaptive avec la VCL
Faire une interface adaptive avec la VCL
pprem
 
Faire une interface adaptive avec FireMonkey
Faire une interface adaptive avec FireMonkey
pprem
 
Ad

Recently uploaded (20)

Best MLM Compensation Plans for Network Marketing Success in 2025
Best MLM Compensation Plans for Network Marketing Success in 2025
LETSCMS Pvt. Ltd.
 
Sysinfo OST to PST Converter Infographic
Sysinfo OST to PST Converter Infographic
SysInfo Tools
 
Foundations of Marketo Engage - Programs, Campaigns & Beyond - June 2025
Foundations of Marketo Engage - Programs, Campaigns & Beyond - June 2025
BradBedford3
 
IDM Crack with Internet Download Manager 6.42 Build 41 [Latest 2025]
IDM Crack with Internet Download Manager 6.42 Build 41 [Latest 2025]
pcprocore
 
On-Device AI: Is It Time to Go All-In, or Do We Still Need the Cloud?
On-Device AI: Is It Time to Go All-In, or Do We Still Need the Cloud?
Hassan Abid
 
Open Source Software Development Methods
Open Source Software Development Methods
VICTOR MAESTRE RAMIREZ
 
Zoneranker’s Digital marketing solutions
Zoneranker’s Digital marketing solutions
reenashriee
 
HYBRIDIZATION OF ALKANES AND ALKENES ...
HYBRIDIZATION OF ALKANES AND ALKENES ...
karishmaduhijod1
 
Threat Modeling a Batch Job Framework - Teri Radichel - AWS re:Inforce 2025
Threat Modeling a Batch Job Framework - Teri Radichel - AWS re:Inforce 2025
2nd Sight Lab
 
Milwaukee Marketo User Group June 2025 - Optimize and Enhance Efficiency - Sm...
Milwaukee Marketo User Group June 2025 - Optimize and Enhance Efficiency - Sm...
BradBedford3
 
Decipher SEO Solutions for your startup needs.
Decipher SEO Solutions for your startup needs.
mathai2
 
Emvigo Capability Deck 2025: Accelerating Innovation Through Intelligent Soft...
Emvigo Capability Deck 2025: Accelerating Innovation Through Intelligent Soft...
Emvigo Technologies
 
Enable Your Cloud Journey With Microsoft Trusted Partner | IFI Tech
Enable Your Cloud Journey With Microsoft Trusted Partner | IFI Tech
IFI Techsolutions
 
SAP PM Module Level-IV Training Complete.ppt
SAP PM Module Level-IV Training Complete.ppt
MuhammadShaheryar36
 
HPE Reseller in uae by numerosystom.pptx
HPE Reseller in uae by numerosystom.pptx
aadibva452
 
Canva Pro Crack Free Download 2025-FREE LATEST
Canva Pro Crack Free Download 2025-FREE LATEST
grete1122g
 
Y - Recursion The Hard Way GopherCon EU 2025
Y - Recursion The Hard Way GopherCon EU 2025
Eleanor McHugh
 
arctitecture application system design os dsa
arctitecture application system design os dsa
za241967
 
Shell Skill Tree - LabEx Certification (LabEx)
Shell Skill Tree - LabEx Certification (LabEx)
VICTOR MAESTRE RAMIREZ
 
IObit Driver Booster Pro 12 Crack Latest Version Download
IObit Driver Booster Pro 12 Crack Latest Version Download
pcprocore
 
Best MLM Compensation Plans for Network Marketing Success in 2025
Best MLM Compensation Plans for Network Marketing Success in 2025
LETSCMS Pvt. Ltd.
 
Sysinfo OST to PST Converter Infographic
Sysinfo OST to PST Converter Infographic
SysInfo Tools
 
Foundations of Marketo Engage - Programs, Campaigns & Beyond - June 2025
Foundations of Marketo Engage - Programs, Campaigns & Beyond - June 2025
BradBedford3
 
IDM Crack with Internet Download Manager 6.42 Build 41 [Latest 2025]
IDM Crack with Internet Download Manager 6.42 Build 41 [Latest 2025]
pcprocore
 
On-Device AI: Is It Time to Go All-In, or Do We Still Need the Cloud?
On-Device AI: Is It Time to Go All-In, or Do We Still Need the Cloud?
Hassan Abid
 
Open Source Software Development Methods
Open Source Software Development Methods
VICTOR MAESTRE RAMIREZ
 
Zoneranker’s Digital marketing solutions
Zoneranker’s Digital marketing solutions
reenashriee
 
HYBRIDIZATION OF ALKANES AND ALKENES ...
HYBRIDIZATION OF ALKANES AND ALKENES ...
karishmaduhijod1
 
Threat Modeling a Batch Job Framework - Teri Radichel - AWS re:Inforce 2025
Threat Modeling a Batch Job Framework - Teri Radichel - AWS re:Inforce 2025
2nd Sight Lab
 
Milwaukee Marketo User Group June 2025 - Optimize and Enhance Efficiency - Sm...
Milwaukee Marketo User Group June 2025 - Optimize and Enhance Efficiency - Sm...
BradBedford3
 
Decipher SEO Solutions for your startup needs.
Decipher SEO Solutions for your startup needs.
mathai2
 
Emvigo Capability Deck 2025: Accelerating Innovation Through Intelligent Soft...
Emvigo Capability Deck 2025: Accelerating Innovation Through Intelligent Soft...
Emvigo Technologies
 
Enable Your Cloud Journey With Microsoft Trusted Partner | IFI Tech
Enable Your Cloud Journey With Microsoft Trusted Partner | IFI Tech
IFI Techsolutions
 
SAP PM Module Level-IV Training Complete.ppt
SAP PM Module Level-IV Training Complete.ppt
MuhammadShaheryar36
 
HPE Reseller in uae by numerosystom.pptx
HPE Reseller in uae by numerosystom.pptx
aadibva452
 
Canva Pro Crack Free Download 2025-FREE LATEST
Canva Pro Crack Free Download 2025-FREE LATEST
grete1122g
 
Y - Recursion The Hard Way GopherCon EU 2025
Y - Recursion The Hard Way GopherCon EU 2025
Eleanor McHugh
 
arctitecture application system design os dsa
arctitecture application system design os dsa
za241967
 
Shell Skill Tree - LabEx Certification (LabEx)
Shell Skill Tree - LabEx Certification (LabEx)
VICTOR MAESTRE RAMIREZ
 
IObit Driver Booster Pro 12 Crack Latest Version Download
IObit Driver Booster Pro 12 Crack Latest Version Download
pcprocore
 

Using FireMonkey as a game engine

  • 1. Sponsored by Using FireMonkey as a game engine Patrick Prémartin DELPHICON 2021 The Official Online Conference All About Embarcadero Delphi delphicon.embarcadero.com
  • 2. Sponsored by Agenda ● What is a game engine ? ● What is FireMonkey ? ● Why using FireMonkey to code games ? ● Really ? Games in Delphi FMX ? ● Managing music and sound effects ● Managing backgrounds and scenes ● Managing user interface ● Managing sprites, animations and collisions ● What about 3D ? ● You want more ?
  • 3. Sponsored by Speaker ● Patrick Prémartin - MVP Embarcadero ● Freelance Delphi and web developer since 2000 (just after the bug) ● Delphi user since the beginning and before with Borland / Turbo Pascal. ● Game coder since a little more (TO7-70 J)
  • 4. Sponsored by Speaker ● Patrick Prémartin - MVP Embarcadero ● Follow me on : ● GitHub : https://github.com/DeveloppeurPascal ● Itch.io : https://gamolf.itch.io ● Twitch : https://www.twitch.tv/patrickpremartin ● My blog : https://developpeur-pascal.fr ● LinkedIn : https://www.linkedin.com/in/patrickpremartin/
  • 5. Sponsored by What is a game engine ? ● A game engine is a library or set of components available to create games. ● You have code, SDK and sometimes editor tools or you can use external tools like Tiled to create your scenes and maps. ● A game engine is not a complete game making software like you have with GameMaker Studio, AppGameKit Studio, Game Guru, Clickteam Fusion, Unreal Engine or Unity but the code to work with when creating games.
  • 6. Sponsored by What is a game engine ? ● There are a lot of game making software and game engines coded in Pascal. ● One of the most known is Castle Game Engine available at https://castle-engine.io/ It now has Delphi compatibility. Look at Michalis Kamburelis DelphiCon 2021 session to know more about it. https://delphicon.embarcadero.com/talks/castle-game-engine- coming-to-delphi/
  • 7. Sponsored by What is a game engine ? ● You perhaps eared about some of this other game engines for Delphi or Pascal developers : ○ Gorilla 3D Framework : https://www.gorilla3d.de ○ Apus Game Engine : https://github.com/Cooler2/ApusGameEngine ○ SDL2 for Pascal : https://github.com/PascalGameDevelopment/SDL2-for- Pascal ○ Andorra 2D, Turbu, Asphyre, DelphiX, Rage3D, and a lot more listed at https://wiki.freepascal.org/Game_Engine
  • 8. Sponsored by What is FireMonkey ? ● FireMonkey is the multiplatform set of components and libraries available in Delphi. ● You have VCL for Windows projects since Delphi 1. ● And since Delphi XE2 we have FireMonkey for all major platforms. ● With Delphi 11 Alexandria you can target Windows, Mac, Linux, iOS and Android platforms depending on your license level.
  • 9. Sponsored by What is FireMonkey ? ● The idea behind FireMonkey is to have one project and one source code to target all major platforms. ● You don’t need to know “platforms languages” like Objective-C, Swift, Java, Kotlin, C, C++, C#, .Net, …
  • 10. Sponsored by What is FireMonkey ? ● FireMonkey includes classic visual components but also shapes, animations, visual effects, 3D, access to system API and other libraries. ● It’s included in all Delphi license level even the Community Edition (free for personal use) and Academic Edition.
  • 11. Sponsored by Why using FireMonkey to code games ? ● The simple answer could be “why not ?” and in fact it’s the first reason I had to play with it. ● Second answer is more technical : ● FireMonkey draws everything on screen by default. ● Visual components are sets of shapes and effects. They are styled and can be changed without coding. ● We have 2D and 3D components and layers in standard.
  • 12. Sponsored by Why using FireMonkey to code games ? ● The simple answer could be “why not ?” and in fact it’s the first reason I had to play with it. ● Second answer is more technical : ● Touch, mouse and keyboard are managed by Delphi. It works for classic programs, so it works for games too. ● We can use properties and events, timers and threads, multi resolution images and bitmaps, classes and all thinks needed to code games.
  • 13. Sponsored by Really ? Games in Delphi FMX ? ● In 2021 I streamed weekly game coding sessions on Twitch, with Delphi and FireMonkey. ● Published games are available at https://gamolf.itch.io ● Some projects have been open sourced on my GitHub account: https://github.com/DeveloppeurPascal/DevPas-Games-Pack ● A lots of other projects are available with “delphi-game” hashtag: https://github.com/topics/delphi-game
  • 14. Sponsored by Really ? Games in Delphi FMX ? ● You can also check the showcase part of Embarcadero blogs at https://blogs.embarcadero.com/category/showcase/ ● And more on iOS and Android stores ! ● Simply look at the list of games which developers forgot to change default package name in their project options : https://www.google.com/search?q=%22com.embarcadero.%22 +game+site%3Aplay.google.com Please don’t forget to personalize your project version info option page.
  • 15. Sponsored by How to ? ● Know, let’s look a little more at developer side of game making with FireMonkey projects in Delphi. ● You’ll find code samples and usable Delphi units on GitHub at https://github.com/DeveloppeurPascal/DelphiFMXGameSnippe ts
  • 16. Sponsored by Managing music and sound effects ● Managing sounds in a Delphi project is simple. We have a component for that : TMediaPlayer. ● In my games I use it to play MP3 music in background. A timer check if the music is over and restart it for a loop. ● For sound effects, I play WAV files with another TMediaPlayer (or more than one in a TObjectList<TMediaPlayer> depending on the game). ● To do the same, use the TMusicLoop class in uMusicLoop.pas
  • 17. Sponsored by Managing backgrounds and scenes ● For backgrounds and scenes, I use TImage component, the Fill property of shapes like TRectangle or TCircle and the TPath to draw SVG path depending on my needs. ● All FireMonkey visual components are containers. They can be parents for all other visual components. ● All visual components have opacity, rotation and scale properties.
  • 18. Sponsored by Managing backgrounds and scenes ● We can use nonvisual components to change property values in a specific duration (TFloatAnimation is very useful). ● We have visual effect as nonvisual components like TShadowEffect and TGlowEffect, useful for games and classic programs to show errors or needed edit fields. ● It give us unlimited possibilities without coding anything… and of course we can code !
  • 19. Sponsored by Managing backgrounds and scenes ● For Egg Hunter project, available at https://gamolf.itch.io/egg- hunter, I needed to manage sprites positions and actions in different threads. ● I wanted 60 FPS (because we need goals in life). ● I didn’t check if I succeeded but the result is good enough in term of user experience.
  • 20. Sponsored by Managing backgrounds and scenes ● My scene is a TImage. I never draw on it. ● I use a TBitmap in background as a buffer. It’s only refreshed depending on the viewport position and sprite actions. ● A timer checks every 16ms if I changed the buffer bitmap. If so, I copy it to the scene image. ● It’s simple. Just need some Booleans and TMutex to avoid access violations, conflicts and sprites flipping.
  • 21. Sponsored by Managing backgrounds and scenes ● In other games, I simply use TLayout on a TForm to simulate a Z-Index if needed. ● You have a sample at https://github.com/DeveloppeurPascal/DelphiFMXGameSnippe ts/tree/main/AnimationVaguesEtCanards ● I used it for Ok Ducky ! game available at https://gamolf.itch.io/ok-ducky
  • 22. Sponsored by Managing user interface ● User interface is simple : I can use styled visual components, shapes, images, … ● For texts I user TLabel if I want the look and feel of the OS or TText when I prefer to change color, size and font in my program. ● For buttons I use TButton, a personalized button style or I “draw” them in a TFrame with TRectangle, images, effects and texts.
  • 23. Sponsored by Managing user interface ● Have a look at this 2018 CodeRage replay to see how I proceed : https://serialstreameur.fr/coderage2018-christmasgame- codereview.php ● This project source code is available on GitHub : https://github.com/DeveloppeurPascal/CodeRage2018- ChristmasGame
  • 24. Sponsored by Managing sprites, animations and collisions ● For sprites I use the bitmap kind of Fill property from TRectangle or TCircle components. ● For other visual elements I use TImage with a TImageList or the background (Fill.Bitmap) of other shapes.
  • 25. Sponsored by Managing sprites, animations and collisions ● Animating is easy : FireMonkey give us a TBitmapListAnimation component which accepts a sprite sheet. ● Look this samples : https://github.com/DeveloppeurPascal/DelphiFMXGameSnippe ts/tree/main/AnimSpriteExplosion and https://github.com/DeveloppeurPascal/DelphiFMXGameSnippe ts/tree/main/AnimSpritePersonnage
  • 26. Sponsored by Managing sprites, animations and collisions ● To check collisions, I use what Delphi use for the visual components and testing mouse clicks. ● IntersectRect() is a very useful (too unknown) method to check if two rectangles collide. ● It’s standard. It works since more than 26 years in the VCL and now in FMX. Why not using it ?
  • 27. Sponsored by Managing sprites, animations and collisions ● For circles I calculate the distance between center of each circle and compare it to the sum of their radius. ● You have a sample with Soap Bubbles game available at https://gamolf.itch.io/soap-bubbles ● The base code for this game is available on GitHub : https://github.com/DeveloppeurPascal/DelphiFMXGameSnippe ts/tree/main/JeuDesCercles
  • 28. Sponsored by Managing sprites, animations and collisions ● For circle versus a rectangle, I calculate the distance between the circle center and each angle of the rectangle. ● The classic sample for this is a Pong or Breakout game, when the ball hits a wall or a brick. ● You have the source code of a sample breakout done for Learn To Code Summer Camp 2021 event at https://github.com/DeveloppeurPascal/Casse-Briques
  • 29. Sponsored by What about 3D ? ● 3D is little more complicated, but FireMonkey includes 3D viewport and 3D shapes. ● You can use them to create games like did Grégory Bersegeay, another French Embarcadero MVP, for ○ 3D Pong : a pong game in 3D. https://github.com/gbegreg/FMXPong ○ FMX Corridor : a The Light Corridor remake. https://github.com/gbegreg/FMXCorridor ○ FMX Island : an island in 3D, base for FPS games. https://github.com/gbegreg/FMXISland
  • 30. Sponsored by You want more ? ● Did I say it’s simple to use Delphi and FireMonkey for game coding and deploying them for Windows, Mac, Linux, iOS and Android devices ? ● With those samples and links, I hope you have all what you need to understand how to use FireMonkey as a game engine in your games. ● If not, contact me and tell me what is missing or submit new feature requests directly in Embarcadero’s Quality Portal.
  • 32. Sponsored by Q&A ● Sorry, I’m not live for Q&A during DelphiCon 2021 but if you want to talk, leave me a message on LinkedIn or at https://developpeur-pascal.fr/contact/ ● You also can talk with me on Twitch during a live (game or other) coding stream at https://www.twitch.tv/patrickpremartin ● Please write in French or English. Use https://www.deepl.com/translator tool to translate if needed.