Tuesday, 8 March 2016

7DRL days 3-4: Mass with class

I gave up and copied some of the gui classes from Kaduria to this project. Mainly classes for loading tiles and processing surface data, plus some other basic classes. So I now have a procedural code mixed up with a bunch of classes and I can display some tiles.

It's obvious that this wont be done in 7 days if ever. But I could at least use full 7 days to see how far I can get. I still have some left of today (is it day 4 or 5 already?) to add fonts which is the next step needed in gui.

Sunday, 6 March 2016

7DRL day 2: Tiles

I now have a program that runs, it has SDL 2 basics, but doesn't yet even have graphics routines. It seems I'm going to write this dev blog in advance to what I'm trying to do for each day. This day I should draw tiles and try to create a tile drawing routine.

I've already had trouble with procedural programming. I started to wonder how it's possible to store global data without classes, but of course it's possible to malloc memory and then point to it.. but how to use that memory without a class? I think C has structs, so they are kind of classes I guess. A class is such a fundamental building block in programming that I just gave up and created one to hold generic gui data, like keyboard commands and later graphics.

I think it was already a bad idea to try the procedural style. The source code will look quite strange if I'm ever going to finish this project. It's already a mix of functions, classes and even one datatype class I've been using a lot in my other projects. But who knows, maybe this is an opportunity to learn something.

Saturday, 5 March 2016

7DRL day 1: Procedural routine

I woke up early, depressed and not ready for the 7DRL challenge. In fact I've had so called "real life" issues lately. But I started the project anyway. The first thing I noticed how stupid procedural programming really is. In class programming you set up variables in the constructor and they can be then used by member functions. But in C you have to pass everything to the function and not only that the function returns some kind of value or object that has to be maintained somehow.

I can do the first part, but I'm just going to use C++ style containers for the objects and that's it. I think it's possible to decrease the painful amount of parameters by creating compound data structs you then pass as reference. It's possible that I also need to shift my thinking from small C++ style functions to larger, more generic functions.

This first day is going to be setting up basics in the source code and I could also draw quick placeholder type tiles and other graphics needed. Lot of the source code is coming from other projects, but it has to be "proceduralized" which is going to be fun I guess.

Friday, 4 March 2016

Evolution blob

One of the ideas for my 7DRL is what I call an evolution blob. In that let's say you start your level generation with ocean tile. What's next? It could be probably sand tile, then sand tile could become dirt etc. Each tile would have the next evolution stage or several ones which then could create a branch in the evolution. To avoid everything become the last stage of evolution there needs to be some kind of percentage value for creation and also possibly a proximity check for stuff like creating dirt next to sand, but not next to ocean (where it would erase the sand tiles).

Then "blobs" are created over each other to proceed the tiles in that place to next generation. I don't know how far you can go like that, but at least simple terrain generation should be quite easy. I guess you could create some kind of rooms by applying a room shaped "blob" with extra value to proceed the evolution from natural environment to artificial walls.

I was talking about planning everything to paper, but it didn't work, because I had the kind of ideas that needs to be implemented to see if they work. Beside that I'm trying to think hard what is the role of classes vs. procedural functions, because I want to stay away from classes as much as possible.

Sunday, 28 February 2016

Plans for 7DRL

This time I'm trying to participate to 7DRL. It's starting soon, but I think there is time to plan the game before implementing. I had an idea to plan the entire game to paper first, to smallest detail about what kind of datatypes you need etc.

I'm also going to try something different in programming which is using procedural routines in C++ as much as possible and also try to create some kind of component/entity model for data. Procedural functions (procedures?) was something I've noticed useful in some parts of regular class based source, but could it be somehow extended more, still maintaining some kind of object based implementation? Who knows, but if this works then we'll find out.

When working with quite large source code as Kaduria has I've started to think about problems in OOP, especially the large number of functions there seems to be in classes. Maybe it's just my fault and I write more specific functions than actually needed.

Saturday, 12 December 2015

Nethack 3.6.0

The elusive Nethack Dev Team (or just the Dev Team) has released a new version of Nethack. It's not a big update, but they are in a process of trying to catch up the current vibe of development in this modern age of wonders.

I've been sick and mainly trying to recover, so it has been practical to spend time playing the new version of Nethack (rather than programming which can be strenuous). While it doesn't have many new features it somehow feels solid. You know, it just works. I still after all these years don't like D&D or the way it forces you to play the game. The nice thing about NH and many other roguelikes is that you don't exactly have to follow "powerplayer" rules and tricks. So it's possible to create your own "story" by trying out stuff. Usually it means rather untimely death, but it's the price you have to pay for freedom.

It's interesting to see where the Dev Team is heading with the next version. It could be difficult to change such an iconic game as Nethack. Maybe the changes are something like more complex environment?

I'm slowly getting my strength back and in fact today I did some programming. I have some nice ideas for Teemu in source code level to achieve more modular structure which is always a good thing, so I know what to do for next week or two.

Friday, 4 December 2015

SDL 2.0: Scancode and keycode

Graphics routines are now complete. What they mostly needed was alpha channel data for things like font colors, because everything starting from data is now 32 bit RGBA. The old update rectangles are gone, because SDL2 has (I guess?) only window wide update. In that I'm planning to use a trick where the screen is updated in the keyboard get routine, because that's how the program works in logical sense. That way I don't even have to keep a update flag for every single drawing routine would otherwise had to send to GUI. Just update when waiting for keypress, whether it's in a menu or during gameplay.

Keyboard routines also needed some work. The old unicode seems to be gone and now there are keycode and scancode codes for keys. I'm actually little bit confused about them and the way I wrote new keyboard routines was using keycode. But you have to do some funny things, because in Finnish key layout some keys are not where you would think they are. For example ? is shift-+ and greater/less than characters are in the same key with greater than requiring shift. To get ? I have to check for + with modifier key shift. But I'm not sure if it's the proper way. Will it work in other layouts as well? I'm also puzzled about scancode in 2.0, because I guess it's supposed to be the physical keyboard code, but keycode itself works pretty much like it already.

There were couple of other odd things. For some reason GetKeyName returns uppercase letter for letters, even keycodes are lowercase (SDLK_a='a'). More confusingly the keyboard event seems to receive lots of events when you press a key, but movement and everything else seems to work with normal repeat rate.

Now when the technical work is done it's time to return to content creation which is sometimes annoying. It's mostly technical as well, but you don't have any kind of reference or wiki for that.