Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 25 26 [27] 28 29 ... 72

Author Topic: The Roguelike Development Megathread  (Read 245753 times)

Rsugar

  • Bay Watcher
  • Newbie Programmer\Graphics Artist
    • View Profile
Re: The Roguelike Development Megathread
« Reply #390 on: July 01, 2009, 05:49:51 pm »

Hi there! I've been playing DF for a couple of years now and came upon this thread about a month ago. In that time I was able to go from scratching my head in confusion to this:



and then to this:



I'm using C++, PDcurses, and the Devshed C++ compiler.

So far, so good right? However, the drawing functions I have right now can only do squares, and I have to manually add openings. I would love to be able to randomly generate maps, and so on so fourth, but this is a real challenge. I have had no prior understanding of c++ until last month. I have a bit of experience with PHP, MySQL, HTML, and Flash, so I was able to grasp onto this language a bit more easily than most becuase of my understandings of programming and scripting langauges.

However, this language is still a challenge. I've tried coding a draw function in which I can load a hard coded Array map, but that failed and I wasn't able to resolve my issues. Also, when I undid all of that back to the point that the second screen shot shows, I had forgotten to save a backup copy of the hard coded map feature.

If anyone knows and random/procedural c++ generation tutorials, and could post them here(I haven't seen any in the op or in the thread...) that'd be great.
 
Logged
"Hey baby, Want to see my mine shaft?"
"oooh...is it long and rough?"

Sowelu

  • Bay Watcher
  • I am offishially a penguin.
    • View Profile
Re: The Roguelike Development Megathread
« Reply #391 on: July 01, 2009, 05:57:01 pm »

I can tell you that map generation is a nice big challenge.  I don't have any examples onhand, but if you take a look at what Nethack and ADOM and Angband, etc, maps tend to look like...well, they start with rooms, then they define the exits from those rooms, and then they start linking up exits.

If you want to link the west exit of the west-most room, with the east exit of the east-most room, your pathfinding algorithm needs to know how to avoid going through the walls of existing rooms to get where it's going.  So do that.

- Make a bunch of rectangular rooms that don't overlap and aren't too close to each other
- While all rooms are not accessible from other:
-- Pick two rooms that aren't in the same graph
-- Randomly pick a spot along the wall from both rooms, which is not already in use, is not adjacent to an existing door, etc
-- Pathfind from one of those to the other, turning solid stone into corridor as you go
-- Put doors in the walls, or don't, or make secret ones
- Add a couple more connections just for fun
- Add up-stairs and down-stairs in rooms, etc...

Now, it's totally okay if corridors intersect.  They can ignore each other completely, that's fine!  You'll end up with occasional 2-wide corridors, but it works for Nethack.  If you want a slightly more complex algorithm, then you can add nodes to the corridors you make--that way, you can pathfind from a room to an existing corridor node, and you wind up with Ts and stuff in corridors.

You can also start making non-square rooms, as long as your program knows how to pathfind around them, and knows how to tell which wall segments are acceptable to put doors in!
Logged
Some things were made for one thing, for me / that one thing is the sea~
His servers are going to be powered by goat blood and moonlight.
Oh, a biomass/24 hour solar facility. How green!

magellan

  • Bay Watcher
    • View Profile
Re: The Roguelike Development Megathread
« Reply #392 on: July 01, 2009, 06:02:08 pm »

Mapgeneration!
One of the things about making roguelikes that are seriously fun! :D

Ok: some of true and tried basic approaches in a very rough form

Draw X random rectangles
Connect with lines and make sure that each rectangle has at least 1 connection

Put room in center
 - from here
select random wall
make corridor
make room at end of corridor
- repeat until full

take whole map, chose x or y axis randomly, random value. make 2 rectangles. Repeat until minimum size of rectangles.
Draw room into each rectangle and connect rooms

Ok, hope that helps a little. I have not the slightest inkling on programming in C. So i can't really point you anywhere in that sense. www.roguebasin.com has some neat articles on all aspects of RL programming though.

Hardcoding a map i can give you one (obvious) hint: Make a program that writes the mapfile. Then do the same thing, only backwards for the reading.
Logged
Prospector, my space exploration roguelike:
http://code.google.com/p/rlprospector/

Rsugar

  • Bay Watcher
  • Newbie Programmer\Graphics Artist
    • View Profile
Re: The Roguelike Development Megathread
« Reply #393 on: July 01, 2009, 06:04:25 pm »

Pathfinding

oh man, I haven't even gotten to that yet.
I'm really, really new to c++, and programming in general. Most of my prior experience was messing around with other's source code in php. (I know I might sound a bit hypocritical there, but I didn't really word my first post correctly. Sorry bout that)

Anywho, right now, my "game" consists of:
1. Draw 3 box rooms
2. Draw the player
3. Wait for input so that the player can be moved
4. Refresh the screen when the player inputs a key hit

Where should I go on from this current point? Should I implement AI first? Should I make a menu? maybe start trying to make objects that can be placed on the map and put in an inventory?

I really don't know where to start...
« Last Edit: July 01, 2009, 06:07:08 pm by Rsugar »
Logged
"Hey baby, Want to see my mine shaft?"
"oooh...is it long and rough?"

Sowelu

  • Bay Watcher
  • I am offishially a penguin.
    • View Profile
Re: The Roguelike Development Megathread
« Reply #394 on: July 01, 2009, 06:13:29 pm »

Well, pathfinding isn't necessarily an AI thing.  In this case, it's useful during map generation to just, well, make the path in the first place.  :)

I usually recommend that, before you make a very good random map generator, you should figure out how you want your items and monsters to work.  Go simple!  An "item" class and a "being" class will probably serve you well.  Menus are good after that, so you can pick up items and view your inventory (even before you can wear them).  And then some simple combat.  Enemies can wander randomly...once you think you're ready for it, learn some simple pathfinding to teach monsters to chase you around the level.  And then you'll be ready to do map generation.

Don't fall into the trap of over-designing things!  Lots of people who start out roguelikes like to make robust systems where you can wield goblins.  DON'T DO THIS.  Keep items and monsters distinct.  Make your system NOT generalized!  Don't worry about what happens if you turn into a rust monster and want to eat that metal armor--just say "No, that can't happen".

The one thing you will probably want to do is to re-use the 'living thing' code between monsters and the player.  But don't take it too far.
Logged
Some things were made for one thing, for me / that one thing is the sea~
His servers are going to be powered by goat blood and moonlight.
Oh, a biomass/24 hour solar facility. How green!

magellan

  • Bay Watcher
    • View Profile
Re: The Roguelike Development Megathread
« Reply #395 on: July 01, 2009, 06:30:15 pm »

AI for a chasing monster:

If myx>playerx then myx=myx-1
If myx<playerx then myx=myx+1
If myy>playery then myy=myy-1
If myy<playery then myy=myy+1

there... that wasn't that bad, was it? :)
Logged
Prospector, my space exploration roguelike:
http://code.google.com/p/rlprospector/

deadlycairn

  • Bay Watcher
    • View Profile
Re: The Roguelike Development Megathread
« Reply #396 on: July 02, 2009, 12:06:10 am »

Yeah, but as the rooms get fancier the AI needs to upgrade as well. Plus that allows for some exploits with diagonal movement, and doesn't always take the best path. Plus a situation like this is asking for trouble.

#############
#......................#
#...........###.....#
#....@....###.m..#
#############
Logged
Quote from: Ampersand
Also, Xom finds people that chug unidentified fluids pleasing.
Quote from: Servant Corps
Ignorance of magic does not give scientists the power to resist fireballs.

Rhodan

  • Bay Watcher
    • View Profile
Re: The Roguelike Development Megathread
« Reply #397 on: July 02, 2009, 03:12:18 am »

Pathfinding is a very tricky concept so it's better to avoid it in your first roguelike.  Focus on line-drawing algorithms and FOV.
With a good line-drawing function you can just make the monster lose track when you're behind a wall, preventing bumping.  Having the monster try and go in your general last direction after losing track will help it get around corners easily.
Pathfinding is only useful for really smart monsters, automated exploring, or monsters actively going places to shop or something.  Not really "My first RL" material.
Logged

Rsugar

  • Bay Watcher
  • Newbie Programmer\Graphics Artist
    • View Profile
Re: The Roguelike Development Megathread
« Reply #398 on: July 02, 2009, 06:49:10 pm »

aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

I've added a config file parser for items, so that the user can make new items in a text file and the game will load them up.

I've gotten to the point where the game will store the file contents into a vector array, and I can retrieve the name and such of an item. The problem is, I have no idea how to make the game build that item. I don't know how to make the game declare the item either. Help!
Logged
"Hey baby, Want to see my mine shaft?"
"oooh...is it long and rough?"

Singularity

  • Bay Watcher
    • View Profile
Re: The Roguelike Development Megathread
« Reply #399 on: July 02, 2009, 11:42:21 pm »

Don't fall into the trap of over-designing things!  Lots of people who start out roguelikes like to make robust systems where you can wield goblins.  DON'T DO THIS.

I've been toying with the idea of starting a roguelike for a while, but I haven't started yet.  Still, I'm going to take that as a challenge, because it just sounds too awesome. ;D  At the very least, I want as much overlap between entities as possible.  After all, if a monster, e.g. an orc has HP, STR, DEF, etc., can't a sword have the same stats?  The meanings will be slightly different (item "HP" would be the item's durability, if you have degrading items), but the concepts are similar.  Taking it another step further, if you have destructible terrain then walls can also have an HP and STR.  In my mind, having those options available from the start is easier to work with than adding them in halfway through, and it also allows for crossovers like magically animated swords.

My best example for this sort of broad classifying is the game Phantom Brave.  It allows you to wield any object in the game, and also allows you to confine (summon) your team to any object.  The uses vary depending on those purposes, but any object can theoretically be useful for either purpose.  There's also an interesting fusion element, where you can combine two items, or two characters, or even an item and a character, to improve their capabilities.  It's a pretty fun system, and there's something oddly gratifying about smacking someone upside the head with a tree. ;D

(Disclaimer:  This certainly isn't "first RL" advice, and I tend to be overly ambitious. ;))
Logged

Granite26

  • Bay Watcher
    • View Profile
Re: The Roguelike Development Megathread
« Reply #400 on: July 03, 2009, 02:57:28 pm »

Inheriting your items and units from the same root is a good idea regardless.  When you decide to add a new trait, you only need to do it once

Rsugar

  • Bay Watcher
  • Newbie Programmer\Graphics Artist
    • View Profile
Re: The Roguelike Development Megathread
« Reply #401 on: July 03, 2009, 08:07:17 pm »

Well, I'm stumped on generating items and such from info files. Like I said before, I can load all of the stuff up as variables after parsing it, but I have no idea how to make the game actually create an instance of the items in the file.

So, I set off to do something else!

SCROLLING MAP! YEEEEEEEEEEEEEEES! It only took about half an hour to figure out, and so I'm feeling a bit better about my programming abilities.
Here's a screen of what I have so far:
Logged
"Hey baby, Want to see my mine shaft?"
"oooh...is it long and rough?"

Willfor

  • Bay Watcher
  • The great magmaman adventurer. I do it for hugs.
    • View Profile
Re: The Roguelike Development Megathread
« Reply #402 on: July 09, 2009, 06:50:59 pm »



I've got the slim basics (basic graphics, movement) done. I have a good idea of where I want to go with it from here as long as I don't shoot myself in the foot along the way. I'm actually starting to get the hang of programming in a way.
Logged
In the wells of livestock vans with shells and garden sands /
Iron mixed with oxygen as per the laws of chemistry and chance /
A shape was roughly human, it was only roughly human /
Apparition eyes / Apparition eyes / Knock, apparition, knock / Eyes, apparition eyes /

narakal

  • Bay Watcher
    • View Profile
Re: The Roguelike Development Megathread
« Reply #403 on: July 09, 2009, 09:08:44 pm »

um..... just asking, but how would a person create a map larger then the screen? ala, more then 80X25 characters, more like 150x150 or something like that? Basically what is the most effiecient way to do so? Because curses pad feature seems really cryptic in its description for me....
Logged

Alexhans

  • Bay Watcher
  • This is toodamn shortto write something meaningful
    • View Profile
    • Osteopatia y Neurotonia
Re: The Roguelike Development Megathread
« Reply #404 on: July 09, 2009, 09:34:18 pm »

I'm trying to start a group project (developing a simple game)

Simple Game Project. Who would like to join?

Anyone who's interested... is welcome.
Logged
“Eight years was awesome and I was famous and I was powerful" - George W. Bush.
Pages: 1 ... 25 26 [27] 28 29 ... 72