r/roguelikedev • u/aaron_ds Robinson • Jun 26 '18
RoguelikeDev Does The Complete Roguelike Tutorial - Week 2
This week is all about setting up a the map and dungeon.
Part 2 - The generic Entity, the render functions, and the map
http://rogueliketutorials.com/libtcod/2
This introduces two new concepts: the generic object system that will be the basis for the whole game, and a general map object that you'll use to hold your dungeon.
Part 3 - Generating a dungeon
http://rogueliketutorials.com/libtcod/3
Your dungeon takes a recognizable shape!
Of course, we also have FAQ Friday posts that relate to this week's material
- #3: The Game Loop (revisited)
- #4: World Architecture (revisited)
- #22: Map Generation (revisited)
- #23: Map Design (revisited)
- #53: Seeds
- #54: Map Prefabs
- #71: Movement
Feel free to work out any problems, brainstorm ideas, share progress and and as usual enjoy tangential chatting. :)
16
u/Lokathor dwarf-term-rs Jun 26 '18
It's your friendly neighborhood Lokathor again, back with some Rust roguelike action. We've got a repo link like before, including a week 02 lesson and some screenshots of how it looked as things went along.
This week we make...
11
u/DerekB52 Jun 26 '18
LibGDX with Kotlin here. I've got section 2 done. I actually did most of this work last week, because the first section took very little time. I've also done a little refactoring already, but a bit more is needed. The end of section 2, has a method for blocking the player's movement, if he touches a blocked tile, my code doesn't do that yet, that's easy to add, but the map generator is too shitty at the moment, I don't want to spawn my player in an area where he can only move 1 tile. I'll start on section 3 tomorrow most likely. (which is technically today, it's 1am here).
Part 3 seems exciting. I started writing a dungeon generator early last week. But, it doesn't do more than spawn random tiles at the moment. I haven't actually put too much time into playing roguelikes, so I don't know what the goals for this dungeon generator are yet. The FOV algorithm also seems interesting. I've done something with FOV one time, and I don't really remember it, so we'll see how it goes.
Gitlab link: https://gitlab.com/Derek52/Kotlin-Rogue-Game
9
u/jpelgrims Jun 26 '18 edited Jun 26 '18
Finished part 2 and 3. Since I don't want to get too far ahead I added some side-features. First I managed to add basic field of view similar to the one used in Moria (where only the current room is lit up) using basic raycasting. Then I added a "tile legend", which shows all types of visible tiles and their names.
I've also managed to set up a very basic telnet game server. Because the rendering is completely done in the console, using ANSI escape codes, this wasn't too hard. The server is basically a simple ncat command that uses the -k and -e flags. The -k (--keep-open) flag allows for multiple simultaneous connections, while the -e (--exec) flag takes an executable as a argument. The executable (in this case a bash script that starts up the game) will then receive all input received over the telnet connection, and any output from the executable is also sent back over this connection. Much to my amusement, it is surprisingly stable and works rather well.
Right now I'm working on adding a menu interface to the server so the client can register, login, load savefiles and change keyboard controls.
Repository - Screenshot
8
u/VedVid Jun 26 '18 edited Jun 26 '18
I finished parts 0 and 1 already, but I started to work on next parts only recently.
Learning Lua through roguelikedev entry is kinda difficult for me, even if it is simple language, and I'm just transpiling python tutorial. For example, imitating real classes was (well, it still is) troublesome. But it will work out, I believe.
I hope that I'll manage to finish my Go entry this year. In contrast to 2017, coding is my priority, and all notes are just poorly written very first drafts instead of real write-ups.
PS. I still suck at using git properly.
edit: wrong link formatting
7
u/DynamicTextureModify Jun 26 '18
Just started on part 2 a little bit ago, I'm glad to see we're refactoring into some nice re-usable components.
7
u/T4keTheShot Jun 26 '18 edited Jun 26 '18
I started my game a while ago with the python 2 libtcod tutorial so hopefully someone can still help me. I decided to add the BSP map generation from the extras part of the tutorial because it looks much better than the make_map() originally used in the tutorial. The problem is that when I replaced map generation with the BSP one, now place_objects() doesn't quite work like it's supposed to anymore. Now if I increase the numbers of items per room to even a very high number, the items only spawn on a single square, stacked on top of each other. and many rooms have no items at all, but the ones that do have items have like 10 on top of each other. Where as before switching to the BSP map, if I increased the number of items per room then you would see more items in every room in the dungeon, and spread apart in the rooms and very rarely ever stacked on top of each other. Here is how it looked before switching to the BSP map function and here it is afterwards. The problem is I dont really understand how the BSP function works at all, the tutorial basically just says that you can just copy and paste it in and it will work like the old map generation but better. It doesn't say anything about having to change place_objects().
7
u/haveric Jun 26 '18
Got a late start to this, but I've gotten everything up to part 3 complete. Github repo
So far I'm using the standard tutorial with Python, but I'm hoping to convert it to JavaScript if I find a bit more time. I've seen others mention rot.js and I'm torn between using that and building it completely custom. Maybe both? So far it doesn't seem like I'd need too much custom code, but might want some utility classes (such as input) that I've built for small games in the past. If anyone has experience trying to do this with JavaScript, please let me know.
7
u/Sh4rPEYE Lisper Jun 26 '18
Hey! The run with Racket continues. I'm around Part 3/4 now, but I don't follow the tutorial closely; for example, I don't want to have a cavern-based environment, so I'm implementing a simple village generator before I start to work on FOV. Here is a screenshot from the latest version (not yet on github).
I have to say I like Racket a lot — it feels really "fluid" to write it and it is very readable. I have a lot of freedom when it comes to the model design, because Racket can do functional, OOP and everything in between. This freedom is at the same time my biggest pain-point — I just can't decide what I want! So, now I'm just experimenting and there will be a big refactor later.
Here is the blog series and here you can find the repo with code. I'm not a blogger and it shows, but I'll work on it. I think I'll rewrite the Part 1 post entirely. If you have some suggestions, please share them with me.
I wish all my new colleagues luck!
6
u/SickWillie Goblin Caves Jun 26 '18
GitHub Repository!
Using C++/SDL2
I think I accomplished quite a bit over the last week - haha, but man do I have little to show for it! Started this past week with having finished adapting Parts 1-3 of the tutorial.
During the last week:
My goal for the next week is to get a dungeon generator up and running, and get a head start on the FOV code - I've done FOV code for another project so I hope it won't give me too much grief!
6
u/Sweedish_Fid Jun 26 '18
This tutorial doesn't really follow my learning style so I've decided to bring out my graphing calculator and see what I can do with it. I've actually been working on it since Aug 2017 when I was camping for a week waiting on the Eclipse.
This challenge has given me a reason to pick it back up. I'll be programming it with the TI-BASIC language within the GrafNCalc83 program on IOS. Since using Github probably won't be the best place to put code is there another place I can put it?
6
u/CrocodileSpacePope Jun 26 '18
I'm doing the /r/roguelikedev tutorial in Rust, using libtcod.
GitHub Repo
Today, I did both Part 2 and Part 3 of the tutorial. I did write my experience down, just follow the links to read.
Part 2 - The generic Entity, the render functions, and the map
The whole Part summed up for me:
I had some problems while doing Part 2, originated by the lack of knowledge of Rust by myself tbh, and because I don't think ahead when trying out stuff. I especially messed up the borrows and moves at some point, which led to somewhat ugly code, but I decided to just carry on with this. Maybe I'll fix it at some point later.
Part 3 - Generating a dungeon
No real problems at all. I messed up the room generation loop a bit, but nothing too bad.
Summed up:
6
u/toptea Jun 26 '18
Python 3 using libtcod-cffi & numpy
Here's my map generation with irregular rooms and "3D walls".
Screenshot - Repo
Ah yes, numpy arrays. I personally found that a different mindset is required when using them. Instead of using loops of any kind, you have to do a thing called "code vectorization". I have so much trouble with this concept that I've ended up ditching my IDE, and went back to jupyter notebook. I test each statement line by line, and draw everything out using matplotlib. Once I'm happy, I put them all back into my main code. Unconventional, but at least I've made it to the end!
5
u/DontEatSoapDudley Jun 26 '18 edited Jun 29 '18
C++ Implementation
Ok so we're back for week 2 and I've gotten all the code working. Here's the current code for week 2 and a screenshot (Colour scheme is temporary, just chose vibrant colours for display purposes while I got shit sorted). Blue is player, pink NPC, green walls and purple are floors. Updated screenshot: https://i.imgur.com/XE6qz9O.png
Major changes:
Code layout info: is to make a new branch for each week so anyone who wants to study the code can look at each iteration to understand specific stuff. I try and comment my code where it might be confusing but if you have any questions please do ask, I'll happily explain my choices and what it means.
Where to now: I'm having fun so after I come back from dinner I'm going to work on map generation. After that FOV most likely. I don't necessarily want to create a generic roguelike and I have an idea brewing in my head so I'll probably move forward with that and begin to depart from the tutorial, although to keep the content coherent I'll add in similar features to what is being added in that week of the tutorial.
I've begun working on map generation and am starting to choose the direction for my game
5
u/dystheria Jun 26 '18 edited Jun 26 '18
Complete Beginner C++17/libtcod/MSVS guide
Parts 2 and 3 of my efforts are available for scrutiny. Repo can be found here.
I've added some readme.md files to each section of the repository to help anyone that might be new to C++ or looking for a slightly more detailed examination of the C++ code.
(disclaimer: I'm both new to developing roguelikes and new to C++ so any corrections are appreciated.)
Edit: I am bad at reddit... mkay.
5
u/[deleted] Jun 28 '18
Got my status here. So far, I’m really not learning much just from typing the code out myself. What’s making me learn is wondering why use a reference here vs a pointer and reasoning it out for myself. Kinda fun, and really new for someone who hasn’t had to worry about memory management ever.
I’m also a week ahead at this point, so feeling pretty proud there as well. I’m enjoying working with C++ enough to where I’m trying to figure out how I want my toolchain to work and graduating from using Sublime Text to an IDE (or at least figuring out how to run/debug builds from ST). Any advice from you vets on those matters would be appreciated!
4
u/[deleted] Jun 26 '18 edited Jun 26 '18
The D Language Tutorial continues, this week we also make a generic class for our entities, create and generate the map, and start moving around on it.
02: Actors and Maps
03: Dungeon Generator
I'm having a lot of fun doing these, and thanks to those that are following along, you've been a big motivator. I usually finish them before Tuesday, and post them as they're finished instead of waiting to "go live", so if you're chomping at the bit keep an eye on the repo or the website.
4
u/brianbruggeman Jun 26 '18
Name: Kelte
Github: https://github.com/brianbruggeman/kelte/tree/develop
Obligatory screenshot: https://imgur.com/a/JEasoHF
Stuff I've done for Week 1:
kelteto the package to run the gamepytest: coverage is about 70% right now)Package: built up the full package so it's downloadable into a virtual env:
TODO yet for Week 1:
Small discussion:
Plans for Week 2:
randompackage, but I want to improve this during my updates for combat so that the combat system is more predictable. In other words, random will be a (relatively small) bag of random numbers which are sampled until the bag is exhausted. That bag will then be shuffled and queued up again. This will make testing super easy, and I think players will be happier when 10% really means 1 in 10.4
u/Rinneeeee Beginner Dev Jun 28 '18
Github repository
I can't believe I'm participating this year. Last year I wasn't able to join but I'm so hyped. I'm going to diverge a little along the journey and make my own roguelike. When it's done I hope everyone can enjoy what I've made.
For this week, I had some problems with the dungeon generator. Sometimes rooms would not connect properly, and I knew it had to be either the create_tunnel functions or the make_map function itself. Rechecked the tutorial, tried to find the mistake for 15 minutes. Then I realized I switched new_x with prev_x. Brain fart moment right there.
3
u/Notnasiul Jun 27 '18
I'm a bit ahead (FOV + enemies + turns) because I wanted to figure out during this week whether to keep doing it in Python or switch to Javascript + rotjs + phaser3
Yesterday I found this repo: webpack-babel-phaser-rot-js and today I'll give it a try! If I don't feel comfortable there I'll go back to Python.
In both cases I'll try to add more dungeon generation methods and maybe scrolling (althogh I like one-screen roguelikes like Brogue)
3
u/_velocicat Jun 27 '18
Following along (albeit loosely) in Java with Trystan's tutorial and the AsciiPanel library. Rather than caves / cellular automata I designed a BSP room generator. I've used the tutorial to add line of sight / fov as well as a few enemies. I'm currently working on adding more items. I'm also trying to use this as an opportunity to get familiar with git.If I'm understanding version control correctly, I think I should be able to branch my code if I want to add a new feature, such as mouse support. Then I can revert back to a previous state, or branch, should I really hose things up. Is this accurate?
3
u/Rakaneth Jun 27 '18
GitHub
I've changed languages again. This will be the last time I do that. I'm writing in Javascript now, for reasons I've outlined in detail in the devlog included in the repository's README, but mostly had to do with my dislike of libtcod and the way Python interfaces with it. Also, I plan on doing something slightly nonstandard with FOV, and I want a library that I am both more familiar with and has more features, so that I can work on content and this aspect of the game. This does set me behind a week, but I am confident I can catch up quickly.
3
u/DerekB52 Jun 27 '18
This is my second comment in this thread, but I've gone ahead and finished Section 3. I'm using Kotlin and LibGDX, and this is the section where I started to run into problems.
I've never translated more than a few methods from one language to another, and it's been an interesting exercise here. Nothing has been too difficult exactly, but I've had to restructure the python example, a bit, to make it work with Kotlin/LibGDX, and my coding style.
If you look at my code, it is messy in a few places, but, I don't want to fix it too much, yet, because i want to see what else we add. The other features will depend on how I clean up and reorganize my current code.
I'm linking here to one specific file in my gitlab repo, because I think it has a good joke in it. But, to anyone reading my repo, I'd like to point out that I had to rewrite GameMap.kt, as GameMap.java, because I was running into a couple issues with Kotlin. The multidimensional array is the only thing that looks nicer in Java syntax.
I'd like to just use an ArrayList, but haven't figured out how I want to do that yet. Anyway, here is my repo, https://gitlab.com/Derek52/Kotlin-Rogue-Game/blob/master/core/src/pizza/derektheprogrammer/kotlinrogue/PlayScreen.kt
3
u/haveric Jun 28 '18
Had some time to start porting over to plain JavaScript. Github | Demo (Try alt+enter to "fullscreen")
Definitely want to take some time to go back and clean things up and optimize where possible, but might look ahead on the tutorial to make sure I'm not optimizing too early for something that will be removed/changed later.
The main issue I ran into was having to create my own renderer for outputting ascii and getting all the offsets to match up correctly. I ended up using 10px monospace figuring it would make it at least consistent width, but I don't really like the rectangular grid, so I may go back and implement a basic sprite-based renderer at some point (Possibly allowing for switching mid-game). If anyone knows a web font that is square or has any other suggestions here, that would be awesome.
I'm looking for any feedback on what I've got so far. I've tried to stick as close to the tutorial as I can, but some things had to be changed due to not being python. Definitely learned more while converting this than I had just following the tutorial, so I'm glad I chose to do both. Specifically, I wanted to note that I now know what a "for else" is, which I wasn't aware was a thing before.
3
u/[deleted] Jun 28 '18
GitHub repository
Late update this week. In my defense, it's because I finally decided to see what all the hype about DCSS was, and it hastily devoured my free time. (This was for research, so it counts as working on the game. That's my story and I'm sticking to it.)
Here's a screenshot of how my Ruby/BearLibTerminal version is working so far. I'm not very happy with the default tutorial mapgen, but it's working for now. Map generation has been the bane of a lot of my past projects, but I'm going to try to find an algorithm I'm happier with before starting on part 4.
3
u/masterofallvillainy Jun 28 '18
I'm a bit behind. I'm doing a graphical roguelike and using pygame. I'm still creating assets and will have to use temp graphics to fill in as we progress through this tutorial. but i have a small room created with tiles and have a character placed in its center. heres a screenshot of what I got so far:
Oubliette
3
u/ShotShadow Jun 30 '18
Marching my way slowly through the tutorial and finished the week 2 lessons.
I’m programming in Swift using the SpriteKit engine that’s provided by Apple. I had to take some weird paths to use this engine where I create an object that will always be rendered as long as it’s attached to the scene. This makes it so I don’t need the render functions but, need to figure out a dance to keep objects I want to be rendered attached to the scene or not.
Not sure what the performance implications of this will be in the future but, I’ll deal with optimizing it later if it’s a problem.
My Repo
3
u/Zireael07 Veins of the Earth Jul 01 '18
Haxe
Yes, I know this is my second top-level post to the topic. Yes, I already posted about doing the tutorial in Javascript. For all the speed with which I did the first two weeks, I don't particularly like JS as such (mostly because it forces you into a completely different design space instead of clean nice classes and instances) and I'm only doing the tutorial in it because I use JS at work and have to get more comfortable with it.
The goal is still to have a web version of Veins, so after a very brief dalliance with Nim (no native roguelike libraries and dll's can't be used in js target, so a story similar to Golang (see week 1)), I picked up Haxe. Haxe's syntax is fairly similar to Go (which is described as somewhere between C and Python) and I like Haxe's syntax more than Java. var blah:int is very close to what mypy (typed Python) uses, after all. And no fugly C-style for loops, which I hate.
I briefly debated Kha vs HaxeFlixel for the input/output framework (no roguelike libraries, again, and while using C libraries IS possible in web target, it isn't something I want to deal with for a summer jam) and settled on HaxeFlixel. When I went to the site, I realized I was looking at it briefly sometime last year, when I was at the "where to go after Lua" stage.
Setting up HaxeFlixel was as easy as following the tutorial on their site (and they also have a ton of demos with source available, including BSP generation and cave generation). Getting a working simple single room + a player on screen took me all of an afternoon, so even faster than JS because I didn't have to spend hours wondering why it doesn't redraw :P
Today I realized that I forgot to account for map limits and walls, so I quickly fixed those problems.
Screenshot
I will try to set up a repo for Haxe sometime today between the football matches :P One problem I can perceive is doing composition as Haxe seems to be made to shoehorn you into oop inheritance (and has NO multiple inheritance unlike Lua) but I will try my best to perservere.
4
u/Zireael07 Veins of the Earth Jun 26 '18
Web Veins
JavaScript
So the choice of javascript turned out to be a good one. I already breezed through week 1 (setup) and week 2 (basic entity, moving around, a simple map) by quickly following the rot.js tutorial on Roguebasin.
All that in one day and with tons of comments to myself (since I don't feel as comfortable in js as in Python)
No github repo yet and coding done in portable vim since well, not at my own computer yet :(
2
u/DerreckValentine Jun 26 '18
I'm jumping ahead and certainly not following the tutorial to the letter, but I'm following the same structure and steps.
I'm using Unity and C#
Here you go: https://bitbucket.org/rkshelton21/rogueliketutorial/src/master/
2
u/jack_is_online Jun 27 '18
I finished part 2 and 3 already (repo is here). Everything seems to be working just fine but I think I'll clean things up a bit before I move on. I probably need to organize my classes better and I think I'll also separate the UI code into its own set of classes.
2
u/domtorr Jun 27 '18
I'm relatively new to gamedev, roguelikedev and programming. I've already completed the tutorial in Python and Rust. This year I wanted to try and follow the path of the tutorial and converting what I can into C# and Unity as I'm learning both right now. I will probably get behind on this because I am not using a library like RogueSharp or libtcod, but if I figure it out I plan on doing a whole step by step write up on how to do it on my blog. If I get that finished I'll post it if I get the blessings of the mods.
Here is my GitLab repo so far
I made a gif of my guy walking around. I know it's just basic, but took me a while to learn how to set up Unity and get TileMaps and sprites going. Check it out.
2
u/cld Jun 28 '18
Couple days late, but I finished tuts 2 and 3 today. Big takeaway personally was how the room interconnections was accomplished, thought calling both horizontal and vertical hall creators was pretty clever.
2
u/Kehvarl Jul 02 '18
Still following the rogueliketutorials path fairly truthfully. I have diverged on a couple of toy branches, but everything in my repo is correct. I did manage to achieve a happy accident in my map generation code. If a room intersects with another, I'm not drawing it but I'm still storing it as a room, which means I generate a lot of rather interesting corridors to nowhere. On a few maps this has lead to inaccessible rooms, so I may tweak the code slightly to keep the dead-ends, but make sure all rooms have at least one path to another rendered room.
3
u/EsotericRogue Jun 26 '18 edited Jul 07 '18
Good morning. I'll be streaming Week 2 tonight at 8PM EDT. Nothing fancy, just Python3.6.5 and Libtcod 1.7 on Windows 10. I should be able to field most question from any novice python programmers, and I'd be happy for anyone to stop by. Here's the repository.
Programming might be very boring to watch on it's own, so I'll be throwing in some chess and perhaps guitar for short breaks. ADOM is queued up for long breaks.
Last week (YouTube), I wrote my own summary for Step 0, for those reasonable people that don't want to learn Powershell, and to correctly note the 'py -c "import libtcodpy"' command. Hopefully this will be of some use to someone.
See ya around.
1
u/CrypticTryptic Jul 03 '18
So, this block of code:
and its explanation of:
"Don't worry if the intersection logic seems alien, it's a direct formula that doesn't require interpretation! It's one of those copy-and-paste things."
led to me spending 6 months learning Python in the hopes that understanding it would allow me to make the map that I wanted to (a map where a half dozen of the rectangle rooms overlap to make a sort of "golf course" shape, like this:
https://i0.wp.com/www.spitballsessions.com/wp-content/uploads/2018/01/s_Golf_2.png?w=640&ssl=1
And after doing all of that, I've come to the conclusion that... I don't think this is even the part of the function that I need to change to make that work.
0
u/[deleted] Jun 26 '18
[deleted] — view deleted comment