This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2012-06-23 12:51:46

THEphish
New Scratcher
Registered: 2012-06-23
Posts: 15

2 Player Maze Game - Help!!!

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

 

#2 2012-06-23 13:03:13

zammer990
Scratcher
Registered: 2012-01-22
Posts: 500+

Re: 2 Player Maze Game - Help!!!

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
end
The only thing I can tell you to do is make sure you have the scripts in two separate sprites (some people don't  hmm ), check they're ordered right and not stacked inside each other and to post the project so we can see your scripts.


http://i45.tinypic.com/2ynq7nn.jpg Play now!

Offline

 

#3 2012-06-23 15:08:54

SOScratch
Scratcher
Registered: 2010-02-01
Posts: 100+

Re: 2 Player Maze Game - Help!!!

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
end
Now change to the next sprite.

SPRITE 2 - PLAYER 2:

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
end
That should work!

VERY IMPORTANT - Keep the negatives in the numbers. You can change the numbers to what you want and that will determine the player movement speed but all the numbers in both scripts have to be the same.
If they are not, the player will end up with weird movement speeds and whatnot.
BE WARNED!


-SOScratch
Scratch On!

Offline

 

#4 2012-06-24 05:42:42

THEphish
New Scratcher
Registered: 2012-06-23
Posts: 15

Re: 2 Player Maze Game - Help!!!

Thanks, both of those worked  smile  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)
end
Sorry 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.

Please may someone help me with this, as I just can't work out how to fix it!

Offline

 

#5 2012-06-24 05:46:46

THEphish
New Scratcher
Registered: 2012-06-23
Posts: 15

Re: 2 Player Maze Game - Help!!!

Sorry in the key right arrow pressed bit it should be:
<key [right arrow v] pressed?>

I do like that 4 every direction.  smile

Offline

 

#6 2012-06-24 10:38:11

sanjayraj
Scratcher
Registered: 2012-03-25
Posts: 500+

Re: 2 Player Maze Game - Help!!!

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)


http://i46.tinypic.com/23sw40j.png

Offline

 

#7 2012-06-24 10:41:52

Corwen
New Scratcher
Registered: 2012-06-23
Posts: 28

Re: 2 Player Maze Game - Help!!!

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

 

#8 2012-06-24 10:50:57

Corwen
New Scratcher
Registered: 2012-06-23
Posts: 28

Re: 2 Player Maze Game - Help!!!

here is my above mentioned game for u to have a look at, simple stuff really:

http://scratch.mit.edu/projects/Corwen/2632028

Offline

 

#9 2012-06-24 11:58:55

THEphish
New Scratcher
Registered: 2012-06-23
Posts: 15

Re: 2 Player Maze Game - Help!!!

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

 

#10 2012-06-24 12:03:30

THEphish
New Scratcher
Registered: 2012-06-23
Posts: 15

Re: 2 Player Maze Game - Help!!!

Problem still not solved.

Offline

 

#11 2012-07-01 05:15:14

THEphish
New Scratcher
Registered: 2012-06-23
Posts: 15

Re: 2 Player Maze Game - Help!!!

Problem now solved thanks to MoreGamesNow on another forum. Look at my project Planez V1, which contains the working scripts.

Offline

 

Board footer