Page 1 of 1

RPG movement System 2

PostPosted: Sat Sep 17, 2011 12:59 am
by Hblade
Test ^^
Smooth View, (Thanks to GAG), View Limiting (Thanks to Skydereign) Perfect Wall Colision, can't exit view :)

TONS of if's in the code of 'player' xD

Re: RPG movement System 2

PostPosted: Sat Sep 17, 2011 3:03 am
by Hblade
OH! There is a fog animation behind the floor I forgot to drag it back up, you can if you want

Re: RPG movement System 2

PostPosted: Sat Sep 17, 2011 6:57 am
by CoFFiN6
Nice! It makes a perfect stop against walls

Re: RPG movement System 2

PostPosted: Sat Sep 17, 2011 5:27 pm
by Hblade
Thanks :D

Re: RPG movement System 2

PostPosted: Sat Sep 17, 2011 8:04 pm
by jimmynewguy
Looks really good, but there's a lot of code going on in the collisions and movement I would try to avoid. I'm not a huge fan of long code :lol:

On the bod actor->draw I would have:
Code: Select all
char *key=GetKeyState();
x += 2*(key[KEY_RIGHT]-key[KEY_LEFT]);
y += 2*(key[KEY_DOWN]-key[KEY_UP]);


Then collision->anyside->repeat since were using x/y + instead of velocity, just this will do.
Code: Select all
PhysicalResponse(MOVE_EVENT_ACTOR_ONLY, USE_CALCULATED_MASS, 1.000000, 1.000000, 0.000000, 1.000000);


Then I'd get rid of all the stop animations the player has, since they are just the fourth frame of the walking animations and use this for the draw actor:
Code: Select all
char *key=GetKeyState();
int dir = (3*key[KEY_UP]+5*key[KEY_LEFT]+7*key[KEY_DOWN]+9*key[KEY_RIGHT]);

if(dir)
ChangeAnimationDirection("Event Actor", FORWARD);

switch(dir)
{
case 0: case 10: case 14:
ChangeAnimationDirection("Event Actor", STOPPED);
animpos = 4;
break;
case 3:ChangeAnimation("Event Actor", "Up", NO_CHANGE);
break;
case 5:ChangeAnimation("Event Actor", "Left", NO_CHANGE);
break;
case 7:ChangeAnimation("Event Actor", "Down", NO_CHANGE);
break;
case 9:ChangeAnimation("Event Actor", "Right", NO_CHANGE);
break;
}


Again, that's just me hating long codes. It doesn't work EXACTLY like how you had it before (in the since of holding keys it will go diagonal, easy fix if it bugs you a lot. And when the player runs into a wall he doesn't stop animating, also easy fix if it bugs you.) But I was just showing you my way since, well I'm not sure. I just like blabbing I guess! :)

EDIT: That post seems a bit snooty, don't change your code because of me :lol: I was just being an example

Re: RPG movement System 2

PostPosted: Sat Sep 17, 2011 10:29 pm
by Hblade
You are truely a genius :)

Re: RPG movement System 2

PostPosted: Sun Sep 18, 2011 2:53 am
by jimmynewguy
If you met me not on the internet, you probably wouldn't think that! :lol: Just hope I somehow helped a little.

Re: RPG movement System 2

PostPosted: Sun Sep 18, 2011 4:51 am
by Hblade
you did :D

Re: RPG movement System 2

PostPosted: Tue Sep 20, 2011 8:40 pm
by SuperSonic
This is really great, good job :wink:

It would be really cool though if you make him move on a grid. I did something like that once and was going to upload it but I can't seem to find it :roll:

Re: RPG movement System 2

PostPosted: Wed Sep 21, 2011 2:33 am
by Hblade
lol yeah Im going to make another demo later today :) And thanks for the positive comments! :D

(well technically it's 10:33 at night xD..)

Re: RPG movement System 2

PostPosted: Wed Sep 21, 2011 2:39 am
by Hblade
jimmynewguy wrote:Looks really good, but there's a lot of code going on in the collisions and movement I would try to avoid. I'm not a huge fan of long code :lol:

On the bod actor->draw I would have:
Code: Select all
char *key=GetKeyState();
x += 2*(key[KEY_RIGHT]-key[KEY_LEFT]);
y += 2*(key[KEY_DOWN]-key[KEY_UP]);


Then collision->anyside->repeat since were using x/y + instead of velocity, just this will do.
Code: Select all
PhysicalResponse(MOVE_EVENT_ACTOR_ONLY, USE_CALCULATED_MASS, 1.000000, 1.000000, 0.000000, 1.000000);


Then I'd get rid of all the stop animations the player has, since they are just the fourth frame of the walking animations and use this for the draw actor:
Code: Select all
char *key=GetKeyState();
int dir = (3*key[KEY_UP]+5*key[KEY_LEFT]+7*key[KEY_DOWN]+9*key[KEY_RIGHT]);

if(dir)
ChangeAnimationDirection("Event Actor", FORWARD);

switch(dir)
{
case 0: case 10: case 14:
ChangeAnimationDirection("Event Actor", STOPPED);
animpos = 4;
break;
case 3:ChangeAnimation("Event Actor", "Up", NO_CHANGE);
break;
case 5:ChangeAnimation("Event Actor", "Left", NO_CHANGE);
break;
case 7:ChangeAnimation("Event Actor", "Down", NO_CHANGE);
break;
case 9:ChangeAnimation("Event Actor", "Right", NO_CHANGE);
break;
}


Again, that's just me hating long codes. It doesn't work EXACTLY like how you had it before (in the since of holding keys it will go diagonal, easy fix if it bugs you a lot. And when the player runs into a wall he doesn't stop animating, also easy fix if it bugs you.) But I was just showing you my way since, well I'm not sure. I just like blabbing I guess! :)

EDIT: That post seems a bit snooty, don't change your code because of me :lol: I was just being an example


There is a glitch in this code ;D
Hold left right, and up at the same time, then release up and press down (While still holding left and right), the player will walk up but go down :D


Other than that I'm VERY impressed! :)

Re: RPG movement System 2

PostPosted: Fri Sep 23, 2011 10:51 pm
by Hblade
jimmynewguy wrote:Looks really good, but there's a lot of code going on in the collisions and movement I would try to avoid. I'm not a huge fan of long code :lol:

On the bod actor->draw I would have:
Code: Select all
char *key=GetKeyState();
x += 2*(key[KEY_RIGHT]-key[KEY_LEFT]);
y += 2*(key[KEY_DOWN]-key[KEY_UP]);


Then collision->anyside->repeat since were using x/y + instead of velocity, just this will do.
Code: Select all
PhysicalResponse(MOVE_EVENT_ACTOR_ONLY, USE_CALCULATED_MASS, 1.000000, 1.000000, 0.000000, 1.000000);


Then I'd get rid of all the stop animations the player has, since they are just the fourth frame of the walking animations and use this for the draw actor:
Code: Select all
char *key=GetKeyState();
int dir = (3*key[KEY_UP]+5*key[KEY_LEFT]+7*key[KEY_DOWN]+9*key[KEY_RIGHT]);

if(dir)
ChangeAnimationDirection("Event Actor", FORWARD);

switch(dir)
{
case 0: case 10: case 14:
ChangeAnimationDirection("Event Actor", STOPPED);
animpos = 4;
break;
case 3:ChangeAnimation("Event Actor", "Up", NO_CHANGE);
break;
case 5:ChangeAnimation("Event Actor", "Left", NO_CHANGE);
break;
case 7:ChangeAnimation("Event Actor", "Down", NO_CHANGE);
break;
case 9:ChangeAnimation("Event Actor", "Right", NO_CHANGE);
break;
}


Again, that's just me hating long codes. It doesn't work EXACTLY like how you had it before (in the since of holding keys it will go diagonal, easy fix if it bugs you a lot. And when the player runs into a wall he doesn't stop animating, also easy fix if it bugs you.) But I was just showing you my way since, well I'm not sure. I just like blabbing I guess! :)

EDIT: That post seems a bit snooty, don't change your code because of me :lol: I was just being an example





Jimmy, can you explain how to have 4 way movement?

Re: RPG movement System 2

PostPosted: Sat Sep 24, 2011 2:01 am
by jimmynewguy
Sure, should've just used it originally since it fixes that bug you found.

Just get rid of all the bods draw actor and keep the collision physical response, then for the player's draw actor do this
Code: Select all
char *key=GetKeyState();
int dir = (3*key[KEY_UP]+5*key[KEY_LEFT]+7*key[KEY_DOWN]+9*key[KEY_RIGHT]);// Make direction

if(key[KEY_LEFT]+key[KEY_RIGHT]+key[KEY_UP]+key[KEY_DOWN] == 1)// if only one of our keys is pressed
{
BOD.x += 2*(key[KEY_RIGHT]-key[KEY_LEFT]);// movex
BOD.y += 2*(key[KEY_DOWN]-key[KEY_UP]);// movey

ChangeAnimationDirection("Event Actor", FORWARD);// animate
switch(dir)
{
case 3:ChangeAnimation("Event Actor", "Up", NO_CHANGE);
break;
case 5:ChangeAnimation("Event Actor", "Left", NO_CHANGE);
break;
case 7:ChangeAnimation("Event Actor", "Down", NO_CHANGE);
break;
case 9:ChangeAnimation("Event Actor", "Right", NO_CHANGE);
break;
}
}
else
{
ChangeAnimationDirection("Event Actor", STOPPED);// don't animate
animpos = 4;
}

Just say if it doesn't make sense :wink:

Re: RPG movement System 2

PostPosted: Mon Sep 26, 2011 2:41 pm
by Hblade
Thanks jimmy! :)

EDIT: But now he stops when your going up and you press over xD Is there any way to make him move left instead of stop? (For example)

Holding up then pressing left would make the player go left, then vise versa, holding left and pressing up would make the player go up (Kinda like RPG maker style :) )