Page 1 of 1

Camper's school for all :-]

PostPosted: Sun Feb 22, 2009 10:35 am
by Camper1995
Hi people, I think, newbies need help with a lot of things, and one of that thing is, saving and loading game
So, I have made this demo of saving and loading game... so

I hope it helps

Move your actor with arrows.
SAVING GAME.JPG


Here is file:
saving game.zip
(29.63 KiB) Downloaded 362 times



Enjoy :D

Re: Examples 4 All

PostPosted: Sun Feb 22, 2009 1:14 pm
by Camper1995
Next example is, gravitation. I made this demo, USE number 1 2 3 and 4
to change gravitation...

Move your actor with arrows: LEFT, RIGHT, UP, DOWN
GRAVITATION.JPG


Gravitation Example.zip
(195.54 KiB) Downloaded 212 times

Re: Examples 4 All

PostPosted: Sun Feb 22, 2009 1:26 pm
by Camper1995
Next example for newbies... jumping...
all is explained in GE... ;-]

Use arrow keys to move
Jumping FOTO.JPG


Jumping.zip
(1.48 KiB) Downloaded 202 times

Re: Camper's school for all :-]

PostPosted: Sun Feb 22, 2009 1:39 pm
by Camper1995
Ok, next example is easy way to make a HP bar.. :D

Move your player with arrow keys
HP.JPG


HP.zip
(4.85 KiB) Downloaded 192 times

Re: Camper's school for all :-]

PostPosted: Sun Feb 22, 2009 1:52 pm
by Camper1995
Yo, next is this. Makin a save and start position... So... :D

Just try it and you will see..
Hole.JPG


Hole.zip
(229.22 KiB) Downloaded 196 times

Re: Camper's school for all :-]

PostPosted: Sun Feb 22, 2009 1:54 pm
by Camper1995
So, I think, this is the basic for start to build a good game...

Yo, next problem is moonwalikng, but I dont know how to do antimoonwalking..

jimmynewguy has explain me that, but, its too complicated :D


ENJOY :D

Re: Camper's school for all :-]

PostPosted: Sun Feb 22, 2009 8:11 pm
by LucasA33
Nice work.

Re: Camper's school for all :-]

PostPosted: Sun Feb 22, 2009 8:12 pm
by skydereign
Platformer antimoonwalking is actually pretty easy. This may seem long, but it is the same logic for all of the scripts. I just put them all there. I'll elaborate on the way jimmynewguy showed you. Since you have two possible directions, you can use a variable called direction. Upon keydown left, set it to 0, upon keydown right, set it to 1. Upon those keydowns, you must switch the animation, depending on if left, right, or both keys are pressed.
KeyDown(Right)[Disable repeat]->Script Editor
Code: Select all
char* key=GetKeyState(); // Allows keyboard interaction (key[KEY_<your key here>]) is either 1 or 0
if (canjump==1) // if actor is on the ground
{
    if (key[KEY_LEFT] == 0 && key[KEY_RIGHT] == 1) // If only right is pressed (allow for walking, so change animation)
    {
        ChangeAnimation("Event Actor", "WalkRight", FORWARD); // Because only right is pressed, change to walking
    }
    else if (key[KEY_LEFT] == 1 && key[KEY_RIGHT] == 1) // If both right and left (don't allow for walking, stand animation)
    {
        ChangeAnimation("Event Actor", "Right", FORWARD); // Because both are pressed
    }
}
right=1; // right


KeyDown(Left)[Disable repeat]->Script Editor
Code: Select all
char* key=GetKeyState();
if (canjump==1)
{
    if (key[KEY_LEFT] == 1 && key[KEY_RIGHT] == 0)
    {
        ChangeAnimation("Event Actor", "WalkLeft", FORWARD);
    }
    else if (key[KEY_LEFT] == 1 && key[KEY_RIGHT] == 1)
    {
        ChangeAnimation("Event Actor", "Left", FORWARD);
    }
}
direction=0; // left

Right and left are to determine jump animations, or any other that you may put in. The reasoning for this is you need to make sure that the actor knows which way it's facing. Since the event is not repeated, the last keydown will define the direction.
Now for the keyup. These follow almost identical logic for sorting which direction to go as above. The only difference is due to the nature of keyup. Since that is an event triggered by a switch from 1 to 0, the conditions will change. If left is still pressed than walk. If both are released set it to stand.
KeyUp(Right)->Script Editor
Code: Select all
char* key=GetKeyState();
if (canjump==1)
{
    if (key[KEY_LEFT] == 1 && key[KEY_RIGHT] == 0) // If left is still pressed, walk left
    {
        ChangeAnimation("Event Actor", "WalkLeft", FORWARD);
    }
    else if (key[KEY_LEFT] == 0 && key[KEY_RIGHT] ==0)  // As left and right are not pressed, set it to stand
    {
        ChangeAnimation)"Event Actor", "Right", FORWARD);
    }
}


KeyUp(Left)->Script Editor
Code: Select all
char* key=GetKeyState();
if (canjump==1)
{
    if (key[KEY_LEFT] == 0 && key[KEY_RIGHT] == 1)
    {
        ChangeAnimation("Event Actor", "WalkRight", FORWARD);
    }
    else if (key[KEY_LEFT] == 0 && key[KEY_RIGHT] == 0)
    {
        ChangeAnimation)"Event Actor", "Left", FORWARD);
    }
}



The last bit is in the draw actor. This will set your movement, only if a single key is pressed.
DrawActor->Script Editor
Code: Select all
char* key=GetKeyState();
if (key[KEY_LEFT] == 1 && key[KEY_RIGHT] == 0) // Only left
{
    x- = 2;  // Move left
}
if (key[KEY_LEFT] == 0 && key[KEY_RIGHT] == 1) // Only right
{
    x+= 2;  // Move right
}
yvelocity+=9; // Because this is the draw actor script, nothing to do with moonwalking

Re: Camper's school for all :-]

PostPosted: Mon Feb 23, 2009 10:15 am
by Camper1995
Ou man, Thanks man... :D I understand it now.. but I have only one question...

Example: I have a character, and I am making a figting game.. so.. when I press SPACE BAR, character will attack (punch)
but......man...do you have play my game: Crash The Bandicoot?

Download it, and there, when I attack and in same time I run...how can I do this: So when I press spacebar when I am running, when the animation
of attacking is finish, the character will run..so, he dont stop...

I cant explain it, because I cant speak good english, but try that game, and you will understand that problem with moonwalking when the player is attacking..


THANKS :D :D :D

Re: Camper's school for all :-]

PostPosted: Tue Feb 24, 2009 2:02 am
by skydereign
Well depending on what you are doing, or how complex you are going with the attacks, there are several ways. I think what you are asking is how to stop movement during an attack. If so, you would create a variable signifying the attack is being done, and when it finishes you set the variable back to 0. So when you press space, or your attack button, set attack to 1. Upon the animation finish, reset it to 0. Now during your draw actor script that creates movement, only allow movement if attack is 0. This can be done with an if statement,
Code: Select all
if (attack==0)

I looked at your game, but you made it a lot harder to make changes. When I make a game, I try to make the fewest amount of events as possible, for the most part this is a good thing to do (sometimes not), but it makes it much easier to edit. Most of your keydowns have many events, all of them are possible in the script editor, such as ChangeAnimation. At first I did that too, but if it is to separate the functionalities of your code, you can comment them with //, or separate them... or both. Just a tip, it makes it much easier for others and yourself to edit and revise. I no longer use keydown events as I have created an alternative to doing so, it is arguable if that is a good thing that I have 3 or so events only, but I prefer it, especially because I edit all my scripts externally...

Re: Camper's school for all :-]

PostPosted: Tue Feb 24, 2009 12:23 pm
by Camper1995
Yea yea,... :-))) Um, only, is this script good?:
Code: Select all
if(respect.textNumber == 9)
{
   Event Enable...
   Change Animatio....
}


I want to do this: When is Respect.textNumber bigger then number 9, enable doors, so you can enter in a building...

Is this good?

Re: Camper's school for all :-]

PostPosted: Tue Feb 24, 2009 11:52 pm
by skydereign
Yeah, I would just set it to > instead of ==, if you want greater than 9.

Re: Camper's school for all :-]

PostPosted: Wed Feb 25, 2009 7:04 pm
by Camper1995
Yeah