here is the code for my SamuraiDude game,
it allows you to pick between 2 players by just changing one variable.
"Select"
in the menu you change character select.
aftwer you press enter if you have one of the 2 character options selected it will set characterselect to select.
here is the draw actor code:
- Code: Select all
char*key=GetKeyState();
if(Select == 0)
{
yvelocity += 1;
if(SLASH == 0)
{
if(key[KEY_LEFT] == 1 && key[KEY_RIGHT] == 0)
{
gs = 0;
if(j == 0)x -= 5;
if(j == 1 && xvelocity > - 5 && hw == 0)xvelocity -= 1;
if(af == 1 && key[KEY_DOWN] == 0 && j == 0)
{
ChangeAnimation("Event Actor", "WL", FORWARD);
af = 0;
}
if(af == 1 && key[KEY_DOWN] == 0 && j == 1)
{
ChangeAnimation("Event Actor", "JL", FORWARD);
af = 0;
}
if(af == 1 && key[KEY_DOWN] == 1 && j == 0)
{
ChangeAnimation("Event Actor", "CL", FORWARD);
af = 0;
}
}
if(key[KEY_LEFT] == 0 && key[KEY_RIGHT] == 1)
{
gs = 1;
if(j == 0)x += 5;
if(j == 1 && xvelocity < 5 && hw == 0)xvelocity += 1;
if(af == 1 && key[KEY_DOWN] == 0 && j == 0)
{
ChangeAnimation("Event Actor", "WR", FORWARD);
af = 0;
}
if(af == 1 && key[KEY_DOWN] == 0 && j == 1)
{
ChangeAnimation("Event Actor", "JR", FORWARD);
af = 0;
}
if(af == 1 && key[KEY_DOWN] == 1 && j == 0)
{
ChangeAnimation("Event Actor", "CR", FORWARD);
af = 0;
}
}
}
if(key[KEY_UP] == 1 && j == 0 && SLASH < 2)
{
if(gs == 0)ChangeAnimation("Event Actor", "JL", FORWARD);
if(gs == 1)ChangeAnimation("Event Actor", "JR", FORWARD);
PlaySound2("data/jump2.wav", 0.555556, 1, 0.000000);
yvelocity = - 15;
j = 1;
}
if(key[KEY_SPACE] == 1 && SLASH == 0 && j == 0)
{
PlaySound2("data/Swipe1.wav", 0.211111, 1, 0.000000);
if(gs == 0)ChangeAnimation("Event Actor", "SLL", FORWARD);
if(gs == 1)ChangeAnimation("Event Actor", "SLR", FORWARD);
SLASH = 1;
}
if(key[KEY_SPACE] == 1 && SLASH == 0 && j == 1)
{
PlaySound2("data/Swipe1.wav", 0.211111, 1, 0.000000);
if(gs == 0)ChangeAnimation("Event Actor", "!JLSpiral", FORWARD);
if(gs == 1)ChangeAnimation("Event Actor", "!JRSpiral", FORWARD);
SLASH = 1;
}
if(SLASH == 2 && animpos > 3)
{
if(gs == 0)ChangeAnimation("Event Actor", "SL", FORWARD);
if(gs == 1)ChangeAnimation("Event Actor", "SR", FORWARD);
SLASH = 0;
}
if(yvelocity > 4)j = 1;
if(yvelocity < -3)j = 1;
if(Health <= 0)
{
Life_Count -= 1;
PlaySound2("data/click.wav", 0.255556, 4, 0.066667);
x = Spawnpoint.x;
y = Spawnpoint.y;
Health = 18;
CreateActor("effect1", "Effect2", "(none)", "(none)", 0, 0, false);
}
if(Life_Count < 0)
{
directional_velocity = 0;
SLASH = -1;
transp = .999;
ChangeAnimationDirection("Event Actor", STOPPED);
}
if(sentryCount.textNumber == 0)
{
if(distance(xscreen, yscreen, portal.xscreen, portal.yscreen) < 400)
{
if(yscreen < portal.yscreen)yvelocity += 1;
if(yscreen > portal.yscreen)yvelocity -= 2;
if(xscreen > portal.xscreen)xvelocity -= 1;
if(xscreen < portal.xscreen)xvelocity += 1;
}
}
if(key[KEY_LEFT] == 1 && key[KEY_RIGHT] == 1)
{
if(gs == 1 && af == 1)
{
ChangeAnimation("Event Actor", "SR", FORWARD);
af = 0;
}
if(gs == 0 && af == 1)
{
ChangeAnimation("Event Actor", "SL", FORWARD);
af = 0;
}
}
}
if(Select == 1)
{
yvelocity += 1;
if(SLASH == 0)
{
if(key[KEY_LEFT] == 1 && key[KEY_RIGHT] == 0)
{
gs = 0;
if(j == 0)x -= 5;
if(j == 1 && xvelocity > - 5 && hw == 0)xvelocity -= 1;
if(af == 1 && key[KEY_DOWN] == 0 && j == 0)
{
ChangeAnimation("Event Actor", "NL1", FORWARD);
af = 0;
}
if(af == 1 && key[KEY_DOWN] == 0 && j == 1)
{
ChangeAnimation("Event Actor", "NJL1", FORWARD);
af = 0;
}
if(af == 1 && key[KEY_DOWN] == 1 && j == 0)
{
ChangeAnimation("Event Actor", "NLC1", FORWARD);
af = 0;
}
}
if(key[KEY_LEFT] == 0 && key[KEY_RIGHT] == 1)
{
gs = 1;
if(j == 0)x += 5;
if(j == 1 && xvelocity < 5 && hw == 0)xvelocity += 1;
if(af == 1 && key[KEY_DOWN] == 0 && j == 0)
{
ChangeAnimation("Event Actor", "NR1", FORWARD);
af = 0;
}
if(af == 1 && key[KEY_DOWN] == 0 && j == 1)
{
ChangeAnimation("Event Actor", "NJR1", FORWARD);
af = 0;
}
if(af == 1 && key[KEY_DOWN] == 1 && j == 0)
{
ChangeAnimation("Event Actor", "NRC1", FORWARD);
af = 0;
}
}
}
if(key[KEY_UP] == 1 && j == 0 && SLASH < 2)
{
if(gs == 0)ChangeAnimation("Event Actor", "NJL1", FORWARD);
if(gs == 1)ChangeAnimation("Event Actor", "NJR1", FORWARD);
PlaySound2("data/jump4.wav", 0.555556, 1, 0.000000);
yvelocity = - 17;
j = 1;
}
if(key[KEY_SPACE] == 1 && SLASH == 0 && j == 0)
{
PlaySound2("data/Swipe1.wav", 0.211111, 1, 0.000000);
if(gs == 0)ChangeAnimation("Event Actor", "NLSS1", FORWARD);
if(gs == 1)ChangeAnimation("Event Actor", "NRSS1", FORWARD);
SLASH = 1;
}
if(key[KEY_SPACE] == 1 && SLASH == 0 && j == 1)
{
PlaySound2("data/Swipe1.wav", 0.211111, 1, 0.000000);
if(gs == 0)ChangeAnimation("Event Actor", "NJSL1", FORWARD);
if(gs == 1)ChangeAnimation("Event Actor", "NJSR1", FORWARD);
SLASH = 1;
}
if(SLASH == 2 && animpos > 2)
{
if(gs == 0)ChangeAnimation("Event Actor", "NLS1", FORWARD);
if(gs == 1)ChangeAnimation("Event Actor", "NRS1", FORWARD);
SLASH = 0;
}
if(yvelocity > 4)j = 1;
if(yvelocity < -3)j = 1;
if(Health <= 0)
{
Life_Count -= 1;
PlaySound2("data/click.wav", 0.255556, 4, 0.066667);
x = Spawnpoint.x;
y = Spawnpoint.y;
Health = 18;
CreateActor("effect1", "Effect2", "(none)", "(none)", 0, 0, false);
}
if(Life_Count < 0)
{
directional_velocity = 0;
SLASH = -1;
transp = .999;
ChangeAnimationDirection("Event Actor", STOPPED);
}
if(sentryCount.textNumber == 0)
{
if(distance(xscreen, yscreen, portal.xscreen, portal.yscreen) < 400)
{
if(yscreen < portal.yscreen)yvelocity += 1;
if(yscreen > portal.yscreen)yvelocity -= 2;
if(xscreen > portal.xscreen)xvelocity -= 1;
if(xscreen < portal.xscreen)xvelocity += 1;
}
}
if(key[KEY_LEFT] == 1 && key[KEY_RIGHT] == 1)
{
if(gs == 1 && af == 1)
{
ChangeAnimation("Event Actor", "NRS1", FORWARD);
af = 0;
}
if(gs == 0 && af == 1)
{
ChangeAnimation("Event Actor", "NLS1", FORWARD);
af = 0;
}
}
}
it is really big, but it is easier than adding 25+ different things for one key down event,
this way it makes a way to have 0 moonwalks.
the basic thing I am trying to say is:
you can just set it up to change animations and do slighy different things depending on what select is.
example:
if you wanted to make your actor change animation to left,
- Code: Select all
if(Select == 0)ChangeAnimation("Event Actor", "Left_1", FORWARD);
if(Select == 1)ChangeAnimation("Event Actor", "Left_2", FORWARD);
got it?
