Guilty or not?

Yes, the big old question: when being "inspired" from tutorial code, is it legit to keep it and to anchor it into your project forever? Or is this considered stealing in some way? Surely, I have a personal guilt about this. I simply cannot live with just imitating someone else's ideas.

Now... I have come to some point where I see the impossibility to change something. I mean, let's take a very basic class, like a point, or maybe a tile. It has an int x and an int y. that's it. There is simply no other way. It is absolutely logical and I would have named it the same way. That goes for other classes too. This was driving me crazy, so I tried to work on my own code. And voilĂ , it worked. It took me some nerves and several tries and complete class rewrites, but in the end, I have learned more than by just copying. Even though I have the impression, the other code is still better in performance, I am happy to have created an own logic. Plus, with each class I write on my own, my understanding for the language and the game logic increases, allowing further derivations from available code.

Phew.. that confession eased my mind. How do you people go about this? Do you even let yourself inspire by someone else's code or are you all so talented that you come up with your own stuff in the very first second?

Field of View

Field of View is very important decision for any game. How will it be rendered? What will the player be able to see?

I decided to make it very easy, by Raytracing. I have only a 2 dimensional space, so this should not pose a performance problem. I had to copy the basics by around 90% from a tutorial, but seriously... there aren't so many different ways on how to define a point or a Line. The Field of View now goes through each Point of a Line and tells if the tile is visible or not. Everything depends on a) the Vision radius, b) the tile itself and c) obstacles. For every point on the perimeter (of the vision's radius), a new Line is created. Then, for each line, we go from the player towards the end point.

Continue reading

Time System

Now the big question: what Time System will it have? How will turns or actions be handled?

First off, I found a small listing of different methods here .Easy enough to get started? Nope. I sure want something to happen that is described as "Plus player time" on that list. I mean, the whole game is centered around the player. Everything is dependant on a player's move to develop. So we can rely that to the player's actions. There is still the possibility of a wait key. I think this will enable me to implement a day/night system quite easily.

But... how to start writing this? I have no idea... . Maybe I will write this later, knowing that I will need to rewrite more than half of my code? Hell, decisions like that are not easy. Maybe I could use some help there.

Save and Load – success

Seriously, I thought I would have to pick it up again at a later point, but after drinking a good sip of whiskey, I finally found the right solution.

My problem with saving and loading the world object (which contains a two-dimensional array of WorldCells, aswell as a two-dimensional array of the Tile (enum)). I totally started it the wrong way. I wanted it to output into an xml file. I used XStream for the serialization and deserialization. It gave me an xml file, 38 mb huge and of course readable and editable, which I didnt want. I succeeded, after many hours, to save the world as I wanted it, but then - this was my biggest problem- I couldn't load the file back. I was browsing the web for hours reading about enum converters and stuff. All too complicated!

Today I sat down and after 10 minutes I was done.
What did I do?
It's easy:

Continue reading