Tutorials · Crypt Knight · Chapter 2
A wide window
By the end
- A project called
crypt-knight, and a window file that opens its game 1280 by 720 - A scene called
Gate, with a camera in it - A Letterbox camera, which shows exactly 320 by 180 world units, draws every one of them as a 4 by 4 block of the window, and puts bars wherever the window is another shape
- The scene the project opens on, and the game running in Play and in a window of its own
On this page
Make the project
Crypt Knight starts as an empty project, and everything in this tutorial happens in it: the scenes you build, the scripts you write and the pictures you copy in.
- Open Rengy and press New project… on its launcher.
- In the folder dialog, make a new folder called
crypt-knight, open it, and choose it. The project takes its name from the folder. - The editor opens the project on an empty room. In Assets, right-click
mover.rgs, the starter script, and choose Delete: Crypt Knight writes its own.
The name matters later. The game you export at the end of the tutorial is named after this folder, so call it crypt-knight exactly.
A wide window
The game plays in a window 1280 pixels wide and 720 high, the shape of a widescreen. The window’s size is a project setting.
- Choose File → Project settings… and open its Window tab.
- Set Title to
Crypt Knightand Size to1280and720, leaving Mode on Windowed, and Borderless and Always on top unticked. - Press Save. The tab writes
window.roninto the project as you make each change, and Save writes it again.
The window is what an exported game and Run game open. The editor’s own Play stays inside the editor, in the Viewport.
- Close the window with the × at the right of its title bar: it floats over the Viewport.
The scene, and its root
A scene is a tree of nodes, and each node carries components: a picture, a camera, a script. The first level of the game is one scene, and it is called the Gate, so its root node is. Scenes and nodes has the whole model.
- In the Hierarchy, press + Add node and choose Node. With nothing selected it lands as a root, as the menu’s Add as root says.
- Rename it
Gate: press F2, type the name, and press Enter. - Press Ctrl+S.
- In the save dialog, make a folder called
scenes, open it, and save the scene asgate.ron.
Save often. Run game and an exported game read each scene from its file, as you last saved it.
A camera that shows 320 by 180
The game is drawn through a node carrying a Camera, which decides how much of the world the window shows. Crypt Knight is pixel art, and the art is small: the knight is 48 pixels tall, and the castle’s tiles are 16 by 16. So the camera shows only 320 world units across and 180 down, and the window stretches that to its own 1280 by 720, four times as big. Every pixel of the art becomes a 4 by 4 block of the screen, and the art stays crisp.
- Select
Gate, press + Add node, choose Camera, and rename itcamera. The menu says Add child of Gate, so it lands underGate. - Set its Position to
160and128. The Gate you paint in chapter 4 starts at the world’s left edge, x0, with its floor near y160, and this puts the view over its left end: 320 across from0, and 180 down from y38. - In its Camera, set Scaling to Letterbox, Extent to
180and Width to320. - Leave Zoom at
1and Pixel Snap ticked. Pixel Snap keeps the view on whole pixels of the art, so the picture does not shimmer when the camera moves. - Click Background, and press U8 at the top left of the picker that opens, so it reads F: the picker then shows each value from 0 to 1, as this tutorial gives every colour, until you close the editor.
- Make it a dark blue-grey:
0.04,0.05,0.08, alpha1.
- Letterbox
- Shows exactly Width by Extent world units, as large as the window allows, and fills the rest of the window with Background. A window of any other shape gets bars, at its sides or above and below, and the view keeps its shape.
- Extent and Width
- The view’s height and width, in world units. A world unit is a pixel of the art, so 320 by 180 is exactly a quarter of the window each way: about 20 of the castle’s 16-pixel tiles across, and 11 down.
The world’s y grows downward, as it does on a screen. The camera’s centre is the node’s position, so the view’s left edge is at x 0 and its right at 320, its top at y 38 and its bottom at 218.
The scene the game opens on
A project opens one scene first: the one Run game and an exported game start on.
- Choose File → Project settings… again, and open its General tab.
- Set Startup scene to
scenes/gate.ron. The tab writes it intoproject.rengyas you choose it.
Right-clicking a scene in Assets and choosing Set as startup scene does the same.
- Close the window again.
Check it works