I can now launch a bullet, if I change the walk straight function to a move with move-anywhere on. But I only want the bullet to travel on walkable areas, and go in the direction of the mouse, and not some altered course set by the program to. the walk straight function works for my other characters. Why won't it work for criflebullet?
(note, the program is not returning any errors)
function shot_vector(int, int, int, int)
{
criflebullet.ChangeRoom(1, 0, 0); //places in the test room
criflebullet.x = cglitch.x;
criflebullet.y = cglitch.y-50; //places bullet behind player character
int vectorx;
int vectory;
vectorx = (mouse.x+16) - cglitch.x;
vectory = (mouse.y+32) - cglitch.y; //determine driection to move bullet
criflebullet.WalkStraight(((cglitch.x) + (vectorx)), ((cglitch.y) + (vectory)));
return;
}
I'm not quite sure. How did it "won't work"? Can you describe it more in detail?
the bullet does not appear at all.
Have your even called the shot_vector() function in the game?
Also, as the function is not taking any parameter, you should remove the "int, int, int, int" part of it (it's odd that your game compiled without errors, as you must provide the names of the variables if a function ever needs to have parameters).
I don't know exactly how your code works, but are you sure it's not simply that you give wrong values to x and y when you initialize them, causing the object to appear immediately outside of any walkable area (and it's not displayed at all) ?
Yeah. Try to add also the following line
criflebullet.PlaceOnWalkableArea();
after setting the bullet's coordinates.
Why did you open a second thread for this? Well, never mind.
This:
criflebullet.x = cglitch.x;
criflebullet.y = cglitch.y-50; //places bullet behind player character
might put the bullet at a position outside a walkable area.
To increase the height, set criflebullet.z to -50. This makes the character get displayed further above without changing their position.
I've tried everything you guys have posted, but the result does not change. I know the bullet is being placed at a valid location because the function works if I substitute "move" for "walkstraight." But I can't use "move" because it changes the course of the bullet if I click outside a walkable area. Also, the "walk" function produces the same results as a the "walkstraight" function, but "move" works almost the way I want it. I guess what I really need is something along the lines of a "movestraight" function, if it exists.
Now, I know what's your problem.
Since the bullet is a character, when you use Walk() or WalkStraight() its walking animation will be played. As the walking animation of a character starts from the second frame of each loop, if you didn't assign a second frame for its loops there may be problems (as opposed to Move(), since the walking animation is not played in this case).
Just assign a sprite to the second frame of each loop and it should be fine.
That did it! Thanks for all the help guys!