Godot Experiments
Some experiments using the Godot game engine.
Note: In 2023-06 I upgraded these to Godot 4; if you want to look at the
Godot 3 versions, grab the godot-3 tag.
These are ports of my PyGame experiments (which started as ports of my Löve experiments for now), we'll see where this goes.
- Experiment 01 - Scrolling Texture
- Experiment 02 - Monospaced Text
- Experiment 03 - Variable Text
- Experiment 04 - Text Entry
- Experiment 05 - Image Fade
- Experiment 06 - UI Dialog
- Experiment 07 - Animiated Icon
- Experiment 08 - Styled Text
- Experiment 09 - UI Button
- Experiment 10 - UI Spinbox
- Experiment 11 - Tilemap
- Experiment 12 - Tilemap Minimap
- Experiment 13 - Fade
- Experiment 14 - Animated Sprite
- Experiment 15 - Drop shadow text
- Experiment 18 - Tilemap Layers
- Experiment 19 - Lighting
- Experiment 20 - LPC Sprite
- Experiment 21 - Blocked Sprite
Experiment 16 and 17 were joystick demos of Experiment 14; if I remember correctly, joysticks already worked with Experiment 14 et al. so I removed them as they didn't add anything.
Bribe me
Want to bribe me to work on more experiments, faster? Want to suggest an experiment?
Always willing to entertain suggestions, but if you're asking me to do some
work, you have the option of fuelling it with coffee. ;-)
Credits
These use the Godot Engine.
License
Stuff I wrote is released under the MIT license, and any resources are covered by their respective licenses (please see individual experiment write up for details). I'm only using open source and freely usable third-party bits, but they might not be using MIT's license.
Experiment 01 - Scrolling Texture
Old games used a technique to animate textures where they shifted the sprite one row or column per frame. An easy/cheesy way to do this is to just produce a set of sprites that are shifted already and treat them as individual frames.
I want to see if there's a way to do it without duplicating and modifying the sprite. I'm thinking that ancient platforms (think Commodore C=64 or Apple ][) wouldn't have the memory to waste for this sort of thing.
The goal is to do this with one draw call, by adjusting the texture.
This is actually more complex in Godot than in PyGame or Löve2D; we have to write a shader! Thank you Internet for answering this question.
Experiment 01 - Scrolling Texture (Almost No Code)
This variant of Experiment 1 accomplishes the same thing with two major differences:
- almost no code (literally one line to set the animation when the scrolling sprite is ready)
- scrolling the texture using the texture Region rather than a shader; when I first did Experiment 1 I didn't know about Region
Graphics
character_robot_jump.png- From Kenney.nl's freely usable Toon Characters 1 collection.
Experiment 2 - Monospaced Text
This is an attempt to create a simple text/console type of window. Print text to it, render it, and scroll up when you reach the bottom. Think of the text area in the bottom-right of the Ultima V, for example.
We'll make an area that can display five lines of 20 characters each. It automatically wraps lines that are too long, and there's a rectangle around the text area so you can be sure it's not over-drawing.
Graphics
LiberationMono-Bold.ttf- An open source font from the liberationfonts repo; this is licensed under the SIL Open Font License.
Experiment 3 - Variable Width Text
This is the same as Experiment 2, but with a variable-width font. This is trivial in Godot.
Graphics
LiberationSerif-Bold.ttf- An open source font from the liberationfonts repo; this is licensed under the SIL Open Font License.
Experiment 4 - Text Entry
This is an attempt to turn Experiment 2 into a simple text entry box. Whatever you type will be printed in the text area.
We'll make an area that can display five lines of 20 characters each. There's a rectangle around the text area so you can be sure it's not over-drawing.
This is trivial with Godot, just use a TextEntry object.
Graphics
LiberationMono-Bold.ttf- An open source font from the liberationfonts repo; this is licensed under the SIL Open Font License.
Experiment 5 - Image Fade
In this experiment, we'll fade an image from black to fully-drawn.
Graphics
character_robot_jump.png- From Kenney.nl's freely usable Toon Characters 1 collection.
Experiment 6 - UI Dialog
In this experiment, we'll draw a dialog box with some text in it and a character portrait.
Graphics
HONK.png- The Goose from House House's amazing Untitled Goose Game, used without permission. I'm not affiliated with House House in any way, other than as a happy customer. You should buy Untitled Goose Game, it's amazingly fun. I have it on my Switch!rpg_gui_v1- RPG GUI construction kit v1.0 by Lamoot on OpenGameArt.org. I had to create a 9-patch image of the parts I wanted to use because I couldn't figure out how to use arbitrary texture hunks for it in Godot.
Font:
LiberationSerif-Bold.ttf- An open source font from the liberationfonts repo; this is licensed under the SIL Open Font License.
Experiment 7 - Animated Icon
In this experiment, we'll draw an animated icon.
This is trivial in Godot thanks to the AnimiatedSprite object.
Graphics
character_robot_sheet.png- From Kenney.nl's freely usable Toon Characters 1 collection.
Experiment 8 - Styled Text
This is an attempt to create a simple text window that supports some text styling (multiple fonts and colours). Print text to it, render it, and scroll up when you reach the bottom.
Graphics
LiberationMono-Bold.ttfandLiberationSerif-Bold.ttf- Open source fonts from the liberationfonts repo; this is licensed under the SIL Open Font License.
Experiment 9 - UI Button
In this experiment, we'll draw a button with some text in it. It'll respond to the mouse hovering over it, and clicks.
Graphics
rpg_gui_v1- RPG GUI construction kit v1.0 by Lamoot on OpenGameArt.org.
Font:
LiberationSerif-Bold.ttf- An open source font from the liberationfonts repo; this is licensed under the SIL Open Font License.
Experiment 10 - UI Spinbox
In this experiment, we'll draw a spinbox with some text in it. It'll respond
to the mouse hovering over it, and clicks, switching between a set of values.
Graphics
uipack- Kenney.nl's UI Pack.
Font:
LiberationSerif-Bold.ttf- An open source font from the liberationfonts repo; this is licensed under the SIL Open Font License.
Experiment 11 - Tilemap
In this experiment, we'll draw a viewport onto a tilemap that was created in Tiled. Use the arrow keys or WASD to move the viewport around the map.
Graphics
LiberationSerif-Bold.ttf- An open source font from the liberationfonts repo; this is licensed under the SIL Open Font License.terrain-map-v7.png- LPC Terrains from OpenGameArt:
"[LPC] Terrains" by bluecarrot16, Lanea Zimmerman (Sharm), Daniel Eddeland (Daneeklu), Richard Kettering (Jetrel), Zachariah Husiar (Zabin), Hyptosis, Casper Nilsson, Buko Studios, Nushio, ZaPaper, billknye, William Thompson, caeles, Redshrike, Bertram, and Rayane Félix (RayaneFLX). See
CREDITS-terrain.txt. You MUST credit all authors with the information in this file, and you must link back to this page on OpenGameArt.
Experiment 12 - Minimap Tilemap
In this experiment, we'll draw a viewport onto a tilemap that was created in Tiled. Use the arrow keys or WASD to move the viewport around the map. This version adds a minimap that follows the viewport.
Graphics
LiberationSerif-Bold.ttf- An open source font from the liberationfonts repo; this is licensed under the SIL Open Font License.terrain-map-v7.png- LPC Terrains from OpenGameArt:
"[LPC] Terrains" by bluecarrot16, Lanea Zimmerman (Sharm), Daniel Eddeland (Daneeklu), Richard Kettering (Jetrel), Zachariah Husiar (Zabin), Hyptosis, Casper Nilsson, Buko Studios, Nushio, ZaPaper, billknye, William Thompson, caeles, Redshrike, Bertram, and Rayane Félix (RayaneFLX). See
CREDITS-terrain.txt. You MUST credit all authors with the information in this file, and you must link back to this page on OpenGameArt.
Experiment 13 - Rect Fades
In this experiment, we'll try to fade in/out on an image by drawing over it with masking rectangles.
Graphics
fox n girl shadows.pngby zonked on OpenGameArt; resized and cropped to fit the window I'm using.
Experiment 14 - Animated Sprite
Note: Input doesn't seem to work, will need to fix. 🤷
In this experiment, we'll animate one of the Liberated Pixel Cup sprites (OpenGameArt's mascot, Sara). Use WASD or arrow keys to walk around.
Graphics
grass.png- A grass tile, by Invincible.LiberationMono-Bold.ttf- An open source font from the liberationfonts repo; this is licensed under the SIL Open Font License.LPC_Sara- Stephen "Redshrike" Challener as graphic artist and William.Thompsonj as contributor. Mandi Paugh is the original artist of Sara and creator of the OGA mascot.
LPC sprite sheet documentation:
- Each row is a complete animation cycle.
- Rows are mostly in groups of four based on facing: away, left, forward, right.
- Animation rows are: Spellcast, Thrust, Walk, Slash, Shoot, Hurt (only one facing for Hurt).
- Are 64x64 on the sprite sheet.
Experiment 15 - Text Dropshadows
This experiment draws text with different dropshadows, so we can see how to make our white text more readable on a light coloured background.
Graphics
grass.png- A grass tile, by Invincible.LiberationMono-Bold.ttfandLiberationSerif-Bold.ttf- An open source font from the liberationfonts repo; this is licensed under the SIL Open Font License.
Experiment 16 - Joystick
I'm skipping implementing this one because Godot handles joysticks transparently through the input mapping support. Both Löve2D and PyGame provide extremely low-level access to the gamepad data and it's up to you to map the raw numbers into something useful.
Experiment 17 - Sprite Joystick
Similarly, I'm skipping Experiment 17, because it's just Experiment 14 with joystick support for movement. Through the magic of Godot's input mapping, Experiment 14 already supports gamepad control.
Experiment 18 - Tilemap Layers
In this experiment, we'll draw a viewport onto a tilemap that was created in Tiled. Use the arrow keys or WASD to move the viewport around the map. This expands on Experiment 11 by working with a map that has several layers.
Note: This is trivial, Tiled's export to Godot 4 supports layers directly.
Graphics
LiberationSerif-Bold.ttf- An open source font from the liberationfonts repo; this is licensed under the SIL Open Font License.terrain-map-v7.png- LPC Terrains from OpenGameArt:
"[LPC] Terrains" by bluecarrot16, Lanea Zimmerman (Sharm), Daniel Eddeland (Daneeklu), Richard Kettering (Jetrel), Zachariah Husiar (Zabin), Hyptosis, Casper Nilsson, Buko Studios, Nushio, ZaPaper, billknye, William Thompson, caeles, Redshrike, Bertram, and Rayane Félix (RayaneFLX). See
CREDITS-terrain.txt. You MUST credit all authors with the information in this file, and you must link back to this page on OpenGameArt.
Experiment 19 - Simple Lights
Note: Input doesn't seem to work? 🤷
In this experiment, we'll take experiment 14 - Animated Sprite and add some simple lighting.
This uses Godot's 2D lighting rather than the blocky shadows of the original demo.
Graphics
grass.png- A grass tile, by Invincible.LiberationMono-Bold.ttf- An open source font from the liberationfonts repo; this is licensed under the SIL Open Font License.light.pngis from Godot's 2D Lights and Shadows demo.LPC_Sara- Stephen "Redshrike" Challener as graphic artist and William.Thompsonj as contributor. Mandi Paugh is the original artist of Sara and creator of the OGA mascot.
Experiment 20 - LPC Sprite
Note: You can switch animations, but can't move or change facing... I'll have to fix that.
In this experiment, we'll take the LPC Sara animation from experiment 14 and let you cycle through the different animations in the spritesheet. Use WASD or arrow keys to walk around and Space to cycle to the next animation.
Graphics
grass.png- A grass tile, by Invincible.LiberationMono-Bold.ttf- An open source font from the liberationfonts repo; this is licensed under the SIL Open Font License.LPC_Sara- Stephen "Redshrike" Challener as graphic artist and William.Thompsonj as contributor. Mandi Paugh is the original artist of Sara and creator of the OGA mascot.
LPC sprite sheet documentation:
- Each row is a complete animation cycle.
- Rows are mostly in groups of four based on facing: away, left, forward, right.
- Animation rows are: Spellcast, Thrust, Walk, Slash, Shoot, Hurt (only one facing for Hurt).
- Are 64x64 on the sprite sheet.
Experiment 21 - Blocked Sprite
Note: Another one that doesn't quite work; movement doesn't move.
In this experiment, we'll take experiment 14 - Animated Sprite and add some blocks that restrict movement. I was trying to do this as part of a new lighting Experiment, but it wasn't working, so I decided to simplify a little.
Graphics
col.png- A column, by mold, resized and cropped to 32x32.grass.png- A grass tile, by Invincible.LiberationMono-Bold.ttf- An open source font from the liberationfonts repo; this is licensed under the SIL Open Font License.LPC_Sara- Stephen "Redshrike" Challener as graphic artist and William.Thompsonj as contributor. Mandi Paugh is the original artist of Sara and creator of the OGA mascot.


















