Jump to content


Photo

Dialogue Example you have to test


  • Please log in to reply
No replies to this topic

#1 dh0k0

dh0k0

    GMC Member

  • New Member
  • 8 posts

Posted 13 September 2012 - 01:48 PM

This and old dialogue example fromg gamemaker 5.3a and yeah it is work on game maker 6 and 8

I use it in every one of my games now when I need to make conversations. So here it is...remember you delete what i have in the (), those are just to tell you what goes there...just to say, this script is based on 32 by 32 head boxes (where the speakers face goes).

create event:
speaker = ??? //(here you put the name of the sprite of the speaker's head)
i=1;
nwText="";
myText="???" //(what the person is saying)
flip = 1


step event:

nwText=nwText+string_char_at(myText,i);
i+=1; //(nothing to put here, keep it the way it is)

draw:

draw_sprite(speaker,-1,0,0)
draw_text(34,0,nwText); //(change nothing here either)

pressbutton:
if flip = 1
{i = 1;
nwText="";
myText="???" //(put something to say here)
speaker = ??? //(any of the speaker sprites names with the heads)
flip = flip+1
exit;}

if flip = 2
{i = 1
nwText="";
myText="???" //(same thing as the thing above)
speaker ="???" //(same thing as the thing above)
flip = flip+1
exit;}
to keep making more text, just make more of those things in the press button event. you add 1 to the amount of the IF FLIP= each time you make another pressbutton "if flip" action.
-------------------------------------------
Well, instead of using all of those if statements, you can use arrays, and also, you can remove the STEP event and put it's contents into the DRAW event.
Here's a suggestion of mine for the code (all I did was revise it up):

CREATE event:
//The Stuff you change
dialogs = 4; //The number of dialogs, in this case, it's 4.
speaker[1] = [face0]; //Here you put the name of the sprite of the speaker's head Speaker #1
myText[1] = "Woohoo! Dialog! Yay!!!!!!!!"; //What the person is saying
speaker[2] = [face1]; //Speaker #2 sprite
myText[2] ="Yay! I can speak! I'm a real string now!";
speaker[3] = [face0]; //Speaker #1 sprite
myText[3] = "Just shaddup, 'kay?";
speaker[4] = [face1]; //Speaker #2 sprite
speaker[4] = "I don't wanna!";
//And so on...
i = 1;
flip = 1;
nwText="";

DRAW event:
//Remember, 'flip' is the current dialog!
nwText = nwText + string_char_at(myText[flip],i);
i+=1; //Nothing to put here, keep it the way it is
draw_sprite(speaker[flip],-1,0,0);
draw_text(34,0,nwText); //Change nothing here either

PRESSBUTTON ? event:
if (flip < dialogs && i>=string_length(myText[flip]) {
//Set the new dialog.
i = 1;
nwText="";
flip += 1;
}



Posted Image

Uploaded with ImageShack.us
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users