player scripting, adding a 'crawl' onto to script

Game Editor comments and discussion.

player scripting, adding a 'crawl' onto to script

Postby PooAs » Fri Apr 25, 2008 3:01 am

well..
this is my main player script
which makes him walk, and jump.

Code: Select all
char*key=GetKeyState();
int spd = 5;
lay = 0;
yvelocity += gravity;
if(damage > 100)DestroyActor("Event Actor");
if(wt > 0)wt--;
else
if(key[KEY_LEFT] == 1 && key[KEY_RIGHT] == 0)
{
    if(j == 0 && xvelocity > -spd)xvelocity--;
    if(j == 1)x -= spd;
    if(ld == 1)
    {
        ld = 0;
        af = 1;
    }
    if(af == 1)
    {
        ChangeAnimation("Event Actor", "RANDAL- pistols left walk 1", FORWARD);
        af = 0;
    }
}
if(key[KEY_LEFT] == 0 && key[KEY_RIGHT] == 1)
{
    if(j == 0 && xvelocity < spd)xvelocity++;
    if(j == 1)x += spd;
    if(ld == 0)
    {
        ld = 1;
        af = 1;
    }
    if(af == 1)
    {
        ChangeAnimation("Event Actor", "RANDAL- pistols right walk 1", FORWARD);
        af = 0;
    }
}
if(key[KEY_LEFT] == 0 && key[KEY_RIGHT] == 0)
{
    af = 1;
    if(ld == 0)ChangeAnimation("Event Actor", "RANDAL pistol left", FORWARD);
    else ChangeAnimation("Event Actor", "RANDAL pistol right", FORWARD);
}
if(key[KEY_LEFT] == 1 && key[KEY_RIGHT] == 1)
{
    af = 1;
    if(ld == 0)ChangeAnimation("Event Actor", "RANDAL pistol left", FORWARD);
    else ChangeAnimation("Event Actor", "RANDAL pistol right", FORWARD);
}
if(j == 1 && key[KEY_z] == 1)
{
    if(key[KEY_LEFT] == 1)xvelocity = -spd;
    if(key[KEY_RIGHT] == 1)xvelocity = spd;
    yvelocity = -(gravity * 13);
    j = 0;
 
}


..

as you can see i added a varibale "lay = 0;"
im trying to add when down is held down my actor crawls
but im having a whole heap of trouble adding it into my code.
i have already added in

keydown- down = lay = 1
keyup - down = lay = 0

any ideas?
If you try
to fix violence
with violence
you do nothing
but create violence
User avatar
PooAs
 
Posts: 29
Joined: Thu Apr 03, 2008 10:24 am
Score: 3 Give a positive score

Re: player scripting, adding a 'crawl' onto to script

Postby Caaz Games » Fri Apr 25, 2008 3:25 am

well all that script is above me but what i do is put it like this
Code: Select all
if(lay==0)
{
         //Put the walk code here
}
if(lay==1)
{
         //Put the crawl code here
}
You are welcome to join my forum. 4 active members lol but it's a cool place. active... much talking :D it's fun!
http://caaz.freeforums.org/
User avatar
Caaz Games
 
Posts: 729
Joined: Wed Feb 14, 2007 9:09 am
Location: California....knows how to party!
Score: 25 Give a positive score

Re: player scripting, adding a 'crawl' onto to script

Postby PooAs » Fri Apr 25, 2008 4:34 am

Thanks man
i put my script in like you said
..
Code: Select all
char*key=GetKeyState();
int spd = 5;
lay = 0;
yvelocity += gravity;
if(damage > 100)DestroyActor("Event Actor");
if(wt > 0)wt--;
else


if(lay==0)
{
if(key[KEY_LEFT] == 1 && key[KEY_RIGHT] == 0)
{
    if(j == 0 && xvelocity > -spd)xvelocity--;
    if(j == 1)x -= spd;
    if(ld == 1)
    {
        ld = 0;
        af = 1;
    }
    if(af == 1)
    {
        ChangeAnimation("Event Actor", "RANDAL- pistols left walk 1", FORWARD);
        af = 0;
    }
}
if(key[KEY_LEFT] == 0 && key[KEY_RIGHT] == 1)
{
    if(j == 0 && xvelocity < spd)xvelocity++;
    if(j == 1)x += spd;
    if(ld == 0)
    {
        ld = 1;
        af = 1;
    }
    if(af == 1)
    {
        ChangeAnimation("Event Actor", "RANDAL- pistols right walk 1", FORWARD);
        af = 0;
    }
}
if(key[KEY_LEFT] == 0 && key[KEY_RIGHT] == 0)
{
    af = 1;
    if(ld == 0)ChangeAnimation("Event Actor", "RANDAL pistol left", FORWARD);
    else ChangeAnimation("Event Actor", "RANDAL pistol right", FORWARD);
}
if(key[KEY_LEFT] == 1 && key[KEY_RIGHT] == 1)
{
    af = 1;
    if(ld == 0)ChangeAnimation("Event Actor", "RANDAL pistol left", FORWARD);
    else ChangeAnimation("Event Actor", "RANDAL pistol right", FORWARD);
}
}
if(j == 1 && key[KEY_z] == 1)
{
    if(key[KEY_LEFT] == 1)xvelocity = -spd;
    if(key[KEY_RIGHT] == 1)xvelocity = spd;
    yvelocity = -(gravity * 13);
    j = 0;
}
else

if(lay==1)
{
if(key[KEY_LEFT] == 1 && key[KEY_RIGHT] == 0)
{
    if(j == 0 && xvelocity > -spd)xvelocity--;
    if(j == 1)x -= spd;
    if(ld == 1)
    {
        ld = 0;
        af = 1;
    }
    if(af == 1)
    {
        ChangeAnimation("Event Actor", "RANDAL- pistols left walk 1", FORWARD);
        af = 0;
    }
}
if(key[KEY_LEFT] == 0 && key[KEY_RIGHT] == 1)
{
    if(j == 0 && xvelocity < spd)xvelocity++;
    if(j == 1)x += spd;
    if(ld == 0)
    {
        ld = 1;
        af = 1;
    }
    if(af == 1)
    {
        ChangeAnimation("Event Actor", "RANDAL- pistols right walk 1", FORWARD);
        af = 0;
    }
}
if(key[KEY_LEFT] == 0 && key[KEY_RIGHT] == 0)
{
    af = 1;
    if(ld == 0)ChangeAnimation("Event Actor", "RANDAL_crawling_left", FORWARD);
    else ChangeAnimation("Event Actor", "RANDAL_crawling_right", FORWARD);
}
if(key[KEY_LEFT] == 1 && key[KEY_RIGHT] == 1)
{
    af = 1;
    if(ld == 0)ChangeAnimation("Event Actor", "RANDAL_crawling_left", FORWARD);
    else ChangeAnimation("Event Actor", "RANDAL_crawling_right", FORWARD);
}
if(j == 1 && key[KEY_z] == 1)
{
    if(key[KEY_LEFT] == 1)xvelocity = -spd;
    if(key[KEY_RIGHT] == 1)xvelocity = spd;
    yvelocity = -(gravity * 13);
    j = 0;
 
}
}




it all works but
the lay==1 does the same as lay==0
????
If you try
to fix violence
with violence
you do nothing
but create violence
User avatar
PooAs
 
Posts: 29
Joined: Thu Apr 03, 2008 10:24 am
Score: 3 Give a positive score

Re: player scripting, adding a 'crawl' onto to script

Postby Caaz Games » Fri Apr 25, 2008 4:38 am

on keydown event it has lay=1 on it right?

== checks the thing and = makes it that way
Like this
key down>DownBttn>Script
Code: Select all
Lay=1

then it should change the action
You are welcome to join my forum. 4 active members lol but it's a cool place. active... much talking :D it's fun!
http://caaz.freeforums.org/
User avatar
Caaz Games
 
Posts: 729
Joined: Wed Feb 14, 2007 9:09 am
Location: California....knows how to party!
Score: 25 Give a positive score

Re: player scripting, adding a 'crawl' onto to script

Postby PooAs » Fri Apr 25, 2008 8:57 am

thanks caaz :)
If you try
to fix violence
with violence
you do nothing
but create violence
User avatar
PooAs
 
Posts: 29
Joined: Thu Apr 03, 2008 10:24 am
Score: 3 Give a positive score

Re: player scripting, adding a 'crawl' onto to script

Postby Caaz Games » Fri Apr 25, 2008 7:15 pm

no problem Image glad to help no off to my secret game Image
You are welcome to join my forum. 4 active members lol but it's a cool place. active... much talking :D it's fun!
http://caaz.freeforums.org/
User avatar
Caaz Games
 
Posts: 729
Joined: Wed Feb 14, 2007 9:09 am
Location: California....knows how to party!
Score: 25 Give a positive score


Return to GE - General

Who is online

Users browsing this forum: No registered users and 1 guest

cron