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

#1 2010-09-29 21:04:59

MWisBest
Scratcher
Registered: 2010-09-29
Posts: 7

2 Keyboard Buttons 2 Sprites?

Well I'm trying to make a 2 player (1 sprite per player) sword-fighting game, but I've run into a problem,

Only 1 Sprite can move at a time, and if a sprite starts moving while another is moving the one that was moving first stops.

I've made it like this:

When (right) key pressed
point in direction 90
if on edge, bounce
move -3 steps
If (Color gray is touching gray)
   set instrument to 128
   play note 60 for 0.1 beats

"(right)" is the key assigned to a sprite for moving right, in this case the sprite on the left (Sprite1) is 'd'. For the sprite on the right (Sprite3) it is the 'right arrow' key, however depending on the sprite the move -3 steps could be either move 3 or move -3. The sprites are set so that they only change direction, not completely rotate around. They are the same sprite but the one on the right is flipped to face the one on the left.

The gray touching gray is so that it makes a little noise whenever the Sprite's swords touch, and it works fine. I'm also thinking of making it so that when they touch the Sprites move away from each other a step or two, and making key presses to perform moves like a fast stab (moves like 20 steps or something?) then has a wait 1 sec and then moves back maybe 15 steps.

I need to understand why it is that only 1 sprite can move at a time like that. My friend David made a PacMan where it is 5 players, meaning 4 people can control 4 ghosties and 1 person controls the PacMan, and the goal of the PacMan is to stay alive. It even has a background for it that looks like the real PacMan, but w/o dots (since that isn't the point of the game, the point of this one is to just stay alive) and they actually will stop if they hit a 'wall' in the background. Each character can be controlled by a different set of 4 keys acting like arrow keys like how I have mine set up. I don't see why mine doesn't work like his.

Offline

 

#2 2010-09-29 21:47:50

Jet7889
Scratcher
Registered: 2008-02-18
Posts: 100+

Re: 2 Keyboard Buttons 2 Sprites?

Well if you script it like
[blocks]
Player One
<when[ right ]key pressed>
<point in direction( 90
<if on edge, bounce>
<move( -3 )steps>
<if> <color[ gray  ]is over[ gray
<set instrument to( 128
<play note( 60  )for( 0.1 )secss>
[/blocks]
It ill move whatever sprite has this
So when you want to have two players you usally script it up for WASD keys
[blocks]
Player One
<when[ D ]key pressed>
<point in direction( 90
<if on edge, bounce>
<move( -3 )steps>
<if> <color[ gray  ]is over[ gray
<set instrument to( 128
<play note( 60  )for( 0.1 )secss>
[/blocks]
That will make it so you can have two players
If you want to see an example or dont want to script this all i made a example
here,
or this for download


Excuse me for dropping off the face of the planet.....
http://internetometer.com/image/16545.png

Offline

 

#3 2010-10-04 13:21:13

MWisBest
Scratcher
Registered: 2010-09-29
Posts: 7

Re: 2 Keyboard Buttons 2 Sprites?

If you would read my whole post you would see that I have one player using the WSAD keys and one using the arrow keys, but only 1 will move at a time.

Offline

 

#4 2010-10-08 13:42:03

MWisBest
Scratcher
Registered: 2010-09-29
Posts: 7

Re: 2 Keyboard Buttons 2 Sprites?

Well I uploaded the game to the website here. It's called 'Sword Fighting Game'. The instructions are in the project notes. I was able to get a lot done with it. I hear if I add anything new or update something I can just upload it again and it will overwrite the previous one, which sounds great!

I'm sorry for the double post but I can't edit my posts yet, and I understand the whole 'New Scratcher' thing and I think it is a great idea to have a system like that.

Offline

 

#5 2010-11-28 23:47:34

Necromaster
Scratcher
Registered: 2010-04-07
Posts: 1000+

Re: 2 Keyboard Buttons 2 Sprites?

MWisBest wrote:

If you would read my whole post you would see that I have one player using the WSAD keys and one using the arrow keys, but only 1 will move at a time.

You might try... Forever if Right arrow pressed...?

Offline

 

#6 2010-11-29 07:09:44

-GizzardGulp-
Scratcher
Registered: 2010-03-05
Posts: 100+

Re: 2 Keyboard Buttons 2 Sprites?

First you should change the -3 to a 3, because your basically saying to the sprite to turn right and then walk backwards after the right arrow is pressed.


http://i1118.photobucket.com/albums/k607/Max_Levine/SnoutmolStudios.png

Offline

 

#7 2010-11-29 07:20:57

-GizzardGulp-
Scratcher
Registered: 2010-03-05
Posts: 100+

Re: 2 Keyboard Buttons 2 Sprites?

Put this on your first sprite and then the same on the second sprite except with W,A,S and D and a different broadcast message.

http://i1118.photobucket.com/albums/k607/Max_Levine/xvxzdv.gif


http://i1118.photobucket.com/albums/k607/Max_Levine/SnoutmolStudios.png

Offline

 

Board footer