Hi!
I'm currently working on a game that has 3 controllable characters. But I was wondering, can I have different characters use the same keyboard keys to move, but only when they're active?
Sure you can.
When checking for key input, you should first check which character is your current player character ( for information on how to find that out, please refer to the manual ) and then you should move only your current player character around.
The player pointer refers to the currently active player, so you can do
player.Walk instead of cEgo.Walk and it will automatically get the right one when you change player characters. Easy as pie!
Thanks! You guys really helped me out!
EDIT: I have another question: Can someone give me the keyboardmovement script for the latest AGS version (2.7)?
I can't find it...
Take a look at the KeyboardMovement script module (http://www.adventuregamestudio.co.uk/yabb/index.php?topic=22724).
Thanks!
And another question:
I want to try making a game like Street Fighter on the SNES, a beat-m-up fighter.
How do I do multiplayer mode, in which player 1 and player 2 can control a character at the same time?
The keys I want to be programmed:
Player 1:
Up-arrow ~ jump
Down-arrow ~ kneel
Right-arrow ~ move right
Left-arrow ~ move left
= button ~ punch
- button ~ kick
0 button ~ head attack
p button ~ special move 1
[ button ~ special move 2
shift, p and ] buttons ~ ultimate special move
Player 2:
w button ~ jump
z button ~ kneel
s button ~ move right
a button ~ move left
t button ~ punch
y button ~ kick
r button ~ head attack
f button ~ special move 1
g button ~ special move 2
Ctrl, f and g buttons ~ ultimate special move
Does anyone know a module/plug-in/code/game template how to do this?
~Yurina
I don't think there's a special plugin or module for this, but if you know how do that for one player, then you could just check for the keys for the second player and handle the keypresses the same way you did for the first one. I don't quite understand where the problem is, I'm afraid... :P
I think Yurina is wanting to know if there is a way to set it up to work over the internet. Even with the tcp/ip plugin I'd say no, since it's very buggy. As for two people on the same machine, you'd have to map out one set of keys for one player and possibly the num pad keys for the other. Bear in mind that almost no one will play a two player game in that way, it's just too difficult and annoying.
But you could have one person playing via VNC, making two-player!
My plans are making an offline multiplayer game, which will be for two players on one keyboard.
The thing is, how do I make a multiplayer function in which two players battle against eachother on one keyboard?
I need two player characters at one time for this, maybe I'll make a different thread for that...
Look at the source code for the games in the Fight game coding contest. For details, see:
http://americangirlscouts.org/agswiki/index.php/Coding_Contest
also try:
http://americangirlscouts.org/agswiki/index.php/Open_Source_Games
I think you'll need to put the commands in rep_ex, rather than on_mouse_click (which can really only handle one key at a time, without getting too convoluted).
The KeyboardMovement module has code for that (used for the eKeyPress movement type) - all you'll need to do is copy the commands for one player, and change the keycodes & character pointer, e.g.:
if (IsKeyPressed(375) && cEgo.Moving == false) { // Left Arrow
cEgo.WalkStraight(cEgox-40, cEgo.y-20);
}
if (IsKeyPressed('S') && cBob.Moving == false) { // S key
cEgo.WalkStraight(cEgox-40, cEgo.y-20);
}
Which I think is why dkh was confused about the probelm (it's why I was, anyway) - you already HAD the module/scripting you needed.
Thanks, thanks, thanks!
I'll try it out when I'm not at school (where I am now) and I'll drop a not about the outcome.
Hi sorry for bumping this.
I have a problem also involving two players and both usin the keyboard. I have no problem gettin them to use the keyboard collectively BUT as i have experienced throughout the history of gaming with keyboard sometimes keys work out on each other ... for example when both press up one guy will not respond as though the keys disrupt each other ... generally i would just change the keys and it may work. Hope you understand ...
My Question: How do I choose keys or what do i do so that the two players pressing keys don't affect each others movement?
I hope you understand: The keys work fine but pressing certain combinations hinder the other player's movement ... grrr ... hard to explain .... For example: player one holds down down-right, but player two too and player can't move due to some keyboard buffer something haha.
[edit] Do i just allow players to define their own keys and let them try out different combinations until keys doesn't affect each other
I think it differs with different keyboard layouts, there's no general rule. So, if you can let the user to define the keys themselves it's the best solution.
i guess that's the best way then.
thanks gilbot.