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

#1 2011-08-06 12:30:30

Corne7
Scratcher
Registered: 2011-07-20
Posts: 45

How do I make a co-op game?

I am trying to work on a Scratch project involving two characters, yet cannot find a way to make it so that when BOTH objects reach their goal, the background changes, not unlike Portal 2. I'm hoping a more experienced Scratch member can help me out. If you have ANY idea on how I can do this, please post. Thank you.


http://i54.tinypic.com/35iruih.png
Leader and Creator of MEOW Gaming.

Offline

 

#2 2011-08-06 12:37:45

Harakou
Community Moderator
Registered: 2009-10-11
Posts: 1000+

Re: How do I make a co-op game?

You could probably use an <and> statement to check if both sprites are at the goal, somewhat like this:

Goal Sprite:

Code:

When green flag clicked
forever if <touching p1 and touching p2>
     broadcast [level change]

Stage

Code:

When I receive [level change]
next background

Hope that helps!


http://www.blocks.scratchr.org/API.php?action=random&amp;return=image&amp;link1=http://i.imgur.com/OZn2RD3.png&amp;link2=http://i.imgur.com/duzaGTB.png&amp;link3=http://i.imgur.com/CrDGvvZ.png&amp;link4=http://i.imgur.com/POEpQyZ.png&amp;link5=http://i.imgur.com/ZKJF8ac.png

Offline

 

#3 2011-08-06 12:38:12

laptop97
Scratcher
Registered: 2011-06-27
Posts: 1000+

Re: How do I make a co-op game?

You could try:

Start
Forever If <touching[sprite1]> and <touching[sprite2]>
  Broadcast [Change Background]

Sorry, I didn't see the above post while I was writing.

Last edited by laptop97 (2011-08-06 12:39:13)

Offline

 

#4 2011-08-06 13:00:02

Corne7
Scratcher
Registered: 2011-07-20
Posts: 45

Re: How do I make a co-op game?

Thanks guys, I'll try these out!


http://i54.tinypic.com/35iruih.png
Leader and Creator of MEOW Gaming.

Offline

 

#5 2011-08-06 13:03:50

Corne7
Scratcher
Registered: 2011-07-20
Posts: 45

Re: How do I make a co-op game?

It works! Thank you so much, guys! Expect the project I needed this for to be posted in about a week. Thanks again!


http://i54.tinypic.com/35iruih.png
Leader and Creator of MEOW Gaming.

Offline

 

#6 2011-08-06 13:15:47

Corne7
Scratcher
Registered: 2011-07-20
Posts: 45

Re: How do I make a co-op game?

Is there anyway I can do it with a colour and not a sprite?


http://i54.tinypic.com/35iruih.png
Leader and Creator of MEOW Gaming.

Offline

 

#7 2011-08-06 13:21:38

Corne7
Scratcher
Registered: 2011-07-20
Posts: 45

Re: How do I make a co-op game?

Or a way to move the sprite with every background?


http://i54.tinypic.com/35iruih.png
Leader and Creator of MEOW Gaming.

Offline

 

#8 2011-08-06 13:27:42

laptop97
Scratcher
Registered: 2011-06-27
Posts: 1000+

Re: How do I make a co-op game?

It's a little harder with colors. I quickly created this.

Offline

 

#9 2011-08-06 13:37:44

Corne7
Scratcher
Registered: 2011-07-20
Posts: 45

Re: How do I make a co-op game?

Can you please tell me the basics of it because my computer can't handle downloads  sad


http://i54.tinypic.com/35iruih.png
Leader and Creator of MEOW Gaming.

Offline

 

#10 2011-08-06 13:37:59

Harakou
Community Moderator
Registered: 2009-10-11
Posts: 1000+

Re: How do I make a co-op game?

With colors, it might be a bit trickier depending on how you want to do it. If you want the goal to be a distinct color instead of a sprite, you should have a script in each player sprite that sets a value (such as p1 touching) to 1 when touching that color and 0 when it's not.

Player sprites:

Code:

When green flag clicked
forever
    if <touching color red>
        set [p1 touching] to 1
    else
        set [p1 touching] to 0

Then you'd want to modify the original script I showed you to look like this:

Stage:

Code:

When green flag clicked
forever
    if <[p1 touching] = 1 and [p2 touching] = 1>
        next background

http://www.blocks.scratchr.org/API.php?action=random&amp;return=image&amp;link1=http://i.imgur.com/OZn2RD3.png&amp;link2=http://i.imgur.com/duzaGTB.png&amp;link3=http://i.imgur.com/CrDGvvZ.png&amp;link4=http://i.imgur.com/POEpQyZ.png&amp;link5=http://i.imgur.com/ZKJF8ac.png

Offline

 

#11 2011-08-06 13:47:26

Corne7
Scratcher
Registered: 2011-07-20
Posts: 45

Re: How do I make a co-op game?

Harakou, you are brilliant. Works perfectly. Thank you so much!

(You have recieved: +5 Internet Points)


http://i54.tinypic.com/35iruih.png
Leader and Creator of MEOW Gaming.

Offline

 

#12 2011-08-06 13:54:33

laptop97
Scratcher
Registered: 2011-06-27
Posts: 1000+

Re: How do I make a co-op game?

That's almost exactly like the scripts in my project  tongue

Last edited by laptop97 (2011-08-06 13:56:28)

Offline

 

#13 2011-08-06 14:08:37

Harakou
Community Moderator
Registered: 2009-10-11
Posts: 1000+

Re: How do I make a co-op game?

No problem! Glad I could help.  smile


http://www.blocks.scratchr.org/API.php?action=random&amp;return=image&amp;link1=http://i.imgur.com/OZn2RD3.png&amp;link2=http://i.imgur.com/duzaGTB.png&amp;link3=http://i.imgur.com/CrDGvvZ.png&amp;link4=http://i.imgur.com/POEpQyZ.png&amp;link5=http://i.imgur.com/ZKJF8ac.png

Offline

 

#14 2011-08-08 10:27:09

DigiTechs
Scratcher
Registered: 2011-04-30
Posts: 500+

Re: How do I make a co-op game?

Harakou wrote:

With colors, it might be a bit trickier depending on how you want to do it. If you want the goal to be a distinct color instead of a sprite, you should have a script in each player sprite that sets a value (such as p1 touching) to 1 when touching that color and 0 when it's not.

Player sprites:

Code:

When green flag clicked
forever
    if <touching color red>
        set [p1 touching] to 1
    else
        set [p1 touching] to 0

Then you'd want to modify the original script I showed you to look like this:

Stage:

Code:

When green flag clicked
forever
    if <[p1 touching] = 1 and [p2 touching] = 1>
        next background

You do know you dont need to use variables:
Player dosent need a script
Stage:

Code:

 When green flag clicked
forever
   if < <[p1colour] touching [goalcolour]> and <[p2colour] touching [goalcolour]>
         next background
   end if
end forever

Less scripts for each, but more complicated to put together.


I'm back.
Maybe.

Offline

 

Board footer