Help with some code...

Talk about making games.

Help with some code...

Postby Eliminator » Mon Jul 28, 2008 11:04 pm

There is a code (Dialogue - a face of speaker, a text and a background in the bottom of screen).
GLOBAL CODE:
Code: Select all
void talk(int npcid)
{
    Dialogue.x=Guy.x; //Place the dialogue box near the guy
    Dialogue.y=Guy.y;
    if(npcid==1 && pultquest==0)//Beavis and Butthead
    {
        ChangeAnimation("DialFace", "Beavis", FORWARD); //Beavis says "Slysh baklan!" (translit)
        strcpy(DialText.text,"Slysh baklan!");
        Dialog(); //pause
        strcpy(DialText.text, "My poteriali 3 pylta ot teleka!");
        Dialog();
        ChangeAnimation("DialFace", "Butthead", FORWARD); //Butthead face
        strcpy(DialText.text,"Eto polnyi otstoi :(");
        Dialog();
        ChangeAnimation("DialFace", "Beavis", FORWARD);
        strcpy(DialText.text,"Naidi ix i prinesi nam za $100");
        Dialog();
        Dialogue.x=2000; //Kick the dialogue box out of here
        Dialogue.y=2000;
        pultquest=1; //activate the quest
    }
}


Dialog(); pauses the game and shows the Unpause button.

And NPC, Beavis and Butthead - code: talk(1);

"Dialogue" is the filled region and is a parent of all elements - Face, background and text

But works only "ChangeAnimation" and Dialog()... GE ignores the strcpy and Dialogue.x=Guy.x; Dialogue.y=Guy.y;. Why?
Eliminator
 
Posts: 9
Joined: Sun Jul 27, 2008 11:37 am
Score: 4 Give a positive score

Re: Help with some code...

Postby feral » Mon Jul 28, 2008 11:56 pm

Eliminator wrote:But works only "ChangeAnimation" and Dialog()... GE ignores the strcpy and Dialogue.x=Guy.x; Dialogue.y=Guy.y;. Why?


this is a common first time mistake so don't worry too much :)

OK... not sure exactly why some of the code doesn't work.. but I can tell you the ChangeAnimation doesn't really work either..

if you tried to change back to Beavis ie: a third change, you would have notice that the only animation you had was of beavis.

the dialogue and dialogue box are also moved into screen, then out of screen, before the next redraw

this is because the function is run "in-between" draws, so only the last animation and last move would be drawn.

basically most of the action happening in the function, really needs to happen over several screen "draws"

to "move" the dialogue box your function could set global variables, rather then attempt to move the items directly,
eg : set two new global variables DialX,DialY and a flag DialShows
then in the function

dialX=Guy.x
dialY=Guy.y
DialShows=1

then use the draw script of the dialogue to position it
if (DialShows==1)
{
x=DialX
y=DialY
}
else
{
y=x=2000;
}

I'll let you work on the rest :) your coding skills seem to be up to the task :)
User avatar
feral
 
Posts: 308
Joined: Sun Mar 16, 2008 6:27 am
Score: 47 Give a positive score

Re: Help with some code...

Postby Eliminator » Tue Jul 29, 2008 9:42 am

OMG cool thanks. Here is a windows executable of my program. Inventory system, experience, dialogue ( :D ).
Attachments
SuperRoleplaySystem.zip
(845.88 KiB) Downloaded 92 times
Eliminator
 
Posts: 9
Joined: Sun Jul 27, 2008 11:37 am
Score: 4 Give a positive score


Return to Game Development

Who is online

Users browsing this forum: No registered users and 1 guest

cron