Author Topic: beyond python and curses  (Read 13669 times)

ebenezer

  • Newcomer
  • Posts: 4
  • Karma: +0/-0
    • View Profile
beyond python and curses
« on: February 22, 2016, 09:55:13 PM »
Hi everyone, I was wondering if you could give me some advice.
I learned a bit of python for work (I'm a scientist and I needed to manipulate big DNA sequence files). This happened >4 years ago, and with that little programming knowledge I started and soon abandoned 4-5 projects for roguelike games. But finally, in the past 3 months, I managed to put together a small game I'm not ashamed of (apart from the title - "Merry Farmer, Demon Slayer").
I have always used python3 + curses library. Now I would like to find an alternative because:
- I would like a slightly better interface (a few more colors, basic sprites)
- python+curses works only in mac, and:
         - portability is very limited
         - my old laptop is dying on me
Is there a python library equivalent to (or better than) curses I could use, that works in windows or is cross-platform?
A friend suggested unity, but I don't have time to learn a new scripting language, and it seems overkill for what I have in mind.
Any suggestion is more than welcome.
Cheers!

elwin

  • Rogueliker
  • ***
  • Posts: 96
  • Karma: +0/-0
    • View Profile
    • Roguelike Gallery
Re: beyond python and curses
« Reply #1 on: February 22, 2016, 11:40:24 PM »
If you want to make a basic graphical interface, there's Pygame, which is relatively simple and highly cross-platform.
Roguelike Gallery: play Rogue online.  SSH or in browser.

akeley

  • Rogueliker
  • ***
  • Posts: 348
  • Karma: +0/-0
    • View Profile
Re: beyond python and curses
« Reply #2 on: February 23, 2016, 12:02:28 AM »
"Merry Farmer, Demon Slayer"

It`s actually not too bad, on condition that "Farmer" is a surname.

Kyzrati

  • 7DRL Reviewer
  • Rogueliker
  • *
  • Posts: 508
  • Karma: +0/-0
    • View Profile
    • Grid Sage Games
    • Email
Re: beyond python and curses
« Reply #3 on: February 23, 2016, 02:50:27 AM »
@ebenezer: libtcod w/python sounds perfect for your situation. There's a complete tutorial here to get you started.

tuturto

  • Rogueliker
  • ***
  • Posts: 259
  • Karma: +0/-0
    • View Profile
    • pyherc
Re: beyond python and curses
« Reply #4 on: February 23, 2016, 07:23:37 AM »
Might be a bit of overkill, but I have had fund with PyQt (https://riverbankcomputing.com/software/pyqt/intro). There's also PySide (https://wiki.qt.io/Category:LanguageBindings::PySide), with slightly different API (very close to PyQt still though) and licensing. It's portable, fast and generally pretty nice.
Everyone you will ever meet knows something you don't.
 - Bill Nye

Quendus

  • Rogueliker
  • ***
  • Posts: 447
  • Karma: +0/-0
  • $@ \in \{1,W\} \times \{1,H\}$
    • View Profile
    • Klein Roguelikes
Re: beyond python and curses
« Reply #5 on: February 23, 2016, 03:58:20 PM »
Libtcod+Python is probably your best option.
Bearlibterminal+Python is a better library for tile-based displays, but it's still making very slow progress towards mac support.
Curses+Python can be made to successfully run on windows and linux thanks to pip, but that doesn't solve the problem of packaging your games for those platforms. There are tools like py2exe, but they're a lot more hassle to use than jist zipping everything up.

ebenezer

  • Newcomer
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Re: beyond python and curses
« Reply #6 on: February 23, 2016, 09:19:32 PM »
Thanks to everyone, I'll look both into libtcod and pygame. If I understand well, with both I can in principle switch easily from mac to windows, if necessary.

And no, farmer is not a surname. You actually grow stuff and then kill demons by throwing beetroots at them.

tuturto

  • Rogueliker
  • ***
  • Posts: 259
  • Karma: +0/-0
    • View Profile
    • pyherc
Re: beyond python and curses
« Reply #7 on: February 24, 2016, 07:08:28 AM »
And no, farmer is not a surname. You actually grow stuff and then kill demons by throwing beetroots at them.

I'm loving this :D Is that available somewhere? I would like to give it a try.
Everyone you will ever meet knows something you don't.
 - Bill Nye

ebenezer

  • Newcomer
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Re: beyond python and curses
« Reply #8 on: February 24, 2016, 04:16:55 PM »
Ok, after a bit of reading and tampering, I decided to switch to python + pygame on a newer windows laptop.
I have started reading a bit of pygame documentation, but could anyone give me a few suggestions about the functions/modules that are most useful for roguelikes? I guess the text renderer, for instance.

(Why pygame and not libtcod? Well, I am also trying to teach some coding to my daughter (now 7yo). We are having a lot of fun with scratch at the moment, but maybe next year I can introduce her to something "serious" and python+pygame seems a good combo. This is just to say that I have nothing against libtcod in particular)

@tuturto: I said I am not ashamed of the game, but it does not mean I feel ready to share it with a community of seasoned developers :)
I always wanted to make a roguelike, and I always wanted to make a farming game. When I was looking for a "magic" (in the widest possible sense) system to include in the roguelike game, I chose to turn roots, nuts, and berries in the rough equivalent of bolts, potions and force fields. Every now and then you have to go back to your vegetable patch by the dungeon entrance to restock. [and if anyone thinks this is a fun idea, feel free to steal it if you can make a fun game out of it]

Omnivore

  • Rogueliker
  • ***
  • Posts: 154
  • Karma: +0/-0
    • View Profile
Re: beyond python and curses
« Reply #9 on: February 24, 2016, 10:27:39 PM »
I have started reading a bit of pygame documentation, but could anyone give me a few suggestions about the functions/modules that are most useful for roguelikes? I guess the text renderer, for instance.

I've been using pygcurses lately, it sits atop pygame and gives you a curses-like text oriented interface

elwin

  • Rogueliker
  • ***
  • Posts: 96
  • Karma: +0/-0
    • View Profile
    • Roguelike Gallery
Re: beyond python and curses
« Reply #10 on: February 25, 2016, 01:57:30 AM »
With pygame, you'll be using Surface.blit() a lot.  Font.render() if you're using ASCII, image.load() for graphics.  You'll need to learn how to use Color objects and the event queue to do anything interesting.  You may find the basic geometry in the draw module helpful.

Pygame has a lot of other features that you probably won't need.

I did not know about pygcurse.  I will add it to my list of potentially handy items.
Roguelike Gallery: play Rogue online.  SSH or in browser.

ebenezer

  • Newcomer
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Re: beyond python and curses
« Reply #11 on: February 26, 2016, 05:49:17 PM »
@elwin
Thanks for the suggestions.
To handle events, I plan to use event.get() blocking everything but QUIT and KEYDOWN events. I really like that events have an unicode value, which allows to easily handle 'a' as well as 'A' (shift+a).
I will use ASCII - I like the old school feeling of ASCII roguelikes - and making decent sprites would take me so much time it's not even worth trying.