How to make a verbcoin from scratch?

Started by silverwolfpet, Tue 08/02/2011 15:07:06

Previous topic - Next topic

silverwolfpet

Hi!

I have searched the forums for about 3 days, I have read most of the threads that contain the words "Verb coin". Apparently many people use the verb coin template. Which is very nice of them... but I need to figure out how to make a verb coin from scratch.

I've googled it, I've looked everywhere before posting here. I really am lost. My game is created with the idea that I want to learn how to do stuff, to explore ags, I love this program. That's why I didn't use the verbcoin template from the beginning.

Some guidance would be much appreciated, please and thank you.

On a side note, once I figure this out, I can release a small demo (with pictures and everything, don't worry Mr. Moderators, I've been haunting these forums for so long, I can RECITE the regulations).

So, ummm, anyone? Please? I've got cookies!

monkey0506

Ahhhhh..Andrei!!

Listen.

A verb coin interface is not the simplest for someone who is not an experienced programmer. Why do you want to do this yourself from scratch? Are you trying to teach yourself programming in lieu of myself since I have failed you so miserably? D:

Essentially the idea is that when the mouse is clicked over something, you're going to start a timer based on a predetermined delay to figure out whether the player is holding the mouse down or if they only just clicked it. Once that timer has expired then you're going to see if the mouse button is still held down. If it is, then you're going to display the GUI used by the verb coin; otherwise you're going to execute the "normal" action (i.e., walking).

If the verb coin GUI is displayed, then you're going to constantly check what button on the GUI the mouse is over, and make sure that the mouse is still held down. When the mouse button is released over a button, then you will process the interaction associated with that button.

If you program this statically, meaning you design your interface around only very specific buttons, then it would be simpler, but much more difficult if you change anything about the interface later. Programming it generically though would not be an easy task for a relatively new programmer.

Personally, I would recommend that you wait a couple days for me to release the verb coin script that I've been working on and just use that. := ..but I might be biased.

Khris

As with all coding problems you start with a flow diagram of sorts.

First of all you create the verbcoin GUI. Then you get it to pop up at the mouse position when the left mouse button is held down over an active location.

Then you store the coordinates of the original click and whether the mouse is currently held down.

If the mouse button is released or the mouse is moved outside the verbcoin, remove it. In the former case, check the button under the mouse, if there is one, execute the action.

Code: ags
bool mouse_down;
int mx, my;

function repeatedly_execute() {

  // verbcoin button down?
  bool mbd = mouse.IsButtonDown(eMouseLeft);

  // open verbcoin
  if (mbd && !mouse_down && Game.GetLocationType(mouse.x, mouse.y) != eLocationNothing) {
    mouse_down = true;
    // store coordinates of original click
    mx = mouse.x;
    my = mouse.y;
    gVerbCoin.SetPosition(mx - 20, my - 20);
    gVerbCoin.Visible = true;
  }

  // reset variable if mouse key not down any longer
  if (!mbd && mouse_down) mouse_down = false;

  // handle verbcoin
  GUI*g = GUI.GetAtScreenXY(mouse.x, mouse.y);
  GUIControl*gc = GUIControl.GetAtScreenXY(mouse.x, mouse.y);

  if (gVerbCoin.Visible) {
    // turn off
    if (!mbd || g != gVerbCoin) {
      gVerbCoin.Visible = false;

      // released over verbcoin button?
      if (gc != null && gc.OwningGUI = gVerbCoin) {
        if (gc == bLook) ProcessClick(mx, my, eModeLookat);
        if (gc == bInteract) ProcessClick(mx, my, eModeInteract);
        if (gc == bTalk) ProcessClick(mx, my, eModeTalkto);
      }
    }
  }
}


(Not tested, there's probably some bugs in there, but should get you started.)

silverwolfpet

#3
Wow, thanks guys!

Hehe, I didn't really expect you to see this post, Mr. Mighty Programmer, I just didn't want to bother you :) If you're releasing a script, that's brilliant, I could sure use that.

In the meantime, just for my sake, I will try to learn what you and Khricey said, see if I can come up with something.Worst case scenario, at least I learn some stuff.

I'm really into this game and I really really want to see it finished! Thank you for the help!

EDIT: I just learned that I'm better at writing novels than writing code. It's a start, right?

silverwolfpet

On a side note, towards the moderator that moved this... ummm, it's NOT a beginner's question. Did you notice the code necessary for this kind of thing?!

Well, either way, if you think I can get better answers there...sure, why not. I'm just smashing my head against the keyboard.

Khris

Actually, the code is pretty basic. And since you are a beginner with a technical question (as opposed to a proficient coder who got stuck doing advanced stuff), what better place to ask that question than the forum labeled "Beginner's Technical Questions"? ;)

You seem to have talked to monkey quite a bit, so I'll leave it at saying that you shouldn't focus on a verbcoin so much; as soon as you learn the basics including how to tackle a coding problem, implementing a verbcoin isn't that big a deal.

silverwolfpet

Oook Khris :p I understand now, sorry, hehehe. And thanks again for the info.

Monkey, when do you think your verbcoin script will be ready? o.O

monkey0506

I'm actually working on a small demo game in the form of a template and then I'll create a thread. I basically want to showcase the various features that I've implemented. The game itself will be terrible.

For right now I think the only thing I have left is trying to do something with the inventory (for the demo). I might be able to finish that today actually.

..and I should try and take a look at your tech demo that you sent me. I'm still too busy with my life (and personal projects) to recommit myself to your project, but I would be more than happy to be your personal consultant haha.

silverwolfpet

Consider it done, Mr. Personal Consultant. Do you want a fancy name in the credits, like Consiglieri? Or whatever the mafia calls the "Family Consultant" :p

I feel kind of childish fooling around with code and trying to learn how to do this, even though I know I'm totally anti-talented at this. I appreciate any help I can get. Once I finish the verbcoin and the walking-talking animations...we're ready to go! Really! Everything is set, including the story and the puzzles on half the game. We can start building upon all that. :D

Now I'll get back to the animations. Walking cycles...bleeeehhh...

monkey0506

Ah, Andrei you're one of the most persistent people I know of. Even if you don't know how to accomplish something you're gonna get it done anyway, no matter how long it takes. :)

Well, the thing has gone public, so grab yours now while you still can!

SMF spam blocked by CleanTalk