I've got the urge to start programming again, so while I'm busy with wrapping up study I'm going to have a break now and then to continue learning Python.
I think I'll learn best if I attempt to make some projects, so I'm looking into making some ASCII games using Python's curses module. I don't particularly have anything in mind just yet - I could fish out some ideas for roguelikes I've had, but I don't particularly want to get stuck on a massive project when I'm so busy. I think I'll just start with some simple A.I. tests to see how well curses in Python can be used to prototype ideas. No serious planning will be done - I'm doing this as a break after all, so I don't want to burn out my brain when I need it for other things.
The screenshot above shows my first attempt at getting curses running and seeing what it can do. So far I've seen that it can:
- Output the basic ASCII characters (0-127).
- Output some extended line based characters (shown above): handy for windows and games.
- Checked the colour range: there's eight possible colours available based on full or no R, G and B. That means red, yellow, green, cyan, blue, magenta, white and black. You can have any combo for the text and background, although I'm mainly fond of black in the background unless you're doing highlighting.
The bits I'm not too sure about are what's going on with that square at the bottom-right - the loop shouldn't have conked out when drawing the sides there. Also under Mac OS X it doesn't appear that the cursor will vanish when curses is active (you can see it after the numbers). I've made the documented function call and it doesn't seem to do anything. I guess the best I can do it move it to the bottom corner every time I do a screen refresh. Annoying.
To start with, I'm going to wrap curses in my own little package; that way if I ever need to replace it with something else, like a SDL equivalent that uses bitmapped characters, then it'll be easy. That shouldn't be too hard to do in Python, and gives me a chance to make my first package.