Friday, August 2, 2013

Weapons and refactoring

Game play

Weapons! Every game needs a couple of these.
Having said this, here's the problem - where the hell am I suppose to put them?
If we are talking about a PC platform, or better yet, console platform - there's no problem. Lots of screen space and multiple controls make it easy to display all existing weapons and select one for the divine task of killing some creature\character\object as part of a task or just because you can.
That is most definitely not the case when it comes to smartphone games. With very little screen space and most limited control options, there is no convenient way to display the weapons to the player without blocking some of the game view. So, what do we do now? Well, after some research i decided to go with one of the most common solutions to this kind of problems: sliding panel.
So, now the game have a weapon selection system (the technical part will follow) with an ugly looking sliding panel.
Weapon selection sliding panel
as you can see in the image above, the player (still only a green square) now have 2 weapons he can select from by simply sliding his finger from the top of the screen (in the horizontal position) a bit down and taping the weapon of his choice. He can also slide the panel back up, in case he changed his mind.
It's important to say that currently, I've decided that the weapon selection will pause the game. I'll decide whether to keep it this way or let the game continue later on (when I'll have a nice stage to practice).
Another point worth mentioning is that the shotgun in the image is only a placeholder and will not take place in the game.

Refactoring

According to Wiki, refactoring is "disciplined technique for restructuring an existing body of code, altering its internal structure without changing its external behavior". What it doesn't said is that it's a great deal of messing around, deleting code, removing code from one place and adding it to some other class while praying to the great Flying Spaghetti Monster that this change won't ruin everything.
And why am I putting the refactoring and weapons in the same post? Because that's what I had to do in order to make the weapon selection system.
In the beginning, it seems like a good and logical idea for the player to hold all of his weapons (that he collected during the game). However, in order to implement the selection system as an independent being, the weapons had to go somewhere else (unless I wanted to pass the player object around pretty much everything and set his weapon collection as public field for everyone to use).
To make a long story short, I'll just say that it's a good idea to spend an extra day or two on creating a good design document - it can save you a ton of time later on.
The panel itself was easy enough to implement (on the technical view). In fact, it was so easy that I think I'll make the game controllers (pause, resume, exit and start over) in a similar way. (Only with the panel on the left)

More weapons

Back to the weapons. Two more questions remain open on this subject:
a. How and when does the player get a weapon?
b. What weapons should I make and how they'll affect the game objects?

Answering the first question is quite easy. What I had in mind is that the player will receive weapons upon an ending of specific stages or quests. For example, let say that the player has to convince an alien (the ones from outer space, not from another country) to join his cause. If he succeeds, he'll get an anti-gravity gun or something like that.
The second question is much more difficult. What I had in mind so far is: Axe, Anti-gravity gun (to lift up some of the blocking objects), Crossbow (because it's one of the coolest weapons ever) and a frying pan. (If he kills a cow with it, he'll get more health point because the meat will be tastier).
If you have any ideas, feel free to comment on the post and suggest them.
I'll also had a couple of "power ups" in mind such as Anti-depression pills (will lower the guilt) and a "Crazy pills" (don't have a better name yet) that will allow him to kill everything without guilt for some time, but then he'll feel more guilty for each action.

2 comments:

  1. How about a see-through sliding panel (opaque)?

    ReplyDelete
  2. Yey! First comment in this blog.
    To the point - the see through sliding panel is exactly what I had in mind for the game. However, since it'll still block about 1/4 of the screen (no matter if it's half clear), I figured that "full" panel will do the trick for the prototype.
    But I guess that with see-through panel I won't have to pause the game for the weapon selection.

    ReplyDelete