Show Posts
|
|
Pages: [1] 2 3 ... 22
|
|
1
|
Developer / Technical / Re: A c++ approach to snake - 61 lines total - ncurses
|
on: February 14, 2012, 03:50:33 PM
|
B) If the only problem is need of an operator=, what's the problem with writing one? What sensible operator = can you write for a object whose members are all constant? An assignment operator is supposed to alter the left hand object's data, but you can't do that, they're constant. Right, that was silly of me. But still, instead of writing an abstraction layer, it'd probably be easiest just not to const the members... compression! --> switch( ch ) { case KEY_UP: y--; break; case KEY_DOWN: y++; break; case KEY_RIGHT: x++; break; case KEY_LEFT: x--; break; }
--> y += ch==KEY_UP?1:ch==KEY_DOWN?-1:0; x += ch==KEY_RIGHT?1:ch==KEY_LEFT?-1:0;
I think I can't use this as is because the source code above would only move the snake when a key is pressed. The code i gave was incomplete and i didn't test it like one should before posting. Sorry, here's the complete code. while(!quit) { // Input ch = getch();
// Requires #include <utility> static std::pair<int,int> heading( 0, 1 ); switch(ch) { case KEY_UP: heading = std::make_pair( 0, -1 ); break; case KEY_RIGHT: heading = std::make_pair( 1, 0 ); break; case KEY_DOWN: heading = std::make_pair( 0, 1 ); break; case KEY_LEFT: heading = std::make_pair( -1, 0 ); break; case 'q': quit = true; break; default: ; } // Logic snake logic = snakes.front(); int x = logic.x + heading.first; int y = logic.y + heading.second; snakes.push_front(snake(x, y)); I could have used an int[2] instead of a make_pair, but i wanted to change the heading with a single line. Depending on how much you are dealing with coordinates, you may want to write a simple vector class and overload the + and - operators. For example: Vec2 heading( 0, 1 ); switch( ch ) { case KEY_UP: heading = Vec2( 0, -1 ); break; ... }
Vec2 newPos = snakes.front().pos() + heading; // For sake of example, i'm assuming that you wouldn't rename snake to Vec2. snakes.push_front( snake(newPos) );
|
|
|
|
|
2
|
Developer / Technical / Re: A c++ approach to snake - 100 lines total - ncurses
|
on: February 14, 2012, 11:01:37 AM
|
Maybe instead of making snake hold const ints, have const versions of Snake. The point is, int GetX() const{...} is practically not different from const int x; . Just because you write the same thing in other "more sophisticated" code, doesn't really mean it's different. No, it's very different. With const member variables the compiler can't generate an operator =. This breaks a lot of things, in particular std::vector, since vector requires operator =. A) Are you sure that operator equal is required? After all, the fallowing definition works perfectly for me (compiles and runs). struct snake { const int x, y; snake(int a, int b) : x(a), y(b) {} snake(const snake& s) : x(s.x), y(s.y) {} }; B) If the only problem is need of an operator=, what's the problem with writing one? Really, you're pushing writing instance.hiding_layer() on a class that could be just as easily represented by an int[2], std::pair<int,int> or strcut {x,y}. Which it makes code look more OOP, structured, i can't see it as an improvement.
|
|
|
|
|
3
|
Developer / Technical / Re: Best form of IPC for a decentralized roguelike? (linux, maybe windows)
|
on: February 12, 2012, 06:32:52 PM
|
...
I just pulled this out of my ass, but I used a similar structure when creating an audio server that could read from several threads or processes at the same time. You've got to start by defining an internal message format that all comm ports will decode to. This is similar to how brogue abstracts between an SDL, nCurses, and OpenGL renderer. I thought i'd do that or write completely separate clients for each, which would allow different features like pop-up text-boxes in ncurses, drawn over the map, or pop-up windows in SDL or OpenGL.
|
|
|
|
|
4
|
Developer / Technical / Re: Best form of IPC for a decentralized roguelike? (linux, maybe windows)
|
on: February 12, 2012, 06:27:00 PM
|
SOAP is the packaging, and it is XML. However, the whole content of that xml can be a single string with your message if you want it to be. It is not like you have to build a sophisticated xml or something. Example here. That still doesn't look like the script in a D&D game. Anyway, if you don't want it, then indeed pipes ... if you want something simple.  The simplist solution that correctly solves a problem is always the best. You must have a handshake logic(which is basically a client registering into DM) and then a logic for message synchronization like this: 1. client locked in waiting for input 2. server sends current map to client and locks for response 3. client does all internal strategy logic and sends response and locks again and so on. (It's been a while since I haven't worked with piped on linux systems  ) Actually, this is the part i haven't looked into enough. I'm not sure how the executable the player runs will either start the server if it hadn't been already and be the UI. The only difference between the player's client and that of the moster's should be that the player has a UI and no AI (though, both could be hacked in/out) so monster clients should be able to spawn a server equally. Or, i could go the rout of every client not spawned by the server spawns a UI which only draws the screen for NPCs, and accepts input for players then passes that input to the client. Another solution that actually uses sockets underneath is RPC (remote procedure call). ...
That might be interesting to learn about... Not for this project's current state, but in the future. But it'd be easy to just send a large char[] holding more or equal to twice the largest (implemented) command. So... 1. I have heard very good things about http://www.zeromq.org/ . What is neat about that is it is a message passing framework which can be used for IPC or cross-thread communication or network communication. That looks really, really interesting. I especially love their political diatribe in the introduction: http://zguide.zeromq.org/chapter:allDoes it require that the client and server both use its library? It'd be interesting to write/rewrite DMs and clients in different languages, using different libraries. (That way, i could test it out on a working system instead of building the game around it.) 3. I think the basic thing you're trying to do is not a good idea. I do not understand what you are gaining by separating out these components into actually separate processes. The only advantage I see to this is to create the possibility of some of these components running on different machines. And even this is something that only makes sense in certain limited ways (i.e. allowing players to connect their own entities to the world is neat, but having your own hosted in-game elements be on different machines is pointless). If your goal is to have the different components of the game (engine, maps, line of sight) be abstract and separable, that's great! There are several good ways to accomplish this goal that do not require the abstract elements to be in different processes, and putting them in different processes opens you up to an entire class of concurrency-related bugs that there is no justification for living with in a turn-based rpg.
As i said, the goal is to learn, not to create a rogue. Therefore, it's irrelevant whether i fail or succeed, it's flawless or buggy. Also, the idea that a program should be monolithic, bloated, and do everything is one i cannot get behind. Programs should be small, do their thing, and do it well. They should work together with well-defined interfaces that allow parts to be modifiable and interchangeable without leading to system instability. Not only is this a concept that seems to no longer be taught, but no longer fallowed as many of the programs we use are incredibly bloated, monolithic, and do everything, but nothing well. But since i was taught to build monolithic programs and games are rarely done in any other way, i thought it'd be a neat experiment. Besides, the features i've been thinking about, like connecting multiple players, are side-effects of doing it this way, not goals.
|
|
|
|
|
5
|
Developer / Technical / Re: Best form of IPC for a decentralized roguelike? (linux, maybe windows)
|
on: February 12, 2012, 03:34:02 PM
|
|
Looking into SOAP... Wikipedia says "a protocol specification for exchanging structured information in the implementation of Web Services in computer networks." OK, sounds interesting. "It relies on Extensible Markup Language (XML)" OH GOD NO!
I don't know what it is, but XML makes me want to bash my head in with a hammer. It's like a middle-ground between difficult to read for a human and difficult to read for a computer.
But really, i want you to be able to take the log of messages passed between the DM and clients to look like an actual game of D&D with simple messages passed back and forth like "move north" or "cast freeze on koboltA". This type of message is easy for both humans and computers to be programmed to understand.
|
|
|
|
|
6
|
Developer / Technical / Re: Best form of IPC for a decentralized roguelike? (linux, maybe windows)
|
on: February 12, 2012, 10:16:23 AM
|
Yes but client X-1 has to move before client X can so X knows what the whole board looks like before planning out any sort of strategy. I had a discussion with a friend last night about D&D and i think it'll make more sense if i explain it this way: think of the engine is the dungeon master. The players tell the DM what move they want to make and the DM tells them what the outcome was. The analogy could go futher: the character, rule, and (i forget the third'sname) books could be separate databases referenced by the DM. So in terms of IPC, the DM sets the map, the client reads it and strategizes. The map would probably just be a regular file in this case. Then you have many clients which connect to it through a protocol
I don't know how they'll connect yet. No code has been written. I did have an experiment using pipes, but it didn't seem like the right way to do it.
|
|
|
|
|
7
|
Developer / Technical / Re: A c++ approach to snake - 100 lines total - ncurses
|
on: February 11, 2012, 03:30:38 PM
|
There's only one place i'd "improve" (change). switch(ch) { case KEY_UP: dir = 1; break; case KEY_RIGHT: dir = 2; break; case KEY_DOWN: dir = 3; break; case KEY_LEFT: dir = 4; break; case 'q': quit = true; break; } // Logic snake logic = snakes.front(); int x = logic.getX(); int y = logic.getY(); if(dir == 1) y--; // move up else if(dir == 2) x++; // move right else if(dir == 3) y++; // move down else if(dir == 4) x--; // move left to int x=0, y=0; switch( ch ) { case KEY_UP: y--; break; case KEY_DOWN: y++; break; case KEY_RIGHT: x++; break; case KEY_LEFT: x--; break; }
x += logic.getX(); y += logic.getY(); Beyond that, i don't think you can improve the code, but add to it. Maybe some obsticles, a bonus randomly generating fruit? Enemies that try and bump into you, but die if eaten? Also, snake is usually a game played in real time, so you might change timeout(-1) to timeout(some val > 1).
|
|
|
|
|
8
|
Developer / Technical / Best form of IPC for a decentralized roguelike? (linux, maybe windows)
|
on: February 11, 2012, 03:18:45 PM
|
I've got a project to create a roguelike that in some way abstracts the UI from the engine and the engine from map creation, line-of-site, etc. To narrow the focus, i first want to just get the UI (player's client) and engine working. My current idea is to make the client basically a program that decides what one character (player, monsters) will do for its turn and waits until it can move again. So each monster has a client, and so does the player. The player's client prints the map, waits for input, sends it to the engine, and tells the player what happened. The monster's client does the same except without printing the map and using AI instead of keyboard input. Before i go any futher, if this seems somehow an obfuscated way of doing things, my goal is to learn, not write a roguelike. It's the journy, not the destination. And so i need to choose what form of ipc fits this model best. - My first attempt used pipes because they're simplest and i wrote a UI for the player and a program to pipe in instructions such as where to put the map and player. While this works, it only allows one client--communicating through stdin and out.
- I've thought about making the engine a daemon that looks in a spool where clients, when started, create unique-per-client temp files to give instructions to the engine and recieve feedback.
- Lastly, i've done a little introductory programing with sockets. They seem like they might be the way to go, and would allow the game to perhaps someday be run over a net. I'd like to, if possible, use a simpler solution, and since i'm unfamiliar with them, it's more error prone.
I'm always open to suggestions.
|
|
|
|
|
9
|
Developer / Design / Re: Pitch your game topic
|
on: September 23, 2011, 06:18:56 AM
|
|
I'm about to go to bed, but this idea tickled me so i thought i'd jot it down here rather than forget.
Space Biologist! You've convinced NASA to give you a bunch of money, you've constructed your space biology ship, time to set off. You fly around in space and search different planets, rocks, etc. The game ends once you find any signs of any life, after which you devote your life to researching it and dying there, hoping that someone searches and finds signs of your life and brings the research back to earth.
Obviously, it'd be an exploration platformer. The thing is a sign of life might be on screen, but if the player doesn't see it and respond appropriately, the game can't end. It mightn't be a bad idea to put a sign of life on every single rock, but trust that the player won't notice, make it obscure.
|
|
|
|
|
10
|
Player / General / Re: We the People
|
on: September 23, 2011, 12:15:55 AM
|
Through reddit, i've found a good number of petitions. They're not related to games, but since all indie developers probably fall under the title "working class", might they be relevant to us? You can also search all the petitions through google, even if it doesn't have enough signatures to appear on the site. The question i have to wonder is what petition could possibly help us make games? Being indie, it feels like everything we do is outside the spectrum corporate law, economy, or whatever a big game corp might have to worry about. What political or societal issues do we face? We could write a petition to abolish software patents (though probably unrealistic). Increase spending on education/scholarships so many of us can go back or continue our education. There's been discussion of having gov subsidize game development, but i don't see how that'd help us communally. There are a lot of issues with developing for proprietary platforms like the iPhone or Xbox; that might be something to look into. What else?
|
|
|
|
|
11
|
Player / General / Re: We the People
|
on: September 22, 2011, 04:33:15 PM
|
The irony is that only the people with lots of money can afford to hunt down and use all those tax breaks. Everyone else is stuck with just what happens to neatly fall into their laps.
Perhaps the problem is the system of tax breaks in general rather than anything related to games. 2. get someone who knows about videogames to be in charge of software patents related to videogames (e.g. nintendo recently patented massively single player games despite such games already existing and not being made by nintendo) -- this unfairly gives advantage to particular people who manage to get patents for things everyone else has been doing for a while
Likewise, i think the problem is the way software patents are done, related to games or not. Check out Patent Absurdity. Whether or not software patents should exist in the first place, i'm not entirely sure.
|
|
|
|
|
12
|
Player / Games / Re: 2 Vital Tips for Designing & Creating Video Games
|
on: September 20, 2011, 06:40:47 PM
|
So at the end of the day, "women are weaker than men" is true, but it's only based on average ability, not a true measure of strength. The most fair statement is "women have less muscle mass than men." What do you mean by "average ability, not a true measure of strength?" Average ability is all we're really talking about here, since generalizations are based on averages. Also muscle mass = strength (or at the least it's strongly correlated to strength and the two increase with one another, though there are also other factors e.g. neurological strength). There's a difference between the language used and the intent meant. Saying women are weaker than men isn't the same as saying they have less muscle mass because one is a subjective statement (strength can be measured a number of different ways) and the other is objective. The actual mass is actually less, and the maximum liftable weight is therefore less, but you're using your own definition of strength. I might for example consider an 80 pounder strong for lifting 200lb, but i wouldn't think the same if he weighed 200. Maybe that's just my own bias. Not much of a defense of my opinion but i'm having more fun watching this discussion than participating in it.
|
|
|
|
|
13
|
Player / Games / Re: 2 Vital Tips for Designing & Creating Video Games
|
on: September 20, 2011, 12:01:41 PM
|
[...] or the concept that when someone makes a statement such as "women are not very physically strong" they are not saying that all women are not physically strong compared to all men but rather that the average woman is not physically strong or less physically strong compared to the average man [...]
"Women are not very physically strong" is not backed by science as strong is a relative term and your not comparing anything. "Women are not vary physically strong in comparison to men" is what you're talking about. The first has the implication that women are weak, the second implies that women are weaker than men. Since all humans are relatively strong compared to small mammals, weak compared to large animals, some perspective is required. I was curious if i could find how much the average man/woman could lift and i found an interesting article. The results revealed that the male subjects were about 50 percent stronger than the female subjects. That is, the average 10-repetition leg extension for males was 119 pounds, whereas the average 10-repetition leg extension for females was 79 pounds.
This is not a fair comparison of muscle strength, however, because the males weighed almost 50 pounds more than the females on average. To better understand the strength abilities of men and women, we divided the weight they lifted by their body weight. When adjusted for weight differences, the average male completed 10 leg extensions with 62 percent of his body weight and the average female completed 10 leg extensions with 55 percent of her body weight.
While this body weight comparison certainly narrows the strength gap between the sexes, it is still not a completely accurate assessment. This is due to the fact that women have a higher percentage of fat than men.
To better examine pound-for-pound muscle strength between men and women, it is necessary to divide the weight lifted by the subjects’ lean (muscle) weight. When we made this calculation we found that the average male and the average female could both perform 10 leg extensions with about 75 percent of their lean weight. So at the end of the day, "women are weaker than men" is true, but it's only based on average ability, not a true measure of strength. The most fair statement is "women have less muscle mass than men." Bit off topic, but the example you chose doesn't work.
|
|
|
|
|
14
|
Player / Games / Re: 2 Vital Tips for Designing & Creating Video Games
|
on: September 19, 2011, 10:22:05 PM
|
Drawing a woman with unrealistic breasts is one thing but drawing a realistically proportioned woman with a spine that has holes in it is another.
Obviously, some men want to see women making this kind of motion.
I think you're looking for ways to make this seem like some sort of cruelty to women by men. While there may be arguments as such, that's not really the point of this thread. Context: Aside from that, bad anatomy makes art bad. Drawing a woman with unrealistic breasts is one thing but drawing a realistically proportioned woman with a spine that has holes in it is another.
The first part of my post was just saying that it's sexist, nothing more. I don't think an image of an arched spine is cruel to women--it's just pixels. My point in the second part was that it's bad art. IMO, unrealistic breasts can be stylistic, but bad spines, disproportionate hips, impossible bends, and general bad anatomy doesn't make the picture any better. Though, this isn't an art critique topic so that's not the point of this thread either.
|
|
|
|
|
15
|
Player / Games / Re: 2 Vital Tips for Designing & Creating Video Games
|
on: September 19, 2011, 08:48:45 PM
|
Pretty much. Just about all of those images people posted are meant to convey motion. And that 'turning sideways so you see T&A at the same time HOW CAN ANYONE DO IMPOSSIBLE' pose is something people do on a regular basis when they are turning to look at something behind them and don't want to rotate their whole body.
But the question is why are most examples of this women? If it was purely about showing motion, there wouldn't be a sexist bias about whom is in the center frame. Aside from that, bad anatomy makes art bad. Drawing a woman with unrealistic breasts is one thing but drawing a realistically proportioned woman with a spine that has holes in it is another. Obviously, some men want to see women making this kind of motion.
|
|
|
|
|