How to make interactive text\dialog.

Questions, comments and discussion about the Game Editor development.

How to make interactive text\dialog.

Postby mindcontrol » Sun Apr 26, 2015 5:03 pm

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)
mindcontrol
 
Posts: 24
Joined: Sun Apr 26, 2015 12:54 pm
Score: 2 Give a positive score

Re: How to make interactive text\dialog.

Postby koala » Sun Apr 26, 2015 5:38 pm

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
Attachments
dialog Windows exe.zip
Windows executable
(768.64 KiB) Downloaded 148 times
dialog source.zip
source (ged and data files)
(72.1 KiB) Downloaded 139 times
Phascolarctos cinereus
YouTube: Marko Radivojevic
Google+: Marko Radivojevic
User avatar
koala
 
Posts: 301
Joined: Thu Mar 26, 2015 7:03 pm
Location: Serbia
Score: 30 Give a positive score

Re: How to make interactive text\dialog.

Postby mindcontrol » Sun Apr 26, 2015 5:47 pm

Thank you, i'll try :D
mindcontrol
 
Posts: 24
Joined: Sun Apr 26, 2015 12:54 pm
Score: 2 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest