Hi. At the moment I'm trying to create a simple 2 player maze game called Planez. I'm trying to make it so that one player uses the up, down, left and right buttons to move their character and the other player uses the e, d, s and f buttons to move their's. But when I try to move both at once only one moves at a time! Is there a solution to this, and if not, what do you think I could to modify it to make it work in a similar way as before.
Offline
Without seeing the script I can't tell you what's wrong, but I can post a script that does what you want:
//for player 1's sprite when gf clicked forever if <key [right arrow v] pressed?> change x by (10)//and so forth end when gf clicked//for player 2 forever if <key [d v] pressed?> change x by (10)//and so forth endThe only thing I can tell you to do is make sure you have the scripts in two separate sprites (some people don't ), check they're ordered right and not stacked inside each other and to post the project so we can see your scripts.
Offline
Make sure you are using two sprites, one for player 1 and the other for player 2.
If you don't, the following script won't work.
Once you have both sprites, delete your current moving scripts and instead put the following scripts for each of the two sprites.
SPRITE 1 - PLAYER 1:
when gf clicked forever if <key [down arrow v] pressed?> change y by (-10) //Change this amount to what you want but keep the negative. end if <key [up arrow v] pressed?> change y by (10) //Keep this amount the same through the entire script. end if <key [left arrow v] pressed?> change x by (-10) //Keep the negative and keep this amount the same as the others. end if <key [right arrow v] pressed?> change x by (10) //Keep amount the same as the others. end endNow change to the next sprite.
when gf clicked forever if <key [s v] pressed?> change y by (-10) //Make all these numbers the same as the first script. end if <key [w v] pressed?> change y by (10) //Make all numbers the same. end if <key [a v] pressed?> change x by (-10) //Keep the negative always. end if <key [d v] pressed?> change x by (10) //Make all numbers in the script the same. end endThat should work!
Offline
Thanks, both of those worked but I am now encountering a different problem. When my sprite goes straight at a wall it hits the wall and bounces off, but when I go diagonally at the wall my sprite goes straight through. I'm using these scratchblocks to control sprite 1 (sprite 2 is basically the same but with different keys to move it):
when gf clicked forever if <key [right arrow v] pressed> set [Safe X v] to (x position) set [Safe Y v] to (y position) change x by (5) endSorry if that doesn't make much sense I've never tried to add scratch blocks to a post before. I used a project about making sprites bounce off walls by Kioti16 if you're wondering about the safe X and safe Y bits, just search it.
Offline
You could do something like this:
when gf clicked forever if <key [s v] pressed?> change y by (-10) end if <key [w v] pressed?> change y by (10) end if <key [a v] pressed?> change x by (-10) end if <key [d v] pressed?> change x by (10) end end
Last edited by sanjayraj (2012-06-24 10:38:23)
Offline
i made a really simple 2 player game where to sprites move around together, it has no interaction or anything, but that should be really easy to add, i will edit this post with a link when i upload it. it might be what ur looking for.
Offline
Sorry, sanjayraj, that's pretty much what I've got already. And Corwen, I looked at your project and it wasn't right so I downloaded it, fixed it and uploaded it as a remix. Here's the link:
http://scratch.mit.edu/projects/THEphish/2632139
Offline