Simple Useful Functions Topic!
Posted: Fri Oct 14, 2011 8:22 pm
Hi everyone, just thought it'd be cool for people to post simple, useful functions here that are "universal" (can be used often) just to see what people have! It's a good thing for beginners or people who want to improve to see.
First one is a toggle function.
You can use it to toggle and integer or other things. Like this would switch an actor from transparent to visible or vise versa
Another could be PointFromCircle
You can use it to have an actor point at the mouse (or change the mouse to anything else if you want) and stay on a circle paths, not nearly as universal but it could help someone
This would have the actor point towards the mouse around the actor named circle with a radius of 50 pixels. You could use it if you made a soccer like game and the player moved towards the mouse, then the ball would be in the right spot for dribbling!
Now post some more!
First one is a toggle function.
- Code: Select all
int Toggle(int integer)
{
return !integer;
}
You can use it to toggle and integer or other things. Like this would switch an actor from transparent to visible or vise versa
- Code: Select all
transp = Toggle(transp);
Another could be PointFromCircle
- Code: Select all
void PointFromCircle(char * circles, int radius)
{
Actor * circle = getclone(circles);
theta = direction(circle->x - view.x, circle->y - view.y, xmouse, ymouse)/60;
x = circle->x+radius*cos(-theta);
y = circle->y+radius*sin(-theta);
}
You can use it to have an actor point at the mouse (or change the mouse to anything else if you want) and stay on a circle paths, not nearly as universal but it could help someone
- Code: Select all
PointFromCircle("circle", 50);
This would have the actor point towards the mouse around the actor named circle with a radius of 50 pixels. You could use it if you made a soccer like game and the player moved towards the mouse, then the ball would be in the right spot for dribbling!
Now post some more!