Thanks to Hblade, I understand now something about making voids and here is some of what I've made!

Current functions:
- Move("animation1", "animation2", DIRECTION, speed);
- Jump("actor", number of actor using function, height of jump);
- EnableJump(the number that actor uses in jump);
- Follow("actor that follows", "actor to follow", axis, speed);
- ViewFollowActor("actor to follow", how much player can move on x axis before view starts moving, same for y, speed)
- CollisionJump("jumping actors name", key, jump height)
First function is for moving actor and same time commanding the animations:
Move("animation1", "animation2", DIRECTION, speed);
Directions:
- LEFT
- RIGHT
- UP
- DOWN
- STOP_LEFT
- STOP_RIGHT
- TWO_KEYS
Use it like this in key down events:
- Code: Select all
Move("charRight", "(none)", RIGHT, 5);
"charRight" is the animation
"(none)" this is for second animation, it's usable for commanding animations when two keys are pressed
RIGHT is the way to move, there is many alternatives
5 is speed of move
This code can be also used to command animations while two keys are pressed like this:
Key Down - left, right - All keys are pressed - repeat:
- Code: Select all
Move("charStopLeft", "charstopRight", TWO_KEYS, 0);
When using it like this, remember to put to the first animation the name of the animation that is for first one of the keys, and to
the second, place the name of the animation of the second key.
Second function is for jumping:
Jump("actor", number of actor using function, height of jump);
- Code: Select all
Jump("Player", 1, 10);
This will make actor called Player jump to the height of 10.
This code work for every individual actor, you just must remember to type different value to the numberin middle of the code.
Third function is for enabling the jump again for certain actor, for example when colliding with ground:
EnableJump(the number that actor uses in jump);
- Code: Select all
EnableJump(1);
If you use Jump function, you must remember to use also this, if you don't use this, actor will jump just once.
And remember to type the number same as the number in code what makes the actor jump.
The fourth function is for making actor to follow another:
Follow("actor that follows", "actor to follow", axis, speed);
Axes:
- AXIS_X
- AXIS_Y
- AXIS_BOTH
- Code: Select all
Follow("enemy", "Player", AXIS_X, 5);
This will make actor called enemy to chase actor Player, following only Players x axel with speed of 5.
This code work for every individual actor, you just must remember to type different value to the numberin middle of the code.
The fifth function is for making view to follow actor:
ViewFollowActor("actor to follow", how much player can move on x axis before view starts moving, same for y, speed)
- Code: Select all
ViewFollowActor("Player", 100, 100, 5);
This will make view follow actor Player with speed of 5. Remember to use this only
in view actors draw actor code.
For now, last function is for making actor jump just while it collides with some actor that you can choose, for example, ground:
CollisionJump("jumping actors name", key, jump height)
Type code to the collision event with actor that you want actor to be able to jump. Remember to put repeat to ON.
For example: Collision - Top side- Ground - Repeat:
- Code: Select all
CollisionJump("Player", KEY_UP, 10);
This will make actor called Player to jump to height of 10 while on actor Ground and key up is pressed.
You can use any key on keyboard to use this function!!!
Enjoy of these, I'll make more soon!
I post also a .zip containing the demo of the using of these functions.
Please give me feedback!!!

THE CODE:
- Code: Select all
long jump[1000];
int dir;
int moving;
int stop;
int stopWay;
#define LEFT 11
#define RIGHT 22
#define UP 33
#define DOWN 44
#define STOP_LEFT 55
#define STOP_RIGHT 66
#define TWO_KEYS 77
#define AXIS_X 88
#define AXIS_Y 99
#define AXIS_BOTH 110
//----------EASY TO USE FUNCTIONS----------
/*These are easy functions for beginners to use
for making their games easier way.*/
//-----MOVING THE PLAYER-----
/*This allows you to change animations and move player
with speed that you can decide yourself.
-----ABOUT USING-----
Moving functions must be used in key down events
following way:
Move("Animation name", "Second animation name" Direction, Speed with numbers);
There are 4 moving directions; left, right, up, down,
and also directions stop left, stop right, and two keys pressed.
To call some of these directions, type:
- LEFT
- RIGHT
- UP
- DOWN
- STOP_LEFT
- STOP_RIGHT
- TWO_KEYS
- JUMP
*/
void Move(char*anim, char*anim2, int moveWay, int speed)
{
switch(moveWay)
{
case LEFT:
x-=speed;
if(moving==0)
{
if(dir!=1 && stop==0)
{
ChangeAnimation("Event Actor", anim, FORWARD);
dir=1;
stopWay=1;
}
}
moving=1;
break;
case RIGHT:
x+=speed;
if(moving==0)
{
if(dir!=2 && stop==0)
{
ChangeAnimation("Event Actor", anim, FORWARD);
dir=2;
stopWay=2;
}
}
moving=1;
break;
case UP:
y-=speed;
if(moving==0)
{
if(dir!=3)
{
ChangeAnimation("Event Actor", anim, FORWARD);
dir=3;
}
}
moving=1;
break;
case DOWN:
y+=speed;
if(moving==0)
{
if(dir!=4)
{
ChangeAnimation("Event Actor", anim, FORWARD);
dir=4;
}
}
moving=1;
break;
case STOP_LEFT:
moving=0;
if(dir!=5)
{
ChangeAnimation("Event Actor", anim, FORWARD);
dir=5;
stop=0;
}
break;
case STOP_RIGHT:
moving=0;
if(dir!=6)
{
ChangeAnimation("Event Actor", anim, FORWARD);
dir=6;
stop=0;
}
break;
case TWO_KEYS:
moving=0;
if(!stop)
{
switch(stopWay)
{
case 1:
ChangeAnimation("Event Actor", anim, FORWARD);
stop=1;
break;
case 2:
ChangeAnimation("Event Actor", anim2, FORWARD);
stop=1;
}
}
break;
}
}
//-----JUMPING-----
/*This allows you to make your player jump easily
to the height that you can decide. Function also
disables jumping after one jump. Use the function
EnableJump(); to enable it again ex. in collision with ground.
-----ABOUT USING-----
This function can be used in key down event
following way:
Jump(Set the height with numbers);
*/
void Jump(char*name, int number, int power)
{
Actor*actor=getclone(name);
if(jump[number]==0)
{
actor->yvelocity=-power;
jump[number]=1;
}
}
void EnableJump(int number)
{
jump[number]=0;
}
void Follow(char*name2, char*name, int way, int speed)
{
Actor*actor=getclone(name);
Actor*follower=getclone(name2);
switch(way)
{
case AXIS_X:
if(follower->x<actor->x-speed)
{
follower->x+=speed;
}
if(follower->x>actor->x+speed)
{
follower->x-=speed;
}
break;
case AXIS_Y:
if(follower->y<actor->y-speed)
{
follower->y+=speed;
}
if(follower->y>actor->y+speed)
{
follower->y-=speed;
}
break;
case AXIS_BOTH:
if(follower->x<actor->x-speed)
{
follower->x+=speed;
}
if(follower->x>actor->x+speed)
{
follower->x-=speed;
}
if(follower->y<actor->y-speed)
{
follower->y+=speed;
}
if(follower->y>actor->y+speed)
{
follower->y-=speed;
}
break;
}
}
void ViewFollowActor(char*name, int Fx, int Fy, int speed)
{
Actor*actor=getclone(name);
int X=view.width/2;
int Y=view.height/2;
if(x+X<actor->x-speed && actor->xscreen>xscreen+X+Fx)
{
x+=speed;
}
if(x+X>actor->x+speed && actor->xscreen<xscreen+X-Fx)
{
x-=speed;
}
if(y+Y<actor->y-speed && actor->yscreen>xscreen+Y+Fy)
{
y+=actor->yvelocity;
}
if(y+Y>actor->y+speed && actor->yscreen<xscreen+Y-Fy)
{
y-=speed;
}
}
void CollisionJump(char*name, int that, int height)
{
Actor*actor=getclone(name);
char*key=GetKeyState();
strcpy(key, getKeyText(that));
if(key[that]==1)
{
actor->yvelocity=-height;
}
}