2. Defold Environment Setup & Configuration
# 2. Defold Environment Setup & Configuration
Before diving into platformer game development, we need to set up our Defold environment properly. This section covers the essential steps to get your development environment ready for creating platformer games.
## 2.1 Installing Defold
Defold is a free, cross-platform game engine that's perfect for 2D platformers. Follow these steps to install it:
1. Visit the official Defold website at [defold.com](https://defold.com/)
2. Click the "Get Defold" or "Download" button
3. Choose the version appropriate for your operating system (Windows, macOS, or Linux)
4. Run the installer and follow the on-screen instructions
## 2.2 Defold Editor Overview
Once installed, the Defold editor will look something like this:
```mermaid
graph TD
A[Defold Editor] --> B[Project Explorer]
A --> C[Properties Panel]
A --> D[Scene Editor]
A --> E[Console/Log]
A --> F[Outline]
A --> G[Assets Browser]
```
Key areas of the interface:
- **Project Explorer**: Navigate through your project files
- **Properties Panel**: Edit properties of selected objects
- **Scene Editor**: Visual editor for game scenes
- **Console/Log**: View debug information and errors
- **Outline**: Hierarchical view of scene objects
- **Assets Browser**: Browse and manage project assets
## 2.3 Creating a New Project
To create a new platformer project:
1. Open Defold
2. Select "New Project" from the dashboard
3. Choose the "Empty Project" template
4. Name your project (e.g., "MyPlatformer")
5. Select a location to save your project
6. Click "Create New Project"
## 2.4 Project Structure
A typical Defold platformer project structure looks like this:
```
my_platformer/
├── main/
│ ├── main.collection
│ ├── main.script
│ └── game.atlas
├── player/
│ ├── player.go
│ ├── player.script
│ └── animations/
├── levels/
│ ├── level1.collection
│ ├── level2.collection
│ └── common/
├── enemies/
├── ui/
├── assets/
│ ├── images/
│ ├── sounds/
│ └── fonts/
├── game.project
└── input/
└── game.input_binding
```
## 2.5 Configuring Game Settings
The `game.project` file contains all the project settings. Important settings to configure include:
1. **Display settings**: Resolution, frame rate, and orientation
```
[display]
width = 1280
height = 720
high_dpi = 1
```
2. **Physics settings**: For platformer collision detection
```
[physics]
scale = 0.02
debug = 0
gravity_y = -1000
```
3. **Input settings**: For controller and keyboard configuration
```
[input]
game_binding = /input/game.input_binding
```
## 2.6 Setting Up Version Control
It's highly recommended to use version control for your project:
```mermaid
gitGraph:
commit id: "Initial setup"
branch development
checkout development
commit id: "Player movement"
commit id: "Level design"
checkout main
merge development
commit id: "v0.1 release"
```
1. Initialize Git in your project folder
```bash
git init
```
2. Create a `.gitignore` file with Defold-specific entries
```
# Defold
.internal
build
.externalToolBuilders
.DS_Store
Thumbs.db
```
3. Make your initial commit
```bash
git add .
git commit -m "Initial project setup"
```
## 2.7 Essential Extensions
Defold has several extensions that are useful for platformer development:
1. **Defold-INI**: For configuration files
2. **Orthographic Camera**: For better 2D camera control
3. **Defold Tiled**: For importing Tiled map editor files
To install an extension:
1. Right-click in the Project Explorer
2. Select "Add Library"
3. Enter the extension URL (e.g., `https://github.com/defold/extension-camera`)
4. Click "Add Library"
## 2.8 Performance Settings
For optimal platformer performance, consider these settings:
```
[graphics]
default_texture_min_filter = nearest
default_texture_mag_filter = nearest
[resource]
max_resources = 1024
```
The texture filter settings are particularly important for pixel art platformers to maintain crisp visuals.
## 2.9 Testing Environment Setup
Set up a testing framework for your platformer:
1. Create a debug overlay
```lua
-- debug.script
function init(self)
self.debug_enabled = true
self.fps_text = gui.get_node("fps_text")
end
function update(self, dt)
if self.debug_enabled then
local fps = 1/dt
gui.set_text(self.fps_text, string.format("FPS: %.1f", fps))
end
end
```
2. Configure hot reloading for faster development
```
[project]
title = My Platformer
version = 0.1
dependencies#0 = https://github.com/defold/extension-hot-reload/archive/master.zip
```
## 2.10 Next Steps
With your environment set up, you're ready to begin creating your platformer. In the next section, we'll cover the fundamentals of platformer physics and movement mechanics.