【GAMEMAKER】Branching Dialogue

 Information about object: obj_diag_set_up_and_splash

Sprite:
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent:
Children:
Mask:
No Physics Object
Create Event:
execute code:

///set up array to hold data
// 1 question
// 2 answer a
// 3 answer b
// 4 answer a target [0 is none]
// 5 answer b target [0 is none]
global.diag[1,1]="Are you in a good mood?";
global.diag[1,2]="Yes, I'm in great mood.";
global.diag[1,3]="No, I'm sad.";
global.diag[1,4]=2;
global.diag[1,5]=3;

global.diag[2,1]="That's great!#Would you like#some cheese?";
global.diag[2,2]="Yyes, I love cheese.";
global.diag[2,3]="No. I'll pass.";
global.diag[2,4]=4;
global.diag[2,5]=5;

global.diag[3,1]="Too bad.#Can I sing#you a song?";
global.diag[3,2]="Yes. Sing me a#shanty song.";
global.diag[3,3]="No. I'd rather you didn't.";
global.diag[3,4]=6;
global.diag[3,5]=7;

global.diag[4,1]="Brie or stilton?";
global.diag[4,2]="Brie, please.";
global.diag[4,3]="Stilton, please.";
global.diag[4,4]=10;
global.diag[4,5]=8;

global.diag[5,1]="How about some gold?";
global.diag[5,2]="Yes, i'm after gold.";
global.diag[5,3]="No, i have enough already.";
global.diag[5,4]=11;
global.diag[5,5]=14;

global.diag[6,1]="Yo ho ho &#a bottle of rum.#Want some rum?";
global.diag[6,2]="Yes. Hmm rum.";
global.diag[6,3]="No. I don't drink.";
global.diag[6,4]=15;
global.diag[6,5]=12;

global.diag[7,1]="OK. Want to go fishing?";
global.diag[7,2]="Yes. Sounds good!";
global.diag[7,3]="No. Fishing is boring.";
global.diag[7,4]=9;
global.diag[7,5]=13;

global.diag[8,1]="Yuck! I prefer brie.##[r to restart]";
global.diag[8,2]="";
global.diag[8,3]="";
global.diag[8,4]=0;
global.diag[8,5]=0;

global.diag[9,1]="Awesome! I'll get my rod.##[r to restart]";
global.diag[9,2]="";
global.diag[9,3]="";
global.diag[9,4]=0;
global.diag[9,5]=0;

global.diag[10,1]="Great choice!##[r to restart]";
global.diag[10,2]="";
global.diag[10,3]="";
global.diag[10,4]=0;
global.diag[10,5]=0;

global.diag[11,1]="Here's 1,000 coins.##[r to restart]";
global.diag[11,2]="";
global.diag[11,3]="";
global.diag[11,4]=0;
global.diag[11,5]=0;

global.diag[12,1]="Probably for the best!##[r to restart]";
global.diag[12,2]="";
global.diag[12,3]="";
global.diag[12,4]=0;
global.diag[12,5]=0;

global.diag[13,1]="OK be boring then!##[r to restart]";
global.diag[13,2]="";
global.diag[13,3]="";
global.diag[13,4]=0;
global.diag[13,5]=0;

global.diag[14,1]="No gold! Your choice.##[r to restart]";
global.diag[14,2]="";
global.diag[14,3]="";
global.diag[14,4]=0;
global.diag[14,5]=0;

global.diag[15,1]="Don't drink too much!##[r to restart]";
global.diag[15,2]="Continue";
global.diag[15,3]="";
global.diag[15,4]=16;
global.diag[15,5]=0;

global.diag[16,1]="Maybe just have a coffee.##[r to restart]";
global.diag[16,2]="";
global.diag[16,3]="";
global.diag[16,4]=0;
global.diag[16,5]=0;




global.message=1;
global.gold=0;
room_goto(room_dialogue);
Information about object: obj_button_one
Sprite: spr_button
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent:
Children:
Mask:
No Physics Object
Mouse Event for Left Released:
execute code:

///Example Do Something - ie choose yes to question 5
if global.message==5
{
global.gold+=1000;
}
//for every click
global.message=global.diag[global.message,4];

Draw Event:
execute code:

if global.diag[global.message,2]!=""
{
var width=string_width(global.diag[global.message,2]);
if width>50 // adjust image size if a long text option
{
var size=(250+(width-50))/250
image_xscale=size;
}
draw_self();
draw_set_font(font_message);
draw_set_halign(fa_center);
draw_set_valign(fa_middle);
draw_set_colour(c_black);
draw_text(x,y,global.diag[global.message,2]);
}
Information about object: obj_button_two
Sprite: spr_button
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent:
Children:
Mask:
No Physics Object
Mouse Event for Left Pressed:
execute code:

global.message=global.diag[global.message,5];
Draw Event:
execute code:

if global.diag[global.message,3]!=""
{
var width=string_width(global.diag[global.message,3]);
if width>50 // adjust image size if a long text option
{
var size=(250+(width-50))/250
image_xscale=size;
}
draw_self();
draw_set_font(font_message);
draw_set_halign(fa_center);
draw_set_valign(fa_middle);
draw_set_colour(c_black);
draw_text(x,y,global.diag[global.message,3]);
}
Information about object: obj_show_message
Sprite: spr_message_bg
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent:
Children:
Mask:
No Physics Object
Step Event:
execute code:

if keyboard_check_released(ord('R'))
{
game_restart();
}
Draw Event:
execute code:

draw_self();
draw_set_font(font_message_big);
draw_set_halign(fa_center);
draw_set_valign(fa_middle);
draw_set_colour(c_black);
draw_text(x,y,global.diag[global.message,1]);
Information about object: obj_gold_hud
Sprite:
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent:
Children:
Mask:
No Physics Object
Draw Event:
execute code:

draw_set_font(font_message_big);
draw_set_halign(fa_center);
draw_set_valign(fa_middle);
draw_set_colour(c_black);
draw_text(room_width/2,room_height-50,"Gold: "+string(global.gold));

No comments:

How the New York Times led to the fall of Assad

Anti-semitism by the New York Times actually made Israel safer ͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­...

Contact Form

Name

Email *

Message *