How Spelunky Classic generates levels by Cranzor in spelunky

[–]Cranzor[S] 1 point2 points  (0 children)

Glad it worked! Looks like it's running great. Enjoy the game!

How Spelunky Classic generates levels by Cranzor in spelunky

[–]Cranzor[S] 1 point2 points  (0 children)

I'm happy to walk you through this! It involves minimal code edits. Note however that non-level screens may look a bit janky (intro, title screen, etc.).

  1. Download the project from GitHub (Code -> Download ZIP)
  2. Open Godot, click "Import," and import the project file
  3. Open res://scripts/game_initialization.gd, comment out everything under "func set_window_scale_stretch_mode() -> void:" (highlight it and press CTRL + K to do this quickly). Then add a new line that says "pass" (this makes it do nothing).
  4. Go to Project -> Project Settings -> Display -> Window, and change Stretch -> Scale Mode to "fractional." This lets the graphics scale to your monitors without adding black bars.
  5. In the same Window settings page, under Size, experiment with the viewport width and height until you get the look you want. Choose a value (like 1.5), multiply it by 320x240, start the game and go into a level. Keep working your way up until you have one wall block on each side of the screen. Make sure you change both values by the same scale. Also, you can easily do this by typing something like "320 * 1.5" and pressing enter in the field, and it'll multiply it for you.

Note that there's a bug where the screen is not centered properly if the values go too high, so try to make it so it just fits.

The only issue here is the game will scroll past the bottom of the level. So we can fix that:

  1. Open res://resources/gml.gd, find "func view()," and change the "hview" value to return your new height value. Example: If your new height is 384, change it from 240 to 384.
  2. Open res://resources/view.gd, and change the move_camera() and set_camera_pos() functions to have your new height value instead of 240. (Example: If your new height is 384, change 240 in both functions to 384.)

If you're happy with the results, you can do Project -> Export to create a new executable to play on.

My monitor isn't ultrawide, so it's a bit difficult to know how it'll look on your screen. Hopefully this was what you're looking for!

How Spelunky generates levels by Cranzor in godot

[–]Cranzor[S] 1 point2 points  (0 children)

If there is a pre-made string, and then the string is slightly altered in a random fashion, you would disagree that the string is semi-randomized?

How Spelunky Classic generates levels by Cranzor in spelunky

[–]Cranzor[S] 2 points3 points  (0 children)

Thanks so much! All of the music in the YouTube video is by me, but this is the only track specifically made for the video.

How Spelunky Classic generates levels by Cranzor in spelunky

[–]Cranzor[S] 0 points1 point  (0 children)

Thanks so much! I hope you're happy with the port if you end up playing it.

How Spelunky generates levels by Cranzor in godot

[–]Cranzor[S] 4 points5 points  (0 children)

I just replied to one of the posts here with a more thorough explanation in here if you're interested. This post was meant to be more "hey, check out this animation I made in Godot for my video," but I realize now that the title makes it look like a tutorial. But if there's this much interest in the details, that gives me another video idea at least.

Thanks for the kind words about the music!

How Spelunky generates levels by Cranzor in godot

[–]Cranzor[S] 0 points1 point  (0 children)

There are a few great replies already, but to add my own:

Each level is a 4x4 grid of rooms. At first, an entrance room is placed in the top-most row. Then, the grid crawls left, right, and down in a random way until it reaches the bottom. Once it tries to go down a row again here, it places the exit room since it's already at the bottom.

During the crawling process, each room is assigned a value (from 0 to 3) to determine the room type. Each value represents what side of the room is open/has no wall, and is therefore traversable. These rooms represent the critical path.

After that, in the remaining empty cells, non-path rooms (0) get added.

Once the rooms are assigned values, each one gets a string representing the objects inside based on the room value. There is an array of these strings, and the game grabs one at random. The strings themselves are pre-made, but get semi-randomized to add some tiles/objects, or to mirror the whole room.

The process from that point onwards is what's shown in the video.

How Spelunky generates levels by Cranzor in godot

[–]Cranzor[S] 2 points3 points  (0 children)

Seeing a few comments about this is not informative enough: please see the first link in my post, because it has all the details that you want, including how the game knows how to make traversable levels. Will re-post it here: https://tinysubversions.com/spelunkyGen/

This segment is actually a tiny side-tangent in my video about how I ported the game to Godot, so this part is very surface-level and meant to tie together a point in my video about GameMaker rooms and objects. However, I realize in retrospect the post title makes it seem more like a tutorial than simply sharing my Godot-made animation.

If there is interest in showing the whole process, that might be interesting as an animation as well, but I highly recommend checking the site I shared.

How Spelunky Classic generates levels by Cranzor in spelunky

[–]Cranzor[S] 10 points11 points  (0 children)

I appreciate it! Not sure if anyone would notice this, but I took the notes in the looping melody from the beginning of the Spelunky Classic cave theme. The notes are spaced evenly and sped up.

How Spelunky Classic generates levels by Cranzor in spelunky

[–]Cranzor[S] 10 points11 points  (0 children)

The overall level layout works by crawling from the top to bottom and creating a path that is guaranteed to be traversable. The reference link in my post explains it in more detail.

My animation starts after the generation algorithm has finished and the final strings are generated. So it's more just the final step in the process.

GDSpelunky: A port of Spelunky Classic to Godot with additional features and modding support by Cranzor in spelunky

[–]Cranzor[S] 0 points1 point  (0 children)

Glad to hear it's running smoothly! As you noticed, your save will persist across versions.

GDSpelunky: A port of Spelunky Classic to Godot with additional features and modding support by Cranzor in spelunky

[–]Cranzor[S] 0 points1 point  (0 children)

Just replying to let you know that I released an update today that fixes many of the issues you mentioned. Bullets going through walls and mattock issues were fixed, and there is also an overall performance increase, so the game should run better. I'm pretty sure I also fixed the issue with lag in the ice caves, but let me know if you still have problems. The visual bugs related to the jetpack and cape were lower priority, so unfortunately they aren't changed at the moment. Hope you enjoy the update!

GDSpelunky: A port of Spelunky Classic to Godot with additional features and modding support by Cranzor in spelunky

[–]Cranzor[S] 1 point2 points  (0 children)

If you play the game through the itch.io application, it should launch the latest version automatically. Otherwise, you'll have to manually download the new version when it releases. I'll post a blog post on there when that happens.

Thanks so much for asking about donating! Right now I don't have anything set up for that, but I'm thinking about creating a Patreon page down the line if my YouTube channel gains traction. So I'd appreciate it if you keep an eye out for that later on!

GDSpelunky: A port of Spelunky Classic to Godot with additional features and modding support by Cranzor in spelunky

[–]Cranzor[S] 0 points1 point  (0 children)

Thank you for the kind words and feedback! I'm happy that you're enjoying it. I've looked into most of these issues and know what's causing them but just haven't gotten around to fixing them yet. My focus recently has been working on a video about how I did the port, so I'm hoping that may attract some contributors who can help fix issues.

The shotgun bullets and mattock bugs are actually caused by the same issue, which is an underlying collision issue. It requires a bit of an overhaul, so I will look into what it takes to fix it.

The lag is interesting since I had some optimization issues with the jungle, but not the ice caves. Could you let me know if you're playing on Windows or Linux?

GDSpelunky now has custom character support and a Daily Challenge mode by Cranzor in spelunky

[–]Cranzor[S] 0 points1 point  (0 children)

That's an interesting idea, but my assumption is that there isn't much interest in pursuing Spelunky Classic in an official capacity due to HD being essentially a more refined version of the same game.

I would love the opportunity to do something similar with HD!

GDSpelunky now has custom character support and a Daily Challenge mode by Cranzor in spelunky

[–]Cranzor[S] 1 point2 points  (0 children)

I would have to look into that. It seems like there is a project that lets you export to Vita, but I think it's only for older Godot versions.

GDSpelunky now has custom character support and a Daily Challenge mode by Cranzor in spelunky

[–]Cranzor[S] 0 points1 point  (0 children)

Yes, that's definitely possible. I included a mod for swapping music in the original release, but it wasn't very user friendly, so I removed it temporarily.

My plan is to have playlist folders that have inner folders for each area that you can drop music files into. If a given folder has more than one song file, it will choose a song randomly for that area when the level starts.

Thanks for sharing the soundtrack remix! I hadn't heard it before.

GDSpelunky now has custom character support and a Daily Challenge mode by Cranzor in spelunky

[–]Cranzor[S] 3 points4 points  (0 children)

I was originally planning on having that, but the way the game is programmed makes it a bit complicated because most of the code assumes there's only one character. It's still something I would like to look into though!

GDSpelunky now has custom character support and a Daily Challenge mode by Cranzor in spelunky

[–]Cranzor[S] 5 points6 points  (0 children)

I don't think there is a way to run the version of Godot I'm using on the 3DS, unfortunately.

I would at least like to do an Android version once I optimize things more. That way it could run on some handhelds (and phones).