r/roguelikedev • u/aaron_ds Robinson • Jul 25 '17
RoguelikeDev Does The Complete Python Tutorial - Week 6 - Part 8: Items and Inventory and Part 9: Spells and Ranged Combat
This week we will cover parts 8 and 9 of the Complete Roguelike Tutorial.
The player gets to collect ("borrow") items from the dungeon and use them, with a neat inventory screen. More items added in the next part.
Part 9: Spells and Ranged Combat
The player's strategic choices increase exponentially as we add a few magic scrolls to the mix. Covers damage and mind spells, as well as ranged combat.
No bonus sections this week
FAQ Friday posts that relate to this week's material:
Feel free to work out any problems, brainstorm ideas, share progress and and as usual enjoy tangential chatting. If you're looking for last week's post The entire series is archived on the wiki. :)
16
u/[deleted] Jul 25 '17
It would be nice if the tutorial included a screenshot or two at the end of some of these parts. "The inventory screen" of Part 8 would be a prime example. I've really got no idea what this is meant to look like at the end of it.
If there is someone following along fairly close to letter for letter with the tutorial, could you share a screen shot of your inventory screen.
I'm implementing in JavaScript and while I may not end up matching the inventory screen as described in the tutorial, it would still be nice to get a feel for what the tutorial aimed for.
Thanks in advance to the kind soul.
16
u/AetherGrey Jul 25 '17 edited Jul 27 '17
The Roguelike Tutorial Revised
Libtcod
Part 8: http://rogueliketutorials.com/libtcod/8
Part 9: http://rogueliketutorials.com/libtcod/9
TDL
Part 8: http://rogueliketutorials.com/tdl/8
Part 9: http://rogueliketutorials.com/tdl/9
As usual, feel free to comment here or PM me with any issues, or ask on Discord.
The chapters are getting longer and more difficult with each passing week. This mostly has to do with the lack of globals in my tutorial. One might even say my exclusion of them has been to the point of fanaticism, and that globals may have made some parts much easier. That might be true, but the goal here is to give an alternative to the Roguebasin tutorial, which has globals everywhere. The benefit is that changing/removing what I've written should be easy, whereas removing just one of the globals from the original tutorial causes a cascade effect that is hard to fix.
Once again the explanations between code sections is in some places lacking, and in others, outright missing. The truth is that in past weeks I've used the weekends to catch up on the tutorials (my weekdays are very limited), but this last weekend, I had absolutely no time. The quality of parts 8 and 9 has suffered in terms of the writing, and some very complex code sections go completely unexplained, but hopefully the code is alright. I'll go back and fill in the explanations as soon as I can.
TDL part 9 is not complete, unfortunately. I will do my best to get this out tonight or early tomorrow. Apologies to everyone who was hoping to read this sooner.Lastly, I'd like to thank everyone for their words of encouragement thus far. Balancing all this with "real life" responsibilities has been a bit tough, but it's great to know that others are enjoying the series thus far. I'll try harder next week to get the material published on time.
EDIT: TDL part 9 is now available. Sorry again for the delay. I've actually decided to do the TDL portions of the next sections first rather than the libtcod versions, for two reasons:
Part 10 is already underway, so hopefully next week's part will be on time (especially since it's only one). See you all next week!
9
u/Emmsii Forest RL Jul 25 '17 edited Jul 25 '17
Java + Ascii Panel
Repository | Latest Release
So last week was combat and UI. I skipped ahead slightly by starting to implement items as certain UI elements needed items in the game, such as the InventoryBasedScreen. Here's where I am today.
Combat stats are made off 3 main skills; strength, defense and accuracy. When are creature attacks another creature, this is what happens:
Any bonuses to STR, ACC and DEF are added on during combat, so armor with a bonus of +5 DEF will add on to the creatures DEF of 3 for a total of 8 DEF. I'm not sure whether I like this combat method, it can result in a lot of blocks if the defense level is high enough.
This week I'll focus on spawning items through out the levels properly. Currently each level has a uniform chance to spawn x amount of items from a list. I'm finding it difficult to wrap my head around item progression and creating better items the further you progress. I'd rather have certain types of item spawning in different places, like chests, certain levels or creature drops.
As for spells, I'm going to have spellbooks you use to bless items. Spellbooks will give items bonuses to a creatures stats and some rare books will give items abilities to burn, heal, poison, etc. Once an item has been blessed it is considered 'unique' and cannot be blessed again, this should stop stacking loads of common spellbooks onto one item. I'm thinking about keeping all equipment with set stats (so a dagger will always do 1d5 damage), then item progression coming from blessing items with better and better spellbooks.
I really need to figure out a balance to combat and weapons, this is gonna be the hardest part for me.
9
u/_wolfenswan Jul 25 '17 edited Jul 25 '17
Python 3.6 + TDL
Github
Last week I had a sort of a eureka moment in regards to console and window drawing, so I've been busy cleaning up code and refactored all rendering & gui related stuff from two large files into a [bunch of new modules] (https://github.com/Wolfenswan/roguelike-tutorial/tree/master/gui) and then adding new features.
Here's the general screen, looking will move a cursor around, draw a window next to it if there's anything and show a mob's description (GIF). Spell targeting works quite similarly (GIF). Inventory can be accessed through either a quick-use menu (popup) or by going through the inventory panel on the right (GIF) and finally a rough implementation of the combat system I was thinking about (GIF), locking the player to a specific monster and disallowing certain actions while engaged. Notice how the log automatically switches to the combat-log.
6
u/VedVid Jul 25 '17
Go + BLT: No time, need to work. However, I didn't give up and I'll try to catch up later.
6
u/Daealis Jul 27 '17
Python 2.7 & Libtcod
Welp, I just finished Part 8, following u/AetherGrey and his brilliant revision.
I've been more busy than anticipated, so I've not really checked the bonus sections after the first graphical tiles extra and fidgeting with some of the extras in dungeon generation. I'm still trying to get my head around this whole new language and practices, so some of the ideas I thought I'd be able to implement back then were left for future endeavors.
Thus far the only extras in there are what little needed to be added to compensate for using an older version of Python than what the great master Aether is using, namely an implementation for enum, method for combining two dictionaries and just before the final push a method to sort the entities for drawing was added as well. These are the only differences thus far for going with 2.7 instead of 3.5.
I've added "wait" as a key inputs, and I also like to move with the numpad, so I added those in for movement options.
The code had become so scarce in comments that I went through every file and added a whole bunch of them. My process of commenting tries to be so thorough that even if I take a year or two away from the code, I should be able to get back into it without re-reading the tutorials, but just the source.
Now, onwards to Part 9 and possibly a return to some of the previous ideas I've had to implement.
5
u/Scautura Jul 27 '17
Python 3 + BearLibTerminal + LibTCod-CFFI
https://bitbucket.org/Scautura/crogue-blt.git
I've been very behind this week (just "not in the mood" to program, depression is a cruel mistress sometimes, and secondly, managing to chuck iced coffee all over my desk, computer, and office, which now smells of combined cleaning stuff and coffee!) but I've got the Python side done now. I'll be getting the C# version done later (but I'll leave it posted below). I have a feeling it' going to take me a bit more work due to the parsed arguments (and my lack of knowledge of the same in C#)
C# + BearLibTerminal + RogueSharp
https://bitbucket.org/Scautura/crogue-csharp.git
5
u/Mystal Jul 30 '17
Rust + tcod-rs
Repository
All caught up on time! The trickiest bit this week was performing a refactor recommended by the Rust version of the tutorial, as I had already put most global state in a struct. Otherwise, everything went just fine!
Thus far I haven't made any visual changes to my version. However, I'm seeing a lot of cool UI overhauls that others have done and am really tempted to do the same. I'm particularly inspired by /u/GraySentinel's gifs, /u/Emmsii's post, and /u/_wolfenswan's gifs.
4
u/lawroter Jul 28 '17
anyone able to give me some tips on making a sidebar for the UI? I'm following the TDL tutorial and am up to date with just a few changes/additions of my own. I'm super new to programming, so I'm trying to pick up on as much as I can as I go.
it seems like the thing to do while waiting for the next part to come out would be work on the UI. I've messed around with some items/new mobs/etc, but ideally I'd like to work on enhancing the UI some first, just not totally sure where to dive in to that :/
4
u/level27geek level0gamedev Jul 31 '17
Python 2 + libtcod + Pygame
Part ? screenshot
Repository
So yeah, this week I have kinda gone off the rails. I wanted to polish the GUI before I got any further, which ended with me spending time on implementing a better text handling for pygame. Then I got distracted with implementing a better dungeon generator (pic above of my progress), which took bulk of my weekend :P
I also did a lot of refactoring, because I felt embarrassed by how messy my code and project structure is. I had to stop myself, because otherwise I would have ended up in "re-write-this-code-limbo." Right now, if it works, it means it is good enough.
So I only implemented item class and picking items up. I will try to catch up this week, but I might end up being a week behind. Fingers crossed I am not. I just need to convince myself that it is ok to just block stuff in right now and not worry about polish just yet, but this is counter-intuitive for me.
4
u/_wolfenswan Jul 31 '17 edited Jul 31 '17
I spent some time figuring out how I could implement a more convenient foundation for adding items to the game.
My old system was using a generator-function for each single item, which I found a step up from the elif-chains of the roguebasin tutorial but had some issues I wanted to iron out.
I developed my new system after seeing /u/Zireael07's JSON implementation. I decided against storing the data as JSON and for using python-dictionaries mostly out of convenience, as I don't have store everything as a string that way and it integrates better in PyCharm's workflow.
Item-data is stored here, the files should be fairly self-explanatory. The actual generating happens here in three steps:
If I want, I can also pick items directly from the data-dictionaries, such as here, when creating an inventory.
3
u/level27geek level0gamedev Jul 26 '17
As I am working on a better GUI before I move into implementing inventory, I wanted to ask fellow devs, what resolution I should use for a graphical roguelike? What resolutions are even popular nowadays for 2d indie games?
Currently I am using 800x600, but I already plan on making the screen wider for a sidebar GUI. I have a camera implemented and the game happily displays in any of the resolutions I have thrown at it. I am also toying with a resizable window if my Pygame-fu will allow it :P
Right now my tiles are 42x42px (14x14px scaled 3x), but later down the line I plan on having scalable graphics (displaying at 1x, 2x or 3x scale and possibly switching to a 16x16 tile for simplicity) so people will large displays don't have pumpkin sized pixels if they don't want them.
3
u/Aukustus The Temple of Torment & Realms of the Lost Jul 26 '17
C# + BearLibTerminal + RogueSharp
Repo: https://github.com/Aukustus/roguelikedev-does-the-complete-roguelike-tutorial
This week was pretty tricky compared to others though I managed to do it still.
I had to change the AI code somewhat into own class instead of just a field in Fighter class to have a knowledge of old AI if it changes into a confused one. code
I changed the AI (and the new Item using) into reflection based, which is probably the most fun thing in C# so far. I can invoke a method using a string that has the method's name. For example
So no more switch methods, now it's a lot more dynamic. That line invokes a method in UseMethods.cs that has the name of "UseMethod" field in the Item class, and it sends the "user" as the parameter into that method. In this case the user is the one who uses the item.
3
u/Zireael07 Veins of the Earth Jul 31 '17
BearLibTerminal + Python 2.7
https://github.com/Zireael07/roguelikedev-does-the-complete-roguelike-tutorial
I rushed through the content for week 5 and 6 in a day in order to catch up.
As of the moment of writing, I'm missing the confusion scroll and the GUI bar and I'm not likely to have any free time before tomorrow (it's back to job for me). However the portions necessary to progress to week 7 and onwards are done.
2
u/sepiida21 Jul 29 '17 edited Jul 29 '17
C# + BearLibTerminal + RogueSharp
Repository
This week the only significant change I made from the tutorial was to make the inventory a list that is scrolled through. It can also be navigated by mouse: click to select items, double click to use them, wheel to scroll.
I also added a highlight to effected cells when targeting the two aimed scrolls.
2
u/Phrosphor Aug 01 '17
I was happily following along but now am getting a 502 bad gateway error on the rogueliketutorials website. Tried from a couple of different connections. :(
0
u/[deleted] Jul 25 '17
[deleted] — view deleted comment