# Python game design

This topic is 2591 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I've been studying programming from Java to C++ and now to Python. While I have never implemented anything I've learned I've always wanted to but have never had the ideas on what to do or how to do it. Now that I do I've found this language, Python, and like the simplicity and power behind it.

I've learn many concepts of programming and with C++ it was always hard to work with just the concept because of the language complexity, but with Python it seems a lot easier to work with.

So my idea:

The game is going to be made with the ASCII characters so basically it will be a rouge like. The major idea behind it is to be similar to Adventure mode in Dwarf Fortress but that's really the only comparison I'm making. Since this will be my first time working with Python I know to start small and work my way up.

1. Game screen generation + player character '@' placement
No movement will be implemented first just the screen and to have the player appear on screen.
2. Of course then movement through keyboard input.
3. I'll need to have an NPC character generate as well in order to test the next addition.
First NPC will probably be simple. I'm a little worried about how to have this character move around freely. Would I have to create AI before NPCs could be implemented?
4. I want the player to have the ability to interact with things in multiple ways. The most basic being through combat.
Combat from the beginning will simply be the ability to attack and maybe a percentage chance to block.

That's really the basic bare-bone set up for character control I have figured.

5. Simple Dungeon. Like most if not all rouge-likes they have a dungeon generator.
I'll probably find a good example with a generator and look over it. I wonder if I should just hand craft a sort of dungeon first before delving into a generator simply for the fact of expanding other game elements.

I plan to expand on pretty much every simple idea to add to it once I know how to work with it.

Interaction : Instead of just combat I'd like to include other interactions as well.
- talking
- examine
- magic

Advanced Combat : One thing I love about Dwarf Fortress Adventure mode is the combat. While I don't think I'd like to go that complex, at least not now, I'd like to have the ability to,
- attack specific locations on the body
- have an attribute system that effects every part of battle from damage, chance to block, attack and movement speed, reach of attack, and whatever else is involved with the fighting.
- add in ranged weapons like bows
- have weapon types effect the attack reach, damage, and have your skill with the weapon effect all that as well.

NPC Generation : Instead of just having the random enemy NPC generate I'd like to have friendly or neutral NPCs as well.
- Talk with friendly NPCs, possibly receive quests or have an NPC become your companion.
- Enemy NPCs have advanced combat skills meaning they can and will fight like you can, choosing body parts to attack not completely randomly but maybe (though this would involve a lot of variable comparison) attacking depending on the efficiency of the attack depending on their attributes, weapon, etc.

Dungeon Generation : While dungeons are all fine and good I'd like to be able to create both interior and exterior locations.
- I'll start with an all interior dungeon generator then eventually work my way to having it generate exteriors as well. Have rivers, lakes, mountains, etc. I'd really limit this though because I know that I could lose all my time trying to make this as realistic as possible. I'm not looking to create a whole world (at least not yet) like Dwarf Fortress does.

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

That there is basically the idea I have for this project. It will grow and develop as I work on it of course but I'm just looking to get input on how I might go about all this. Though that's a pretty broad question.

I'd really appreciate if someone or a few people could go through these things I've explained and either link me to sites that would help with this sort of thing or explain what ways I will code these mechanics.

I've read this and it is helpful but I'd rather not follow something like this step by step because I can't learn like that. I learn better finding things out on my own or with help from others, this way I feel as though I'm just copying and pasting the code and doing nothing myself.

One issue I've been running into as I tried starting with the code last night is that I can't get python to run through notepad++. I've tried a few different things like having the Run... shortcut set to the "$(FULL_CURRENT_PATH)" but a cmd window pops up and closes almost instantly and all I can make out is that I see the word syntax. I know the code I was writing was correct as well and I also copied it straight from the tutorial. My final question. I read somewhere that Python is great for scripting but it may be necessary to write a games engine in something like C++. I was wondering how this would work. I'm also wondering what would an engine for this sort of game I've explain above me composed of. Really appreciate any help I get seeing as this is such a long winded post. Thanks EDIT: Could someone refer me to a good python book? I'm looking on amazon right now but I'm looking for a good reference book and or one that explains the concepts and their use in python. Thanks #### Share this post ##### Link to post ##### Share on other sites Advertisement Really appreciate any help I get seeing as this is such a long winded post.[/quote] First, no worries. I tend to be overly verbose myself =P Second, it's rogue. Sorry, many years playing RPGs has made it a reflex. "rouge" is the French word for "red" and commonly associated with makeup. My final question. I read somewhere that Python is great for scripting but it may be necessary to write a games engine in something like C++. I was wondering how this would work. I'm also wondering what would an engine for this sort of game I've explain above me composed of.[/quote] Frankly, increasing hardware (better processors, more RAM) and deep research and advances in interpreted languages have deprived C++ of it's once-booming thunder. That said, Python isn't known for being a speed demon but it generally gets the job done, with it's extensive library providing ample compensation for any performance loss. The actual performance you'll get will vary depending on the version of Python you choose to use (Python 2, Python 3, Jython, IronPython, etc. ) and whether you compile it or not but for something like this I don't see any significant penalty other than that of poorly constructed user-made algorithms. Please note that I am not "voting" for one or the other. They each have their merits, you'll need to decide based upon which language you feel delivers the features you'd like the best. That said, if I had to chose I would opt for Python - it comes with the curses library making text-related operations significantly easier and allowing you to easily add a splash of color, should you choose. There's also dedicated text-based UI libraries (for Python) that you can use as well. Furthermore, you can always intermix [Python and C++] should you find something that needs that form of optimization. If you're looking for an engine written mostly in Python, with backings to C++ for optimized portions, you might look into Panda3D. I realize, technically, it's not what you're after - 3D is far more complicated than text batching - but in a lot of ways you could substitute functionality. All that really changes is spatial representation and the rendering pipeline. One issue I've been running into as I tried starting with the code last night is that I can't get python to run through notepad++. I've tried a few different things like having the Run... shortcut set to the "$(FULL_CURRENT_PATH)" but a cmd window pops up and closes almost instantly and all I can make out is that I see the word syntax. I know the code I was writing was correct as well and I also copied it straight from the tutorial. [/quote]
I would get a dedicated IDE or just use Notepad++ to edit your files and have the command line handy so you can do it yourself. Off the top of my head, it might be the Python version of the tutorial vs. the one on your system. Make sure you've got it set up so you can see the compilation output - it's been awhile, but it should be in the View settings somewhere. You might need to enable a split view. For whatever reason, I never got Notepad++ to obey me, hopefully someone else can help you out with that specifically.

I'll need to have an NPC character generate as well in order to test the next addition.
First NPC will probably be simple. I'm a little worried about how to have this character move around freely. Would I have to create AI before NPCs could be implemented?[/quote]
Eh, not necessarily. If by "move around freely" you mean "do something" then just have an "update" method and pass it an array of functions that do something. As an example: {move(3), turn(AROUND)} and have it start at 0 and iterate to the next instruction every x amount of time and loop. Implement methods to check to see if it can move to a given location so you don't have any bounds issues.

Of course, first verifying that your NPC shows up without doing anything is usually beneficial.

I'll probably find a good example with a generator and look over it. I wonder if I should just hand craft a sort of dungeon first before delving into a generator simply for the fact of expanding other game elements.[/quote]
I prefer light hand-crafting to get a feel for how I want the dungeon format to look and to ensure the game currently displays things correctly. As for random generation, there are indeed a number of resources and examples to use. A quick Google search will yield quite a number of them, for instance this looks simple enough to implement.

Dungeon Generation : While dungeons are all fine and good I'd like to be able to create both interior and exterior locations.
- I'll start with an all interior dungeon generator then eventually work my way to having it generate exteriors as well. Have rivers, lakes, mountains, etc. I'd really limit this though because I know that I could lose all my time trying to make this as realistic as possible. I'm not looking to create a whole world (at least not yet) like Dwarf Fortress does.[/quote]
I'm sure it would be pretty easy to modify your generation algorithm to accommodate such things. Mountains and rivers are just larger walls while "large outdoor areas" are just larger rooms.

I'm just looking to get input on how I might go about all this.[/quote]
Looks like you have a pretty reasonable start. If you don't learn from tutorials then the best thing to do is to jump into it. Good luck to you.

Appendium: there are a number of Open Source "rogue-likes" you might wish to inspect should you require inspiration.

##### Share on other sites
Thank you very much for taking the time to read all that ^^.

I would get a dedicated IDE or just use Notepad++ to edit your files and have the command line handy so you can do it yourself. Off the top of my head, it might be the Python version of the tutorial vs. the one on your system. Make sure you've got it set up so you can see the compilation output - it's been awhile, but it should be in the View settings somewhere. You might need to enable a split view. For whatever reason, I never got Notepad++ to obey me, hopefully someone else can help you out with that specifically.[/quote]

I actually missed this which was right on the tutorial page. Doing this worked for me.

Eh, not necessarily. If by "move around freely" you mean "do something" then just have an "update" method and pass it an array of functions that do something. As an example: {move(3), turn(AROUND)} and have it start at 0 and iterate to the next instruction every x amount of time and loop. Implement methods to check to see if it can move to a given location so you don't have any bounds issues.

Of course, first verifying that your NPC shows up without doing anything is usually beneficial.[/quote]

Well for the game, I was planning on just doing a turn-based style so how then would I implement the movement? Same as you suggested? I'd think that the character movement, it being a rogue-like (thanks for correcting my spelling) wouldn't need to be advanced like in a 3D game where the movement is important. I assume it would be just fine if for someone holding a small weapon; sword, mace, axe; that they'd close in on you, when holding a bow they'd keep distance until they switched to a dagger or small weapon then the movement AI would change and with a pole-arm they would simply keep you out of range.

Would this be accomplished by having an array of variables that check and determine which AI to operate on? I'd think if the check had to be run each turn, movement, that it would slow down the time between turns being loaded.

I prefer light hand-crafting to get a feel for how I want the dungeon format to look and to ensure the game currently displays things correctly. As for random generation, there are indeed a number of resources and examples to use. A quick Google search will yield quite a number of them, for instance this looks simple enough to implement.[/quote]

Actually after I posted this my brother suggested doing it by hand. I figured I could create a separate file with a hand crafted dungeon simply for testing out the mechanics and adding things through there before I implemented them into a game with generation.

1. 1
2. 2
Rutin
16
3. 3
4. 4
5. 5

• 26
• 11
• 9
• 9
• 11
• ### Forum Statistics

• Total Topics
633702
• Total Posts
3013451
×