Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: OriginsRL: ITT: Moving an @ around in a box  (Read 1119 times)

Mephisto

  • Bay Watcher
    • View Profile
OriginsRL: ITT: Moving an @ around in a box
« on: July 29, 2011, 02:34:33 am »

Origins Devlog

I've started a new little roguelike project. So far, I'm working solely with Python 3 and curses (Damn Arch Linux for fostering my wish to have the latest and greatest and damn me for wishing to use the newest when the newest has few fully-functioning libraries yet).

I just ran through the whole "making an @ move around the screen" bit. I've done it before, but never in Python and never using curses, always libtcod or another library. I had a few moments of stupidity, as I outlined in my blog.

Note: various sources tell me Python's version of curses works in Windows, so you should be able to play if you want. Why you would want to simulate being stuck inside a large room I don't know, but you can do it anyway. Fret not about the sorry state of my current code; it will all be disposed of when I learn all I can from the crappy demo I've got. I'll be using good practices, a proper OO design, good MVC for when libtcod and/or pygame get updated, proper unit testing, Mercurial, all that fun stuff.

My project is tentatively named "Origins," as the blog post can attest. It's fitting. As the game starts, you'll be alone in the world. Think of Terraria without the newbie guide. You'll be able to gather resources, build things, create junk, alter the world, and after the player reach an as-yet-undetermined milestone, people may decide to begin moving in. These people won't just appear, but will be people from other locations on the map. Surviving is easier when you're not the only one. If the player finds someone in his travels and that person comes to like him enough, the player may be able to persuade them to come live in his up-and-coming village.

My grand scheme is to make the various recruited NPCs and creatures the player may run into seem to be alive. NPCs won't stand in one spot all day spouting the same lines but will move around. Shopkeeps leave for lunch, shops will be closed at night, pubs will be more crowded in the evening, stuff like that. The shops I mentioned won't magically acquire goods and cash - instead, whatever they sell must first be acquired by them. Players won't be the only entities using the shops. Wandering creatures will react appropriately to the player's presence. If the player is heavily armored or such, intelligent creatures may be wary (unless they think they can take him). Wildlife will always be skittish (barring special circumstances) and will dash away at the drop of a hat. If a creature, intelligent or not, knows more of its kind are around, is on good terms with them, and it plans to attack the player, it won't attack right away but will signal its fellows to join in.

Another feature that's been floating around in my mind will only come up in the distant future, if at all. I would like to give the game a kind of local multiplayer. If you've played Animal Crossing, you know what I'm talking about. Players could only play one at a time but would be sharing the same world. Whether or not they would start in the same location or would have to find each other first, I'm not sure.

Origins will be heavily based on skills and crafting. If the player wants something in the beginning, he has to make it first. Later on, this need may be somewhat lessened by NPC gatherers, artisans, and sellers.

Constructive criticism, ideas, and offers to help (when I complete something tangible and I'm back to using my uni's internet) are all welcome.
Logged

Mephisto

  • Bay Watcher
    • View Profile
Re: OriginsRL: ITT: Moving an @ around in a box
« Reply #1 on: July 30, 2011, 02:19:07 am »

I've got a new blog post up - http://miscgeekery.wordpress.com/2011/07/30/python-3-my-brain-why-does-it-hurt/

I'm stuck. I'm certain it's just my currently dead brain that's causing me problems, but I can't for the life of me find what's wrong with this code. Help would be greatly appreciated.
Logged

Antsan

  • Bay Watcher
    • View Profile
Re: OriginsRL: ITT: Moving an @ around in a box
« Reply #2 on: July 30, 2011, 03:27:17 pm »

Quote
Code: [Select]
for x in range(orig_x, size_x):
Shouldn't this (and all the other instances if this pattern) be
Code: [Select]
for x in range(orig_x, orig_x+size_x)?

I don't know python and I didn't try to understand what you're doing, but I guess this is the mistake.
Logged
Taste my Paci-Fist

Mephisto

  • Bay Watcher
    • View Profile
Re: OriginsRL: ITT: Moving an @ around in a box
« Reply #3 on: July 30, 2011, 03:41:38 pm »

Quote
Code: [Select]
for x in range(orig_x, size_x):
Shouldn't this (and all the other instances if this pattern) be
Code: [Select]
for x in range(orig_x, orig_x+size_x)?

I don't know python and I didn't try to understand what you're doing, but I guess this is the mistake.

Many thanks. That didn't fix it, however. In my test code orig_x and orig_y were zero, so it didn't matter whether or not they were added to the size.

It matters not. I'm rewriting certain crappy parts of my code (read: the whole thing) anyway.
Logged

Red

  • Bay Watcher
    • View Profile
Re: OriginsRL: ITT: Moving an @ around in a box
« Reply #4 on: July 30, 2011, 03:46:13 pm »

Quote
Code: [Select]
for x in range(orig_x, size_x):
Shouldn't this (and all the other instances if this pattern) be
Code: [Select]
for x in range(orig_x, orig_x+size_x)?

I don't know python and I didn't try to understand what you're doing, but I guess this is the mistake.

That is a mistake but I don't think its causing the problem he's having(Since he setting orig_x and orig_y to 0).

I also posted in a comment on the blog but I'll put it here too:

The problem doesn’t seem to be with the loops or the if statements(I recreated them in part of some of my own code and they worked).

It might have something to with how you are declaring map_tmp(which to be honest confuses the crap out of me, though it may be because I haven’t worked with python for a while) or how it is used after it is returned.
Logged

Mephisto

  • Bay Watcher
    • View Profile
Re: OriginsRL: ITT: Moving an @ around in a box
« Reply #5 on: July 30, 2011, 04:00:30 pm »

Quote
Code: [Select]
for x in range(orig_x, size_x):
Shouldn't this (and all the other instances if this pattern) be
Code: [Select]
for x in range(orig_x, orig_x+size_x)?

I don't know python and I didn't try to understand what you're doing, but I guess this is the mistake.

That is a mistake but I don't think its causing the problem he's having(Since he setting orig_x and orig_y to 0).

I also posted in a comment on the blog but I'll put it here too:

The problem doesn’t seem to be with the loops or the if statements(I recreated them in part of some of my own code and they worked).

It might have something to with how you are declaring map_tmp(which to be honest confuses the crap out of me, though it may be because I haven’t worked with python for a while) or how it is used after it is returned.

I just replied to my post but figured I should also reply here. The problem was with how I was declaring map_tmp. As it stood, I thought my code would create a list of lists, size (size_y, size_x), but it did not. If I declare map_tmp correctly, say, with
Code: [Select]
def room(orig_x, orig_y, size_x, size_y):
    map_tmp = []
    for y in range(orig_y, orig_y + size_y):
        map_tmp.append([])
        for x in range(orig_x, orig_x + size_x):
            map_tmp[y].append('.')
... before going into the big loop in my previous example, everything is just fine. Now that this works, I may reuse parts of it.
Logged