Page 1 of 1

How to make interactive text\dialog.

PostPosted: Sun Apr 26, 2015 5:03 pm
by mindcontrol
Hi, i'm trying to make my first game, but i'm locked and I don't know how to make a NPC speak (like pokemon for ex, when u speak with people by pressing A).
Can someone help me? (i don't have any experience with scritping, i was able only to make the PG move and collide thanks to some tutorial)

Re: How to make interactive text\dialog.

PostPosted: Sun Apr 26, 2015 5:38 pm
by koala
mindcontrol wrote:Hi, i'm trying to make my first game, but i'm locked and I don't know how to make a NPC speak (like pokemon for ex, when u speak with people by pressing A).
Can someone help me? (i don't have any experience with scritping, i was able only to make the PG move and collide thanks to some tutorial)
Well, first you could make an actor where dialog will be. Place that actor outside the view.
Next, when your player collides with a NPC, you could place the dialog in the view. You'll also need to change text. For example:
Code: Select all
dialog.x = -200;
dialog.y = -200;

sprintf(dialog.text, "NPC: Hi! I am NPC!\n[SPACE]");

EventDisable("Event Actor", EVENTKEYDOWN); // EventDisable("player", EVENTKEYDOWN); - player can't move

i = 1; // i is int variable in Global Code
You should leave "Repeat this event while actor is colliding:" on "No".

When you press [SPACE], or whatever key you prefer:
Code: Select all
switch (i) {
    case 1: sprintf(dialog.text, "Player: Hi! I am Player!\n[SPACE]"); break;
    case 2: sprintf(dialog.text, "NPC: How are you?!\n[SPACE]"); break;
    case 3: sprintf(dialog.text, "Player: I am fine. And you?\n[SPACE]"); break;
    case 4: sprintf(dialog.text, "NPC: Great! Although I don't look like that.\n[SPACE]"); break;
    case 5: sprintf(dialog.text, "Player: See ya! BYE!\n[SPACE]"); break;
    case 6: EventEnable("player", EVENTKEYDOWN); // player can move
            dialog.x = 200;
            dialog.y = 500;
            break;
}

i++;


source (ged and data files)
Windows executable

Re: How to make interactive text\dialog.

PostPosted: Sun Apr 26, 2015 5:47 pm
by mindcontrol
Thank you, i'll try :D