Page 1 of 2

online game

PostPosted: Fri Jun 24, 2011 4:17 pm
by praaab
ok i have a few questions on my game that im creating. 1. how do i make my game online, like to make other people play against eachother. 2. how do i make my character shoot from the side hes facing because he only shoots on the right side. 3. how do i create an ai with gravity and shoot.

Re: online game

PostPosted: Sat Jun 25, 2011 5:25 pm
by MrJolteon
praaab wrote:ok i have a few questions on my game that im creating. 1. how do i make my game online, like to make other people play against eachother. 2. how do i make my character shoot from the side hes facing because he only shoots on the right side. 3. how do i create an ai with gravity and shoot.

1: You can't.
2: Use variables, that's all I know
3: Dunno

Re: online game

PostPosted: Sat Jun 25, 2011 7:12 pm
by Camper1995
3. Dunno
:lol:

But seriously, i don't think we can make online games for now.
New GE should be able to make them.

Re: online game

PostPosted: Sun Jun 26, 2011 6:05 pm
by praaab
but how do i make the actor able to shoot from both sides

Re: online game

PostPosted: Sun Jun 26, 2011 6:25 pm
by lcl
praaab wrote:but how do i make the actor able to shoot from both sides

First, you need to declare a variable. Go to some event with script editor and at the script editor click variables, then add, then name it dir (shortening for direction), leave those integer and global as they are and click add. Then close the script editor.

Now add this code to your player actors key down event (right) - script editor:
Code: Select all
dir = 1;

And this for key left:
Code: Select all
dir = 0;

Now, 1 is for right and 0 is for left.

Next, go to the key down event for shooting - script editor and add this code:
Code: Select all
CreateActor(...); //You can add the function to script by clicking "variables/functions". Find CreateActor(); from there and create your bullet actor.
if (dir == 1)
{
    bullet.xvelocity = 10;
}
else if (dir == 0)
{
    bullet.xvelocity = - 10;
}

Remember to change the "bullet" before those xvelocities to the name of your bullet actor.
There you go! Did this help? :)

- lcl -

Re: online game

PostPosted: Sun Jun 26, 2011 7:00 pm
by praaab
yes this helped a lot thank you so much but i have one more question. how do i load my game onto my ipod with geplayer?

Re: online game

PostPosted: Sun Jun 26, 2011 7:06 pm
by lcl
praaab wrote:yes this helped a lot thank you so much but i have one more question. how do i load my game onto my ipod with geplayer?

Sorry, I don't know about this, I don't have iPod.

Re: online game

PostPosted: Sun Jun 26, 2011 7:17 pm
by praaab
ok one more questioin im trying to create an ai but he doesnt have gravity and i dont know how to add gravity to him?

Re: online game

PostPosted: Sun Jun 26, 2011 7:19 pm
by Hblade
Draw Actor:
Code: Select all
yvelocity+=.5;

Re: online game

PostPosted: Sun Jun 26, 2011 7:26 pm
by praaab
ok i know how to use gravity but the ai code.

Re: online game

PostPosted: Sun Jun 26, 2011 7:29 pm
by lcl
Hblade wrote:Draw Actor:
Code: Select all
yvelocity+=.5;

U didn't feel like writing much? :lol:

And as for you praaab that code Hblade provided does increase yvelocity (the actors velocity on y axis) by 0.5 every frame, because it comes to draw actor, and all code in draw actor event is executed every frame when actor is drawn. So with the preset fps of GE (30) (you can change it in game settings) it will add this 0.5 to the actors yvelocity 30 times in second. That makes the actor accelerate while falling.

And yes, for some reason, Ge's y axis numbers are inverted in comparison to normal. So minus is up and plus is down. :)

EDIT: this seems not to be what you're trying to do..
What do you need to do? :)

Re: online game

PostPosted: Sun Jun 26, 2011 7:33 pm
by praaab
no listen, i try to use ai like enemy>draw actor>script editor>MoveTo>player>avoid none. he follows you but doesnt fall to the ground

Re: online game

PostPosted: Sun Jun 26, 2011 7:51 pm
by lcl
Ahh, now I see!
Take that MoveTo -command away, here is the solution:
Code: Select all
int move = - 1 + 2 * (x < player.x);
x += 5 * move;

What this code does it creates local variable move and sets it to - 1 and then adds 2 to it if x < player.x. those brackets return 0 or 1 depending on if the condition inside them is true or not. If it is true move will be 1, otherwise it'll be - 1.
And now the actor will move 5 pixels to right or left according to what is the value of move. :D

Did you understand my explanation? :)

Re: online game

PostPosted: Mon Jun 27, 2011 12:36 am
by praaab
ok well 3 more things, 1 i dont know how to make him change his animation(enemy) when he moves left and right. 2 how do i make him jump when the player is above him? 3. how do i make the ai shoot from both sides by himself like the player and yes this was very helpful thankyou

Re: online game

PostPosted: Mon Jun 27, 2011 5:58 am
by skydereign
Well if your animations are in a certain order you can do this.
Code: Select all
int move = - 1 + 2 * (x < player.x);
x += 5 * move;

ChangeAnimation("Event Actor", getAnimName(x<player.x + 2), NO_CHANGE);

By certain order I assume you are using this.
Stand Right
Stand Left
Move Right
Move Left
anything else

If not you'll have to use this.
Code: Select all
int move = - 1 + 2 * (x < player.x);
x += 5 * move;

switch(move)
{
    case -1:
    ChangeAnimation("Event Actor", "move_left", NO_CHANGE);
    break;

    case 1:
    ChangeAnimation("Event Actor", "move_right", NO_CHANGE);
    break;
}


To make it jump the easiest way would be to have it jump whenever it can (otherwise you'd have to get into predicting platforms). So add this to the end of the above code.
Code: Select all
if(jump==1)
{
    yvelocity=-10;
    jump=0;
}


Add a collision event with the ground to reset jump to 1 (jump needs to be an actor variable). If you have jump animations and don't have the animations in the order suggested above, then copy it into the if statement and switch the names to jump_right and jump_left (if you do you can use the same ChangeAnimation code but instead of +2 add +4).


Lastly if you want the enemy to shoot the direction its facing you can do this (I assume you already have code to make it shoot, so having a CreateActor call). Change 15 to the speed you want.
Code: Select all
CreateActor("bullet", "bullet_anim", "(none)", "(none)", 0, 0, false)->xvelocity=((x<player.x)-(x>player.x))*15;