Question: What Game Engine Does Terraria Use?
Answer
Terraria, the popular 2D sandbox adventure game developed by Re-Logic, was originally created using Microsoft's XNA framework. However, with the discontinuation of XNA, the developers later migrated to the FNA framework, which is a reimplementation of the XNA framework that is open-source and can be used for cross-platform development.
To further understand the transition, it's important to note that Terraria's gameplay involves exploration, crafting, building, and combat with a variety of creatures in a procedurally generated 2D world. The choice of game engine or framework impacts how these features are implemented and how well they perform on various platforms.
Here is a simplified example to illustrate how one might use FNA to create a basic game structure similar to what could be found in Terraria, highlighting the initialization of the game window and game loop:
using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Input; public class Game1 : Game { GraphicsDeviceManager graphics; SpriteBatch spriteBatch; public Game1() { graphics = new GraphicsDeviceManager(this); Content.RootDirectory = "Content"; // Set your window size or make it full screen graphics.PreferredBackBufferWidth = 800; graphics.PreferredBackBufferHeight = 480; // other initialization code here... } protected override void Initialize() { // TODO: Add your initialization logic here base.Initialize(); } protected override void LoadContent() { spriteBatch = new SpriteBatch(GraphicsDevice); // TODO: use this.Content to load your game content here } protected override void Update(GameTime gameTime) { if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape)) Exit(); // TODO: Add your update logic here base.Update(gameTime); } protected override void Draw(GameTime gameTime) { GraphicsDevice.Clear(Color.CornflowerBlue); // TODO: Add your drawing code here base.Draw(gameTime); } }
When starting the game development process, you would expand upon this structure by adding more classes and methods to control game objects, handle physics, manage user input, and render graphics. It's worth noting that while this example is somewhat representative of how a game like Terraria might begin in terms of structure, Terraria itself is a much more complex product with additional considerations for content loading, world generation, multiplayer support, and so forth.
While Terraria is not an open-source game and its actual source code is not publicly available, indie developers often look at frameworks like FNA when developing games with similar ambitions on a technical level.
Was this content helpful?
Other Common Game Dev Questions (and Answers)
- Can I Use an SQL Database for Game Development?
- How are databases used in game development?
- How do you save multiplayer game data, in a database or a file?
- How can you design an efficient database for a game?
- Should I Use Redis or MySQL for Game Development?
- Do Video Games Use Databases?
- Does game development require knowledge of mathematics?
- Should I Use a Game Engine or Not?
- Do you need a game engine to make a game?
- What are the differences between Azure PlayFab and AWS GameLift?
- How can you set up matchmaking using AWS GameLift?
- How can Redis be used for a game server?
Free System Design on AWS E-Book
Download this early release of O'Reilly's latest cloud infrastructure e-book: System Design on AWS.
Switch & save up to 80%
Dragonfly is fully compatible with the Redis ecosystem and requires no code changes to implement. Instantly experience up to a 25X boost in performance and 80% reduction in cost