Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: godot dungeon crawler resource #360

Merged
merged 38 commits into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
a329e3c
Scene creation, asset importing, and player idle animation
lillianhidet Sep 8, 2024
872a405
Merge branch 'Tuhura-Tech:main' into 304-godot-dungeon-crawler
lillianhidet Sep 8, 2024
445b207
Player movement
lillianhidet Sep 9, 2024
54dc043
Tilemap setup. and level creation
lillianhidet Sep 9, 2024
46e228a
Collision for tileset
lillianhidet Sep 15, 2024
487fe97
Sprite animation based on movement
lillianhidet Sep 15, 2024
4b1b174
Sprite facing
lillianhidet Sep 15, 2024
dc1d4f8
Weapon scene creation
lillianhidet Sep 20, 2024
cf4a9bf
Finished weapon, first half of health system
lillianhidet Oct 2, 2024
ef4ee7e
Merge branch 'main' into 304-godot-dungeon-crawler
Darkflame72 Oct 2, 2024
1aafdc3
First Iteration of health system
lillianhidet Oct 3, 2024
0f436c6
Update 2d Dungeon Crawler.mdx
lillianhidet Oct 3, 2024
fd051aa
Merge branch '304-godot-dungeon-crawler' of https://github.com/lillia…
lillianhidet Oct 3, 2024
6df1c54
Fixed failed commit
lillianhidet Oct 3, 2024
ef1c7ff
Merge branch '304-godot-dungeon-crawler' of https://github.com/lillia…
lillianhidet Oct 3, 2024
4759586
Finished Health System
lillianhidet Oct 3, 2024
fe9212d
Coins/Potions
lillianhidet Oct 3, 2024
ef96d56
Enemy Scene
lillianhidet Oct 3, 2024
7380273
Finished Enemy
lillianhidet Oct 3, 2024
73fdeff
Formated files for pages, added image s
lillianhidet Oct 3, 2024
6e0c434
Godot docs links
lillianhidet Oct 4, 2024
7e69e85
Added checkboxes to the end of each page
lillianhidet Oct 4, 2024
4b73dbe
Changed how player death is handled
lillianhidet Oct 4, 2024
d4455dd
Godot 4.3 Tilemaplayer level creation update
lillianhidet Oct 4, 2024
57215b4
Updated level loading to 4.3
lillianhidet Oct 4, 2024
d94e782
Changed order of Godot pages
lillianhidet Oct 4, 2024
70efc89
Merge branch 'main' into 304-godot-dungeon-crawler
lillianhidet Oct 4, 2024
1bf05eb
Spelling pass
lillianhidet Oct 4, 2024
c9c43d4
fix: tutorial nav directories
arimulligan Oct 5, 2024
120aa59
Added steps to pages requiring them
lillianhidet Oct 5, 2024
ae06d90
Merge branch 'main' into 304-godot-dungeon-crawler
lillianhidet Oct 5, 2024
c0c3743
fix: use correct file extension
Darkflame72 Oct 7, 2024
ae28942
Resolves all changes except intro/screenshots
lillianhidet Oct 8, 2024
3495b67
Merge branch '304-godot-dungeon-crawler' of https://github.com/lillia…
lillianhidet Oct 8, 2024
0b7e82f
Added preview + Refactored headings for clarity in tutorial tracker
lillianhidet Oct 8, 2024
4847730
fixed file extension
lillianhidet Oct 10, 2024
d979b04
Merge branch 'main' into 304-godot-dungeon-crawler
lillianhidet Oct 10, 2024
bc3c5a4
Merge branch 'main' into 304-godot-dungeon-crawler
lillianhidet Oct 11, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added src/assets/godot/dungeonCrawler/screenshot.PNG
lillianhidet marked this conversation as resolved.
Show resolved Hide resolved
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,20 @@ This is a guide to making a 2-dimensional dungeon crawling game in [Godot](https
This guide is up-to-date with Godot 4.3 stable official release, and will likely work with any version of Godot newer than 4.3. Due to the use of **TileMapLayers** which were introduced in 4.3, this tutorial isn't compatible with any version pre 4.3
:::

We'll be making a game in which the player explores a multi-floor dungeon in a top-down perspective. This project will include:
- Movement
- Attacking
- Health loss & Gain
- Pickups (Coins & Potions)
- Enemies
## What you'll be making

We will not be creating our own assets as part of this project, although you are of course welcome to!
![Screenshot preview of the game](/src/assets/godot/dungeonCrawler/screenshot.png)

We'll instead be using a free asset pack by Ox72 on Itch.IO which [can be found here](https://0x72.itch.io/dungeontileset-ii) Just click *Download now* followed by *No thanks, just take me to the download* and download the file called *0x72_DungeonTilesetII_v1.7.zip*
In this tutorial, you'll work step by step through creating your very own Dungeon Crawler! In this game, the player will navigate through a multi-level dungeon of your design, full of enemies to fight, and treasure to collect!

You'll learn to:
- Create an animated player character
- Create enemies that chase and attack the player
- Create a User Interface that tracks health and points
- Switch levels
- Design 2D Combat

Let's jump right in!

## Making the project

Expand All @@ -38,9 +41,11 @@ Godot Documentation for nodes discussed in this section:
:::


Set up a Basic 2D project, using the Forward+ Renderer. Let's start by importing our assets.
We won't be creating our own assets as part of this project, we'll instead be using a free asset pack by Ox72 on Itch.IO which [can be found here](https://0x72.itch.io/dungeontileset-ii) Just click *Download now* followed by *No thanks, just take me to the download* and download the file called *0x72_DungeonTilesetII_v1.7.zip*

Create a new 2D project, using the Forward+ Renderer.

Let's start by importing our assets!

<Steps>

Expand All @@ -61,7 +66,7 @@ Set up a Basic 2D project, using the Forward+ Renderer. Let's start by importing
</Steps>

<Box>
### Checklist
## Checklist
<Checklist>
- [ ] I have imported the assets
- [ ] I have setup my folders and changed the settings
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Here's how my scene looks with no other modifications:

Let's hit **Ctrl + S** and save this scene in our **Scenes** folder, call it **Player.tscn**

### Animations
## Animations

Let's give ourselves something to look at!
<Steps>
Expand Down Expand Up @@ -71,7 +71,7 @@ Let's give ourselves something to look at!
Great! That's our animations all done!
</Steps>

### Collision
## Collision

Now that we have something to look at, let's give our player a hitbox.
<Steps>
Expand All @@ -87,7 +87,7 @@ Now that we have something to look at, let's give our player a hitbox.

With our script created and attached, let's get to programming our movement!

### Movement
## Movement

<Steps>

Expand Down Expand Up @@ -140,7 +140,7 @@ Switch back to 2D view at the top of the screen.
And that's our player ready to go for now!

<Box>
### Checklist
## Checklist
<Checklist>
- [ ] I've created the player scene
- [ ] I've setup the animations
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ description: Setting up a basic test level
import Checklist from '/src/components/tutorial/Checklist.astro';
import Box from '/src/components/tutorial/Box.astro';

## Building a level
## Level Scene

:::note[Godot Documentation]
Godot Documentation for nodes discussed in this section:
Expand Down Expand Up @@ -82,7 +82,7 @@ Here's what my room looks like:
Don't go too crazy on your level design just now! This first area will just be to test!
:::

### Adding our player to the level
## Adding our player to the level

Now that we have a basic level set up, let's add our player to it so we can start to properly test our game! To do this, we'll just drag our player scene from the **Scenes** folder
in the file browser, into our **scene tree** as a child of the root node! Finally, we'll give the player a child of type **Camera2D.** here's what my scene looks like:
Expand All @@ -93,7 +93,7 @@ Don't worry if the names of your nodes are different, leave them as they are for

You should be able to move around! Though you'll quickly notice you're able to walk through walls, which isn't ideal, so let's fix that!

### Level collision
## Level collision
<Steps>
1. Click on your **Walls TilemapLayer** Node, Then, navigate to the inspector. Click the **TileSet** Object at the top of the inspector.

Expand Down Expand Up @@ -125,7 +125,7 @@ You should be able to move around! Though you'll quickly notice you're able to w
Now try playing your game again! You'll notice you actually collide with the walls! Great!

<Box>
### Checklist
## Checklist
<Checklist>
- [ ] I've set up the Tilemaps
- [ ] I've added collision
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import Checklist from '/src/components/tutorial/Checklist.astro';
import Box from '/src/components/tutorial/Box.astro';
import { Steps } from '@astrojs/starlight/components';

## Improving our player

:::note[Godot Documentation]
Godot Documentation for nodes discussed in this section:
Expand All @@ -23,7 +22,8 @@ make sure our animation changes to our walking animation when we move, and make

We'll also be implementing attacking, but we'll do that in its own section!

### Input mapping
## Input mapping

<Steps>
1. To change our inputs, we'll first need to set up our **Input Map** to do this, we'll navigate to **Project -> Project Settings** in the top left of the workspace.

Expand Down Expand Up @@ -65,7 +65,7 @@ if you run your game, you'll notice your inputs are now changed!
We won't assign our Attack option just yet, but it's good we've created it already.


### Animation switching
## Animation switching

To change our animation depending on if we're moving or not, we'll only need to add a few lines to our script. But first, we'll need a reference to our **AnimatedSprite2D** in our script.

Expand Down Expand Up @@ -131,7 +131,7 @@ Great! Let's get to changing our animation!

Play your game, and you'll notice your animation changes when you move!

### Sprite facing
## Sprite facing

To flip our player based on the direction we're moving, all we really need to do is add another If to check only the **Horizontal** part of our velocity, as thankfully the **AnimatedSprite2D** node has a built-in way to flip our sprite!

Expand Down Expand Up @@ -190,7 +190,7 @@ I'll be adding this section **beneath** the animation section, but before the **
Test your game, and you'll notice your sprite now faces left or right depending on the direction we're facing!

<Box>
### Checklist
## Checklist
<Checklist>
- [ ] I've setup the Inputs
- [ ] My sprite flips from left to right
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import Checklist from '/src/components/tutorial/Checklist.astro';
import Box from '/src/components/tutorial/Box.astro';
import { Steps } from '@astrojs/starlight/components';

## Creating our Weapon

:::note[Godot Documentation]
Godot Documentation for nodes discussed in this section:
Expand All @@ -19,7 +18,7 @@ Godot Documentation for nodes discussed in this section:

Let's give our player something to attack with!

### Weapon Scene
## Weapon Scene

Let's make our weapon!
<Steps>
Expand Down Expand Up @@ -54,7 +53,7 @@ Let's make our weapon!
6. Before we move on, navigate to the inspector tab of the **Area2D** node and find the **Collision** tab, under **Layer** make sure nothing is selected. Under **Mask** Make sure *only* 2 is selected.

</Steps>
### Weapon Script
## Weapon Script
<Steps>
1. Let's create a script to control our weapon, create it using the default template and attach it to the **root node2d,** call it "weapon.gd"

Expand Down Expand Up @@ -105,7 +104,7 @@ Let's make our weapon!
```
</Steps>

### Sword Animation
## Sword Animation

Now, let's start creating our attack animation!
<Steps>
Expand Down Expand Up @@ -144,7 +143,7 @@ And that's it! We'll come back later to add the code for destroying enemies.

Great! Let's get our weapon added to our player!

### Adding our weapon to our player
## Adding our weapon to our player

Navigate to your player scene. From the filesystem, drag in your weapon scene (called **weapon.tscn**) and attach it as a child of the main
**CharacterBody2D** node.
Expand All @@ -155,7 +154,7 @@ You're also welcome to adjust the size of the weapon (Although, you're best to d


<Box>
### Checklist
## Checklist
<Checklist>
- [ ] I've created the weapon scene
- [ ] I've created the weapon script
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import Box from '/src/components/tutorial/Box.astro';
import Checklist from '/src/components/tutorial/Checklist.astro';
import { Steps } from '@astrojs/starlight/components';

## Health

:::note[Godot Documentation]
Godot Documentation for nodes discussed in this section:
Expand All @@ -18,7 +17,7 @@ Godot Documentation for nodes discussed in this section:
:::


### Player Health
## Giving our player Health

Let's start setting up our health system on the player side!
<Steps>
Expand Down Expand Up @@ -199,9 +198,9 @@ Let's start setting up our health system on the player side!

And that's the player side of health done! Let's move onto the UI side!

### Health UI
## Health UI

#### UI Setup
### UI Setup

Time to start making some UI!
<Steps>
Expand All @@ -222,7 +221,7 @@ Time to start making some UI!

Great! That's all the UI setup we'll need to do for now (Though we'll come back to it later for points)

#### UI Scripting
### UI Scripting

<Steps>
1. Add a script to the root node, calling it "ui.gd"
Expand Down Expand Up @@ -330,7 +329,7 @@ Great! That's all the UI setup we'll need to do for now (Though we'll come back

</Steps>

#### Getting things connected
### Getting things connected

<Steps>
1. Go back to your main level scene. Add a new child of type **CanvasLayer** and add your new UI scene as a child of this! (This ensures that the UI 'sticks' to the camera, rather than existing within the game)
Expand Down Expand Up @@ -359,7 +358,7 @@ Run your game! And you should have 3 hearts! Great!


<Box>
### Checklist
## Checklist
<Checklist>
- [ ] I've given the player a hitbox
- [ ] I've created the health UI
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
---
type: tutorial
unitTitle: Pickups
title: Health & Coins
title: Potions & Coins
description: Implementing pickups for the player to collect
---

import Checklist from '/src/components/tutorial/Checklist.astro';
import Box from '/src/components/tutorial/Box.astro';
import { Steps } from '@astrojs/starlight/components';

## Pickups

:::note[Godot Documentation]
Godot Documentation for nodes discussed in this section:
Expand All @@ -22,7 +21,7 @@ Let's get onto pickups! Our game will have two types of pickups: Coins, and Poti

Thankfully the setup for the two will be extremely simple, and they won't even need a script! As all logic is handled by our hitbox script!

### Coins
## Coins

<Steps>

Expand Down Expand Up @@ -91,14 +90,14 @@ Don't worry, we've done all the hard work of connecting signals earlier! This'll

If you've set it all up right, you should notice this number going up each time you pick up a coin! Add a few instances of the coin scene to your level to test!

### Potions
## Potions

For potions the process is exactly the same! You should be able to do it on your own! Just follow the steps for creating the coin scene. Except in this case we'll just want a regular **Sprite2D** As the potion sprite isn't animated, and we'll want the group to be called "health" (make sure it matches the line we wrote in **hitbox.gd**)

Don't worry if you don't seem to be able to pick up the potions! It's probably because you have full health!

<Box>
### Checklist
## Checklist
<Checklist>
- [ ] I've created a coin pickup
- [ ] I've created a potion pickup
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import Checklist from '/src/components/tutorial/Checklist.astro';
import Box from '/src/components/tutorial/Box.astro';
import { Steps } from '@astrojs/starlight/components';

## Enemies

:::note[Godot Documentation]
Godot Documentation for nodes discussed in this section:
Expand All @@ -22,7 +21,7 @@ Something to fight!

We'll be keeping our enemy fairly simple, it'll operate off a circular detection range, and walk toward the player if it enters that range, without taking into account walls (Though it will of course still collide with walls)

### Enemy Scene
## Enemy Scene

Let's get to making the scene!

Expand All @@ -48,7 +47,7 @@ Let's get to making the scene!

</Steps>

### Enemy Scripting
## Enemy Scripting

Now let's get the enemy moving!
<Steps>
Expand Down Expand Up @@ -149,7 +148,7 @@ Add an enemy to the scene, and you should notice that if you get close to it, it

Although there's one problem... We can't destroy it!

### Destroying the enemy!
## Destroying the enemy!

Head to your Weapon Scene and open the **weapon.gd** script. We'll just need to make some slight modifications to check if the sword is colliding with enemies when we attack.

Expand Down Expand Up @@ -187,7 +186,7 @@ Head to your Weapon Scene and open the **weapon.gd** script. We'll just need to
Test it out, and hopefully you'll find you can now destroy the enemies!

<Box>
### Checklist
## Checklist
<Checklist>
- [ ] I've created the enemy scene
- [ ] I've created the enemy script
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import Checklist from '/src/components/tutorial/Checklist.astro';
import Box from '/src/components/tutorial/Box.astro';
import { Steps } from '@astrojs/starlight/components';

## Another floor

:::note[Godot Documentation]
Godot Documentation for nodes discussed in this section:
Expand All @@ -24,7 +23,7 @@ Until now, our game has only had one level. Let's change that! Thankfully, Godot

Let's get straight into it!

### Creating Multiple Levels
## Creating Multiple Levels

To create multiple levels, we'll want to save each level and *everything* in the level, as a **Scene.** A level should contain **Everything** that we want to be part of the level, such as enemies, coins, and potions. However we *don't* want the player or the UI to be saved in the level.

Expand Down Expand Up @@ -59,7 +58,7 @@ Here's an example of a level I made, take note of the order of the nodes in the

![Initial Scene](/src/assets/godot/dungeonCrawler/createdLevel.png)

### Level Loader
## Level Loader

The very last step for our game, is creating something to actually transition us between levels!
<Steps>
Expand Down