On Tiles and Why We Don't Have Them (But we're progressing. Thanks utunnels)

It says nothing conclusive… I can assure you of that. It had taken ages for the preliminary build to compile when the error came along so I wouldn’t feel comfortable in giving it another shot, plus chances are it could be my present linker settings that are responsible for what’s causing the error.

At any rate what you’re doing here with Cata’s code is commendable for a person who is acting on their own. Are you going to keep at it and squeeze in a couple of new features for the tileset window or are you gonna quit? You have my blessings to proceed in case it means anything to you.

I’m currently playing the game so I like a tileset window to help my gameplay because I’m not a core roguelike player and have some problem with the ascii interface. :slight_smile:

I think I’ll complete the code, or at least add the fog of war and npc. Actually my solution change is a single gfxwindow.cpp file plus several lines in main.cpp, it should be easy enough to manage, unless the core code of the game is changed dramatically someday. I mapped constants in game to string, so as long as the names stay unchanged, the code should work.

For example, the json file entry:

{ "id":"t_pit", "fg":277 },

It maps terrain with type id t_pit to tile 277 (count from the upper left corner of the picture, 16x16). Anyone that can understand mapdata.h can edit the json file easily. You can also use “bg” to set a background tile, for example a desk may need a floor bg but you can always draw it on fg instead.

Other map elements are similar, for example, traps start with tr_, monsters start with mon_, fields start with fd_ and items use their id strings (check those json files in raw folder).
Walls are a bit tricky, currently I put all possible 12 tiles in a line, you can check the picture for an example.

Anyway, what bugs me the most at this point is that none of the folks behind Cataclysm have paused to get a look at what you have just recently uploaded to the Internet and passed their judgement on whether the tileset window is worth including in the vanilla version.

Also, when you take into account that there’s folks like Deon ( known for outstanding tileset work on titles such as Rogue Survivor ) and others who are ready to pull up their sleeves and make some decent graphics for Cataclysm, you start to think that maybe no one really cares much about getting this department an upgrade.

The team have said in the past that they have little desire to sacrifice the speed at which Cataclysm regularly gets new features in order to wring out better-looking visuals, but hopefully your ongoing struggle to bring novelty to the game will make them change their mind.

We’re definitely interested in mainlining tileset support, I’ll be taking a look at this as soon as I get home this evening. The only thing that gives me pause is all the mentions of Visual Studio, this isn’t a windows-only thing is it?

Honestly, I didn’t even notice it until now. I would have expected something like this to have it’s own thread. (And as always, PRs on github where we actually track the project is the quickest and most effective way to get proposals for inclusion seen and reviewed. We’ll definitely look at stuff like this when we can, but it’s not blaring into our ears every day like the github stuff is and it’s much, much easier to miss or forget about)

[quote=“Kevin Granade, post:44, topic:197”]We’re definitely interested in mainlining tileset support, I’ll be taking a look at this as soon as I get home this evening. The only thing that gives me pause is all the mentions of Visual Studio, this isn’t a windows-only thing is it?[/quote] Yeah, but isn’t the project windows only (because catacurse is) currently?


The last binary file I uploaded was actually compiled using mingw (makefile.windows, or makefile.windows.gfx), because I noticed visual studio is buggy as I mentioned in another thread. It is definitely a pain to maintain when most devs don’t use it.

And the source: https://www.dropbox.com/s/yk1mcx5v7bb1gd2/Cataclysm-DDA-tile.7z
I already made fog of war work. I admit the code is not efficient because it basically does what map::draw does again, and there are many string lookups .

I noticed this yesterday, I just didn’t have much time for forum-ing. It’s certainly interesting, though.

Uh… catacurse is actually a crude Windows approximation of ncurses, which is a common Linux terminal drawing utility. The reason catacurse is Windows-only is because there are better options under Linux ;).

We’re interested in having multi-platform tiles support, and although we generally prefer to avoid external dependencies, I think that tiles are an exception to that. If you’re able to move your stuff over to something like SDL, that would be awesome, and would personally make me a lot more inclined to try getting this merged into the main game. Even if you don’t test it under Linux, just having it set up to use a cross-platform library like SDL would make things a lot easier for us.

Although, even if it remains Windows-only, there’s still a potential for it to be merged in. Long-term, we’d need to migrate tiles to something cross-platform, but short-term, having something that works on one system is better than none at all. Plus, if it has performance comparable to or better than catacurse, we might be able to use it as a way to get better performance under Windows.

Anyway, key things that would make this a lot more attractive for inclusion in mainline: make it multi-platform, and try to structure things so that it can “just work” without any special attention.

I see. I was wondering what’s that ncurse thing in cursedef.h.
Actually I’m not familiar with gdi but I saw catacurse was using that so I gave it a try.

Using SDL sounds a good idea. It will also benifit sound and music.

Yeah, what I’ve seen indicates that SDL is pretty reliable, once it’s configured properly. There are other options, of course, but SDL is the obvious one. If you get this moved over to something that’s cross-platform, the chance of inclusion in mainline will skyrocket. And, of course, a solid base for tiles support will have our undying gratitude :).

I spent one day to rewrite catacurse.cpp using sdl and sdl_ttf.

The drawback is, sdl_ttf must load font from file, which means we’ll have to put an actual font file somewhere in data folder. Otherwise it is hard to tell where the font files are located on different systems.

Including a default font in the data folder is totally fine, especially since the idea has come up in other contexts as well (internationalization).

Here’s a link to the source (actually I only changed one file).

The code needs some clean up and the font looks a bit out of shape, I need to investigate more about that.

Awesome, I’ll take a detailed look at this tomorrow :).

Some initial comments, based on a cursory glance before bedtime:

  1. If this works as well as we hope, we’ll definitely want to pull the SDL/tiles stuff out from that Windows-specific #ifdef, for obvious reasons. It’s fine leaving it where it is for now, but someone will have to get that cleaned up a bit before inclusion in mainline (I also suspect that someone may be me, unless someone else gets to it first).

  2. Related to the above, we may want to retain the old catacurse.cpp file, since it’s got minimal dependencies. Although… now that I think of it, the standard way to handle an SDL dependency under Windows is to just include the .dll file in your binary download, so… maybe an SDL dependency for bare-bones Windows binaries is fine after all.

  3. I can’t remember what this was going to be, so: awesome, let’s see if this works :).

Hehe, I forgot to say, that modification do not have the tile window… I just rewrote catacurse.cpp so it might be more portable someday.
I linked the exe statically, so users don’ t need to download dll files.

I also uploaded sdl lib files in the same package under 3rdparty folder. The makefile I’m using is makefile.windows.sdl, so if one has mingw compiler installed he should be able to try it right away.

mingw32-make.exe -f makfile.windows.sdl


Unfortunately, it seems SDL 1.2 can’t have multiple windows like 2.0. And I’m reconsidering the tile window idea because not all systems have full support for multiple windows. So maybe I’ll end up editing the main window.

LOL

Whatever you end up doing with the main window, make sure the resulting code is as compact and portable as possible in relation to the existing one, though I’m sure you’ve got this down by now.

Speaking of, it’s been quite a while since I last fired up Cataclysm, the main reason being that I can’t bring myself to resume playing now that I’m used to some form of visuals thanks to fatdog’s recent contributions in that department. It’s like going through drug withdrawal for goodness’ sakes ( not implying that I have first-hand experience of drug withdrawal though ). Despite that, things will pick up soon I guess.

I think I need some time to plan i t out.

If the game has 1 window, maybe the user can press a button to switch between a tileset map and an ascii map, toggle fullscreen mode or use default map size, etc.

Well put. Best of luck with your assignment.

[quote=“utunnels, post:50, topic:197”]I spent one day to rewrite catacurse.cpp using sdl and sdl_ttf.

The drawback is, sdl_ttf must load font from file, which means we’ll have to put an actual font file somewhere in data folder. Otherwise it is hard to tell where the font files are located on different systems.[/quote]

I wouldn’t say that’s any drawback. Furthermore you can replace font files with bitmap images and then there would be no difference for the game between using tiles or ASCII symbols. Also, when you use bitmaps you can load them in video memory as textures and make use of hardware acceleration, although that font library could be already doing that on its own, through OpenGL I suppose.

For input, to support holding a key, you can use “SDL_GetKeyState”, that is in “void CheckMessages()” do something like this:

[code]
Uint8 *keystate = SDL_GetKeyState(NULL);

if(keystate[SDLK_LEFT])
lastchar= KEY_LEFT;

if(keystate[SDLK_RIGHT])
lastchar= KEY_RIGHT;

if(keystate[SDLK_UP])
lastchar= KEY_UP;

if(keystate[SDLK_DOWN])
lastchar= KEY_DOWN;[/code]

Yeah, I like the bitmap font idea. But perhaps ttf is better for internationalization. Although, it is still a backup option.

As for the key repeating problem, I already solved it, will update the code next time I get a chance.

	SDL_EnableKeyRepeat(500, 25);

[quote=“Soron, post:53, topic:197”]Awesome, I’ll take a detailed look at this tomorrow :).

Some initial comments, based on a cursory glance before bedtime:

  1. If this works as well as we hope, we’ll definitely want to pull the SDL/tiles stuff out from that Windows-specific #ifdef, for obvious reasons. It’s fine leaving it where it is for now, but someone will have to get that cleaned up a bit before inclusion in mainline (I also suspect that someone may be me, unless someone else gets to it first).

  2. Related to the above, we may want to retain the old catacurse.cpp file, since it’s got minimal dependencies. Although… now that I think of it, the standard way to handle an SDL dependency under Windows is to just include the .dll file in your binary download, so… maybe an SDL dependency for bare-bones Windows binaries is fine after all.

  3. I can’t remember what this was going to be, so: awesome, let’s see if this works :).[/quote]

You can throw away ncurses completely and have identical code working on Linux, Windows and Macintosh, by using Trolltech’s Qtopia. It’s kind of like GLUT (OpenGL Utility Toolkit), only better, and in syntax very similar to SDL. It’s very much like SDL actually, only it has a bonus of having portable windowing management library, and all the rest is about the same, that is input and video/audio output handling. Handling input is almost identical to SDL, and for video output you can either use OpenGL or their own 2D rendering library, both pathways hardware accelerated on all three target systems. I haven’t done any sound programming with QT, but it should be as good as anything else. To achieve such smooth cross-platform compatibility the only file you would need to modify is “catacurse.cpp”, which would be used by all of the three platforms, and the work required would be quite similar to what was done here to port it for SDL, easy. QT is free for non-commercial use, or at least it was several years ago.