Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1] 2 3

Author Topic: Roguelike Engine  (Read 7584 times)

Angle

  • Bay Watcher
  • 39 Indigo Spear Questions the Poor
    • View Profile
    • Agora Forum Demo!
Roguelike Engine
« on: July 05, 2011, 01:53:36 am »

I'm working on a basic roguelike engine in C++. I've never really programmed anything before, so I may be overreaching, but I couldn't think of anything else I really wanted to program.

The below source is thoroughly outdated. Up to date source can be found here.

What I want to do is codify each different type of square of terrain as a const instance of a class. Like I have an instance for smooth ice, and an instance for rough rock cave floor, and for polished cave floor, etc. I then have localareas that store 2d vectors of pointers to these const instances of terraintypes. What I'm working on right now is having a player and having it draw the world from around the player. next I'm going to have the local areas keep track of what other localareas are next to them. The reason I'm doing it this way, instead of just having an array or something is because this will allow me to do all sorts of weird things. Like have gradual slopes, instead of staircases. Or do horribly deviant things to space and distance. or play mean tricks on anyone who plays my games. etc.

Anyway, heres the source code. Tell me what you think!

Spoiler: Main.cpp (click to show/hide)

Spoiler: LocalArea.h (click to show/hide)

Spoiler: LocalArea.cpp (click to show/hide)

Spoiler: TerrainType.h (click to show/hide)

Spoiler: TerrainType.cpp (click to show/hide)

Spoiler: Entity.h (click to show/hide)

Spoiler: Entity.cpp (click to show/hide)

Spoiler: Location.h (click to show/hide)

Spoiler: Location.cpp (click to show/hide)

Spoiler: Player.h (click to show/hide)

Spoiler: Player.cpp (click to show/hide)
« Last Edit: November 14, 2011, 10:55:38 pm by Angle »
Logged

Agora: open-source platform to facilitate complicated discussions between large numbers of people. Now with test site!

The Temple of the Elements: Quirky Dungeon Crawler

MorleyDev

  • Bay Watcher
  • "It is not enough for it to just work."
    • View Profile
    • MorleyDev
Re: Roguelike Engine
« Reply #1 on: July 05, 2011, 08:22:32 am »

Don't think of it as an Engine. Think of it as a game. You can refactor out the reusable stuff later, for now: Get that ascii representation of a man fighting ascii representations of orcs, or whatever you want the finished product to contain. Then you add functionality to the game.

Seriously, this little blog post needs to be mandatory reading: http://scientificninja.com/blog/write-games-not-engines

Engines come from games, not the other way round.
Logged

Angle

  • Bay Watcher
  • 39 Indigo Spear Questions the Poor
    • View Profile
    • Agora Forum Demo!
Re: Roguelike Engine
« Reply #2 on: July 05, 2011, 09:15:39 am »

well, alright then. Ascii orcs it is then.
Logged

Agora: open-source platform to facilitate complicated discussions between large numbers of people. Now with test site!

The Temple of the Elements: Quirky Dungeon Crawler

Aramco

  • Bay Watcher
    • View Profile
Re: Roguelike Engine
« Reply #3 on: July 10, 2011, 01:10:29 am »

If only I knew C++, I could have an opinion. Through my knowledge of C#, I sort of know what I'm looking at, but only barely.
Logged
Or maybe there's a god who's just completely insane and sends you to Detroit, Michigan in a new body if you ever utter the name "Pat Sajak".

Angle

  • Bay Watcher
  • 39 Indigo Spear Questions the Poor
    • View Profile
    • Agora Forum Demo!
Re: Roguelike Engine
« Reply #4 on: July 19, 2011, 09:35:41 pm »

I've done some more programming, and would like some criticism. I've done some more stuff with the LocalAreas and they work, but somehow I think that there must be a better way to do these things. The way I've got it right now, I have these LocalAreas that store 2d vectors of pointers to these const instances of terraintypes. I also have the LocalAreas keep track of what other LocalAreas are next to them, and the direction, rotation, offset, and mirroring of these bordering LocalAreas. I have this implemented through a nested class, LocalArea::BorderArea, and a vector of these BorderAreas.

The main two functions that bother me are LocalArea::getTerrain(int x, int y) and LocalArea::getBorder(int x, int y), which are in files LocalAreaTerrain.cpp and LocalAreaBorder.cpp. They're both huge ugly masses of nested switch statements. getTerrain looks within it's own area for a tile located at (x,y) and if it can't find it then it looks in the LocalArea's that border it. GetBorder looks at the coordinates of (x,y) and figures out witch, if any, of it's borders they lie in.

So, without further ado, the code.

Spoiler: TerrainType.h (click to show/hide)

Spoiler: TerrainType.cpp (click to show/hide)

Spoiler: LocalArea.h (click to show/hide)

Spoiler: LocalArea.cpp (click to show/hide)

Spoiler: LocalAreaTerrain.cpp (click to show/hide)

Spoiler: LocalAreaBorder.cpp (click to show/hide)

Also- I have a game in mind. It's called "Beneath the <Adjective> Mountains". You start the game at the entrance to these massive caverns beneath these mountains. In the caverns, you encounter all sorts of creatures and strange civilizations and stuff. The game is mostly about exploration and discovery.
« Last Edit: July 19, 2011, 09:40:45 pm by Angle »
Logged

Agora: open-source platform to facilitate complicated discussions between large numbers of people. Now with test site!

The Temple of the Elements: Quirky Dungeon Crawler

Ehndras

  • Bay Watcher
  • Voidwalker
    • View Profile
Re: Roguelike Engine
« Reply #5 on: July 19, 2011, 09:47:59 pm »

I have no idea what the hell any of this means, but I'll say this:

Ever read 'At the mountains of madness' by H. P. Lovecraft? Ever heard of Cthulhu? YES.

THAT. Do THAT! Doing a crazy alien/supernatural context beneath the earth like finding ancient hidden civilizations that may have created humanity and sure as hell predate us would be awesome and, crappy game or not, more interesting than yet another half-made game about orcs and elves. Gives it a little mystery, some interesting twists, and something to work towards. ;)

In other words, orcs/elves/dungeons has been done, over-done, resurrected, and then killed again. To death. Did that make sense? No? Exactly.
Logged
Quote from: Yoink
You're never too old to enjoy flying body parts.  
Quote from: Vector
Ehndras, you are the prettiest man I have ever seen
Quote from: Dorsidwarf
"I am a member of Earth. I enjoy to drink the water. In Earth we have an internal skeleton."

Angle

  • Bay Watcher
  • 39 Indigo Spear Questions the Poor
    • View Profile
    • Agora Forum Demo!
Re: Roguelike Engine
« Reply #6 on: July 19, 2011, 10:02:31 pm »

I have read'At the mountains of madness' by H. P. Lovecraft. And I will do some thing like that, but mostly it's going to be various mythical underground civilizations living their day to day lives.

I am thinking of doing a cosmic horror roguelike at some date well in the future, though.
Logged

Agora: open-source platform to facilitate complicated discussions between large numbers of people. Now with test site!

The Temple of the Elements: Quirky Dungeon Crawler

Neonivek

  • Bay Watcher
    • View Profile
Re: Roguelike Engine
« Reply #7 on: July 19, 2011, 10:05:23 pm »

Quote
Doing a crazy alien/supernatural context beneath the earth like finding ancient hidden civilizations that may have created humanity and sure as hell predate us would be awesome and, crappy game or not, more interesting than yet another half-made game about orcs and elves

You are aware "Alien who predates humanity" is a much more common a trope in RPGs then you think right? In fact there are three series entirely based around this concept.

In fact more common then elves and DEFINATELY more common then orcs.

The problem with doing a proper lovecraftian Roguelike is the amount of talent, planning, and foresight required NOT to turn it into a hack and slash. It is a game where you can't trust your eyes and yet even within insanity there is truth (plus other stuff blaw blaw)
Logged

Angle

  • Bay Watcher
  • 39 Indigo Spear Questions the Poor
    • View Profile
    • Agora Forum Demo!
Re: Roguelike Engine
« Reply #8 on: July 19, 2011, 10:12:27 pm »

The problem with doing a proper lovecraftian Roguelike is the amount of talent, planning, and foresight required NOT to turn it into a hack and slash. It is a game where you can't trust your eyes and yet even within insanity there is truth (plus other stuff blaw blaw)

Yeah, that's WAY the hell down the road. Especially because the idea I had calls for simulating basically all of society as a background.
Logged

Agora: open-source platform to facilitate complicated discussions between large numbers of people. Now with test site!

The Temple of the Elements: Quirky Dungeon Crawler

Ehndras

  • Bay Watcher
  • Voidwalker
    • View Profile
Re: Roguelike Engine
« Reply #9 on: July 19, 2011, 10:35:27 pm »

Aye, proper details comes WAY later, after ensuring all the mechanics actually function properly. You can easily change names/descriptors around later on and get new graphics once the mechanics are going well. ;)

I'll leave the coding to you, Angle, as I as of yet may as well be reading a lecture on quantum mechanics in Arabic, considering how well I understood any of that.

Let me know when you've got something functional, I'll do bug testing as is needed :D Once I actually know what you're talking about, I'll also join in. As of now though, I'll sit on the sidelines and watch. :P
Logged
Quote from: Yoink
You're never too old to enjoy flying body parts.  
Quote from: Vector
Ehndras, you are the prettiest man I have ever seen
Quote from: Dorsidwarf
"I am a member of Earth. I enjoy to drink the water. In Earth we have an internal skeleton."

Ehndras

  • Bay Watcher
  • Voidwalker
    • View Profile
Re: Roguelike Engine
« Reply #10 on: July 19, 2011, 10:39:28 pm »

Quote
Doing a crazy alien/supernatural context beneath the earth like finding ancient hidden civilizations that may have created humanity and sure as hell predate us would be awesome and, crappy game or not, more interesting than yet another half-made game about orcs and elves

You are aware "Alien who predates humanity" is a much more common a trope in RPGs then you think right? In fact there are three series entirely based around this concept.

In fact more common then elves and DEFINATELY more common then orcs.

The problem with doing a proper lovecraftian Roguelike is the amount of talent, planning, and foresight required NOT to turn it into a hack and slash. It is a game where you can't trust your eyes and yet even within insanity there is truth (plus other stuff blaw blaw)

I was not aware. The sheer volume (thousands) of elf-orc-bladi-blah-hack&slash dungeon crawlers seems to outnumber scifi-based rpgs by a ton, considering how I actively seek those types of games out and only ever seem to come across really SHITTY scifi rpgs, when I'm not bombarded by hundreds of classic fantasy rpgs about kingdoms and knights and dragons and bladiblah.

Considering how my literary style started with H. P. Lovecraft, I'd say I'm good enough to half-ass something.

Here's a little philosophical crap I wrote after my last reading of Lovecraft... Had been a good 5 years since I had read any Lovecraft, sadly. Once I read every single one of his stories, I sort of gave up on reading for a while >_>

You might, uhh, notice a few Lovecraftian references. ;)


http://gjstruck.wordpress.com/2011/02/01/ephemeral-visions-of-atlantean-vistas/
Logged
Quote from: Yoink
You're never too old to enjoy flying body parts.  
Quote from: Vector
Ehndras, you are the prettiest man I have ever seen
Quote from: Dorsidwarf
"I am a member of Earth. I enjoy to drink the water. In Earth we have an internal skeleton."

Ehndras

  • Bay Watcher
  • Voidwalker
    • View Profile
Re: Roguelike Engine
« Reply #11 on: July 19, 2011, 10:44:58 pm »

Btw, I apologize if its a bit dense. I have a very... Complicated writing style, and I may or may not have been slightly drunk and/or without sleep for several days.
Logged
Quote from: Yoink
You're never too old to enjoy flying body parts.  
Quote from: Vector
Ehndras, you are the prettiest man I have ever seen
Quote from: Dorsidwarf
"I am a member of Earth. I enjoy to drink the water. In Earth we have an internal skeleton."

Angle

  • Bay Watcher
  • 39 Indigo Spear Questions the Poor
    • View Profile
    • Agora Forum Demo!
Re: Roguelike Engine
« Reply #12 on: July 20, 2011, 05:40:40 pm »

It's a nice little article, although you were right about it being dense.

Come on, people, can't anyone criticize my code? Constructively, of course.
Logged

Agora: open-source platform to facilitate complicated discussions between large numbers of people. Now with test site!

The Temple of the Elements: Quirky Dungeon Crawler

Angle

  • Bay Watcher
  • 39 Indigo Spear Questions the Poor
    • View Profile
    • Agora Forum Demo!
Re: Roguelike Engine
« Reply #13 on: July 21, 2011, 04:51:53 pm »

I now have a very basic game. There are open spaces you can run around in, and walls that block movement. Next I want to implement walls that block vision. Any advice or criticism?

Spoiler: Main.cpp (click to show/hide)

Spoiler: LocalArea.h (click to show/hide)

Spoiler: LocalArea.cpp (click to show/hide)

Spoiler: TerrainType.h (click to show/hide)

Spoiler: TerrainType.cpp (click to show/hide)

Spoiler: Entity.h (click to show/hide)

Spoiler: Entity.cpp (click to show/hide)

Spoiler: Location.h (click to show/hide)

Spoiler: Location.cpp (click to show/hide)

Spoiler: Player.h (click to show/hide)

Spoiler: Player.cpp (click to show/hide)

Spoiler: LocalAreaTerrain.cpp (click to show/hide)
« Last Edit: July 21, 2011, 04:53:51 pm by Angle »
Logged

Agora: open-source platform to facilitate complicated discussions between large numbers of people. Now with test site!

The Temple of the Elements: Quirky Dungeon Crawler

Angle

  • Bay Watcher
  • 39 Indigo Spear Questions the Poor
    • View Profile
    • Agora Forum Demo!
Re: Roguelike Engine
« Reply #14 on: July 21, 2011, 04:54:06 pm »

Also, I really need a better way to upload my project. Any recommendations? I've heard git-hub is good.

Spoiler: LocalAreaBorder.cpp (click to show/hide)
Logged

Agora: open-source platform to facilitate complicated discussions between large numbers of people. Now with test site!

The Temple of the Elements: Quirky Dungeon Crawler
Pages: [1] 2 3