Page 1 of 1

gravity/ and using a sword

PostPosted: Thu Sep 22, 2011 7:19 pm
by praaab
1. for gravity i use yvelocity + yvelocity = 2; it works and everything but when i get to the edge of a platform, he starts sliding away on the edge and eventually falls off. is there another code that I could use for the gravity script?

2. My character is a stick man with a sword and shield, when i want him to attack how do i make it so that if his sword hits an enemy then the enemy will die or get hurt depending on the hp level.

thanks,

Praaab.

Re: gravity/ and using a sword

PostPosted: Thu Sep 22, 2011 7:42 pm
by savvy
yvelocity + yvelocity = 2; for a start would set it to 2 all the time, use yvelocity+=2;
then ont he collision event with the top side of the ground use yvelocity=0;

then with the sword, add a collision with the enemy and use...
(this goes in the enemy, not player)
Code: Select all
if(collide.animindex==0||collide.animindex==1)
{
//0 being the animindex of the attack animation right, 1 left
hp-=1;
//hp is an actor variable
if(hp<=0)DIE;
}


maybe not well described, but ask away..

savvy

Re: gravity/ and using a sword

PostPosted: Sun Oct 02, 2011 1:19 pm
by praaab
ok well im new to this coding of C and im not sure where to put my animations in the lines of code that u gave me