Slides from my lecture at Pascal Cafe 2024 conference about mobile app development using Castle Game Engine.
See https://castle-engine.io/ for more information about CGE. See the accompanying example project on https://github.com/castle-engine/conference-pascalcafe2024 .
5. Castle Game Engine
● 3D and 2D
● Editor
● Pascal API (all that you can do in editor + much more)
○ For your games and for engine
○ FPC (all platforms) and Delphi (Windows, Linux)
● Open-source
○ Want to fork to add a project-specific feature? OK.
● Multi-platform
○ Windows, Linux (Raspberry Pi too), FreeBSD, macOS
○ Android, iOS
○ Nintendo Switch
6. 3D FPS game template
● Views
● Play view
○ Viewport, navigate in 3D
○ Left side: hierarchy with components
■ UI
■ viewport is also UI
■ 3D: transform scenes, cameras, lights
■ drag-and-drop 3D models, images
■ transform, delete, duplicate
■ behaviors attach to transforms, like billboard
○ Right side: properties
○ Bottom: files
■ preview
■ special data directory
■ double click to run view3dscene on scenes
10. Run on mobile
Just switch "Run -> Platform (...)" to "Android".
Assuming you have Android SDK and FPC cross-compilers, see https://castle-engine.io/android .
21. But some differences cannot be "hidden" by
engine
● When touching, user cannot move position without pressing
● Touching has less precision
○ (smaller physical devices (phones), your finger, you don't see the
cursor)
● Multi-touch possible in exchange: touch screens can track each finger
press independently.
22. Multi-touch API
● Press, Motion and other events have "FingerIndex"
● Observe current touches from any place (like Update):
○ Container.Touches[FingerIndex: Integer]: TTouch
○ Container.TouchesCount: Integer
28. UI scaling - scale UI to some imaginary size
● The coordinates you specify are in floats, and follow "scaled coordinates".
● The "scaled coordinates" by default pretend that you have a screen 1600 x 900,
○ but adjusted (larger in one dimension) to keep aspect ratio.
○ Of course this is configurable, https://castle-engine.io/manual_castle_settings.php
30. UI Scaling - result
● Sizes and positions are scaled, so designing them on 1 screen will work on
another.
● You can just use hardcoded numbers for sizes and positions.
○ They will work (be scaled).
● Use anchors to keep things aligned to proper border/center.
● Your application works on all screen sizes --
○ various Androids, iOS, desktops…
34. How are Android / iOS projects build
● FPC compiles your application to a library (so or a).
● We glue it with larger code that defines an Android or Xcode iOS project.
● So we can really use 100% of native platform capabilities.
● "Services" are pieces of code basically added to the native project,
○ that expose some native platform API (like vibrations).
○ They usually enable to control it from Pascal code
○ (you can use your own, e.g. JNI, or use our ready CastleMessaging -- good for
cases when communication is naturally asynchronous, like for all services that
do something over the network).
● See https://castle-engine.io/android_services
38. More services
https://castle-engine.io/android_services
● Various Ad frameworks
● Analytics
● In-app purchases https://castle-engine.io/in_app_purchases
● Networking (downloading URLs, TCP/IP client/server)
● Google Play Games (Achievements, Leaderboards)
● Vibrate
● Photo storage
● TestFairy (distribution, remote logging)
● More planned (GPS, maps, AR…)
39. iOS is as easy as Android, you just
need mac machine
40. iOS
If you have a mac machine, follow https://castle-engine.io/ios to get some dependencies:
● Xcode with cli tools
● FPC cross-compilers
and you can build iOS (iPhone, iPad) applications with equal ease as Android.
CGE can prepare
● Xcode project (that you can later deploy in any way from Xcode)
● or create ready archive like IPA (that you can distribute e.g. using TestFairy)
iOS services are available as well https://castle-engine.io/ios_services
43. Plans
● 7.0-alpha3 release next week
○ Ton of stuff:
https://castle-engine.io/new_features_in_castle_game_engine_7.0
● 7.0 release this year:
○ Material components (shaders, mirrors, easier)
○ Steam (for your games, but also for editor!)
● 7.2 (hopefully this Christmas):
○ Web platform (target, but also source!)
● More: https://castle-engine.io/roadmap
44. How to make this sustainable?
● We're a community of Pascal developers who are enthusiastic about open-source, games,
and Pascal.
● Engine is all free and open-source.
○ But we can sponsor open-source work (Andrzej Kilijański, Eugene Loza).
○ We also did commercial games (CAG, https://unholy-society.com/ ).
● Support us:
https://www.patreon.com/castleengine
● Want to work together, b2b contract?
michalis@castle-engine.io