1
Programming / Re: Basic game programming concepts
« on: October 15, 2013, 02:15:32 PM »Quote from: Quendus
To get help with problems in code and software, it's best to provide specific information about what went wrong - no-one can say much about something that "doesn't work", but if you say what doesn't work, when, whether there was an error message at runtime or compile time, what the error messages were, etc., then often there will be someone who's had a similar problem in the past.
You're totally right. I was just thinking it might not be an ncurses thing, but rather a problem of the implementation itself. So maybe someone who never used ncurses might be able to help as well.
This is the actual error that I don't understand:
I used getch() to capture the keyboard input, however it will only return "Press 'q' to quit", even when a key is pressed that I defined to do something else (like the arrow keys or u, h, n, j).
Even though I implemented while (key != 'q') in the function Action(), the program terminates after the second key is pressed.
Quote from: Vanguard
Making "hero" a tile type is a Real Bad Idea. It's confusing and it'll lead to more than a few problems. Instead you should have heroX and heroY integers to track their location. Better yet, make arrays of integers to store the x and y locations of every man, animal, and monster in the dungeon.
I worried about that, too. Would it make sense to write a function like GetLocation() that returns both coordinates? I actually wanted to do this at first, but I didn't really know how to do that (if it makes sense, I will again try to implement it by myself), so I chose the simplest thing I could think of.
What do you mean by arrays of integers? I would have rather thought about a list or a 2-dim. vector. Could you give an example?
Quote from: Vanguard
Even though programming a game is about manipulating abstract data, imo the best way to do it is to think about everything in terms of concrete nouns and verbs (with objects and variables being nouns and functions/methods being verbs). The tile array describes different segments of the building the game is taking place in. That description doesn't fit the hero, so he or she shouldn't be tracked by that variable.
This is very interesting.
I've never thought like that. I admit that I rather have a hard time to actually imagine variables and functions like this as I still think of (tile) arrays as tensors rather than actual maps.
But as I'm still a beginner with game programming, I'm not beyond hope, I think.