Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - Hashiba

Pages: [1]
1
Programming / [Python] Looking For Some Good Examples
« on: February 05, 2016, 07:34:57 PM »
I'm yet another new Programmer+Pythoner+roguedev that has been lurking around these forums for the last week or so after finishing the (in)famous python + libtcod tutorial.  I've been giving some thought about where to go next, and there is some temptation to just keep adding onto that existing code.  However, a fairly large part of me feels that in order to really know how to code, I have to code, not just follow along a tutorial or merely extend some existing logic.  When I combine this thought with the fact I really don't like the way the tutorial code is written (all one file, globals all over the place, etc.) I decided the next stage for me is to essentially start from scratch with my own code, purposefully implementing things differently to both make certain I understand the logic as well as become more comfortable with Python.

I set out to attempt to follow a lot of these "best practices" I keep reading about and try a strict OOP style.  So far I've recreated the basic "@" walking around the "." tech demo while borrowing as little from the tutorial as possible (there is some common code due to libtcod, but I tried to build all of mine from the docs rather than the tut).  I'm getting ready to move to the next steps, but this also means I'll be adding more classes and possibly files and I'm purposely committing the grave sin of trying to factor before I code.  I mean, I know I can code the next features, but I'm wanting to learn better ways to be coding them.  Inheritance with relatively dumb base classes? Composition on top of relatively smart base classes?  How big should my core "Engine" class be allowed to get? I have a lot of questions that I'm sure don't have really concrete answers, but I'm sure that there *are* answers.

I keep reading the advice here and elsewhere to "look at *good* code" and follow examples of how to structure things, and how to pass information between the classes, but there is a hitch.  I am a new programmer, so despite the fact I can find 100s of python games on Github, I have no idea if I'm looking at *good* code to learn by example.  A lot of the projects I have looked at, especially 7DRLs look like they have some terrible practices in use.  I found some with circular imports and others with dozens of global variables (not counting CONSTANTS), and this just doesn't help me learn to be able to manage a large project.

What I'm hoping for is this:  Will any of you be so kind as to point me to a (couple of) roguelike project(s) that are written in Python, use OOP and are written in what would reasonably be considered *good* code?  Obviously there are many styles of coding, but there must be a few projects that most reasonably agree on are well written.

2
Programming / Python FOV Help
« on: May 22, 2012, 10:02:27 PM »
Hi folks!  I've been dabbling at learning to program and have set my sights on a roguelike.
I've been half-following the  "Complete Roguelike Tutorial using Python and libtcod", except I'm not using libtcod.  I'm using Python 3.2.3, Pygcurse and Pygame.
Call me crazy, but I figure converting a tutorial to a new library is a better learning experience than just copying code and hoping I understand it.

Its working so well I am stumped!  I am not experienced enough to write my own FOV algo and obviously I can't used the ones included with libtcod.  So...

I found a Python permissive FOV implementation on RogueBasin @
http://roguebasin.com/index.php/Permissive_Field_of_View_in_Python

Well I can't make it work!  Specifically it does something I am not familiar with.  You call to calculate FOV with a fuction call that takes 7 arguments, 5 or which are variables and 2 are "user functions".  The variables make sense but I have no idea how you pass a function as an argument to a function.  I've tired Google and some Python documentation without any luck.

If someone can be kind enough to enlighten me, I can finish up the basic 'engine'.

Thanks in advance!

P.S. I'm not really stubborn about what type of FOV I use at this point in my Roguelike career.  Any helpful adivce on another implementation would also be helpful.

Pages: [1]