Hello, Gwen.

Posted on February 16, 2012 | 6 minute read

I kind of started this thing last night.

First, I should probably think of some way to refer to this thing when I write about it in a way that doesn’t give away the entire concept. I have a feeling calling it “thing” or “project” or “it” is going to get very old very quickly. At the same time though, giving it a name is kind of like making a commitment. Seeing as I don’t actually know what I’m doing and have no clue how or when or if I’ll even finish, it seems risky. Oh well, I still don’t want to keep calling it “it” all the time.

Let’s just call it Gwen for now - the NPC that I most associate with Guild Wars: Prophecies. First introduced in pre-Searing Ascalon, Gwen was always the most memorable for me; like the NPC representative of the entire series. I really need to finish EotN and Beyond to see where she ended up.

Anyway, here’s what I actually did last night.

Installed Git and set up GitHub

Houston - we have version control.

The Git installation was mostly painless except for my having to run the .dmg twice before it actually installed properly. Thanks to the awesome people of Twitter for helping me troubleshoot. It did work in the end! I now have a working private repository and while I’m still getting the hang of pushing and such through the terminal, several commits have successfully been made.

Yesterday’s list

In yesterday’s post I had a list of things I had to learn as a first step to coding this thing:

  • Detect mouse clicks onto an entity

  • Store entity coordinates into array when clicked

  • Remove coordinates from array when the entity is clicked a second time

And happily all of the above have been accomplished! I didn’t really expect to get them done in one day (although I know all of the above would be very simple for an actual programmer, for me it’s more like stabbing in the dark until something works. It takes forever to pin the tail on that donkey).

First I should say that I haven’t been doing this alone. I Googled the heck out of this (yesterday morning I had no idea what push() and pop() were) and my friend CODENAMEX helped get the idea of what I have to learn to do straight in my head as I bounced my dodgy brainstorming off of him. I modified the final concept slightly when actually coding it when I saw how to best handle these things in Impact, but much advice was definitely had in terms of general structure. Stew, whom I originally met in the Impact IRC channel, also gave some awesome pointers.

It’s interesting to be able to actually talk to people fairly openly about individual mechanics in Gwen as opposed to the last thing. I certainly don’t want anyone to do anything for me, but am already finding general advice invaluable. It never ceases to amaze me just how much you can learn in a short amount of time from people who actually know what they’re doing.

So:

Detect mouse clicks onto an entity

I did this by creating a pointer entity that is 1px x 1px and follows the cursor at all times. When the left mouse button is clicked, the pointer entity checks against whatever other entity it is touching and triggers a function in the clicked entity accordingly.

Store entity coordinates into array when clicked

I modified this slightly. Instead of storing coordinates, I’m storing the entire entity that’s being clicked itself (presumably I’ll then just be able to pull its attributes out as needed). I created an array in the pointer entity that is empty by default and scattered a couple of node entities that are meant to be selectable on the map. When the pointer checks against a node, it stores that node in its array via push() and changes the visual appearance of the node to signal that it’s active/selected.

Remove coordinates from array when the entity is clicked a second time

When the entity is clicked a second time things got a little more tricky for me. Setting it up to remove the last set of coordinates with pop() was easy. However, I don’t want the player to be able to just deselect any currently selected node. I need them to only be able to deselect the last selected node that they clicked (so deselect the nodes in the order in which they selected them).

Click counter

I did this by creating a click counter in the node entity. The click counter is set to 0 by default.

  • A click on the node is detected.

  • If the click counter is 0 the node is added to the array. The click counter then goes up to 1.

  • If the click counter is 1 when the node is clicked again and the node is the last one stored in the array, it gets deselected and removed from the array with the pop() method.

  • The click counter is then set back to 0

  • If the node that is clicked a second time is not the last node in the array, nothing happens and the node remains active. The player can then click on the nodes to deactivate them in order.

Go button

This wasn’t on the above list, but I also added a Go button…it doesn’t do anything yet, just prints a message to the console.

The thing is that visually right now all of the above just looks like a couple of boxes on the screen. Nevertheless, I made these boxes. They are mine and they do things, so I am happy: [caption id="attachment_47201” align="aligncenter” width="300” caption="Boxy."]Gwen screenshot 1[/caption]

Next

Right now I’m pretty apprehensive about my abilities to code this thing. Just thinking about this array stuff bent my brain yesterday and I’ve already learned a lot, but it’s not even a tiny fraction of what still has to be done. I should note that the idea itself does not involve overly convoluted or complex gameplay. In fact, the overall concept is pretty simple. It’s the making of it that is going to be difficult.

At this stage I can’t really be too specific about exact things I need to do here as they would start revealing a little too much of the gameplay, but I’ll keep posting updates on isolated mechanics as I learn them.




Categories:game dev dev games
comments powered by Disqus