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

#1 2013-03-26 14:31:38

Wifflekipter
New Scratcher
Registered: 2013-03-26
Posts: 7

I'm trying to improve a level-changing script.

So, I'm trying to make a platformer. I'm trying to make it so that I can use just one color to switch to multiple different  levels. Here's my current scripts for portals/level-changing:
(Sprite's script)

when flag clicked
forever
if <touching color white>
broadcast level1
(Stage's script)
when i receive level 1
switch to background background 2
However, this script only lets the game only have one level, as if i made the script for Sprite 3 somewhat like this:

if <touching color white>
broadcast level1\
broadcast level2
It would just change to level 2, right?

I know that you could make multiple sprites to change the levels, but the last time I used that, I somehow screwed something up, and then the whole game was broken (skipping levels, spawning in the wrong place, etc.). So I'd rather not have that happen.

If anyone can help, please reply.

Offline

 

#2 2013-03-26 22:38:14

ErnieParke
Scratcher
Registered: 2010-12-03
Posts: 1000+

Re: I'm trying to improve a level-changing script.

Wifflekipter wrote:

So, I'm trying to make a platformer. I'm trying to make it so that I can use just one color to switch to multiple different  levels. Here's my current scripts for portals/level-changing:
(Sprite's script)

when flag clicked
forever
 if <touching color [#FFFFFF]?>
  broadcast level1
 end
(Stage's script)
when i receive [level 1 v]
switch to background [background 2 v]
However, this script only lets the game only have one level, as if i made the script for Sprite 3 somewhat like this:

if <touching color [#FFFFFF]?>
 broadcast [level1 v]
 broadcast [level2 v]
end
It would just change to level 2, right?

I know that you could make multiple sprites to change the levels, but the last time I used that, I somehow screwed something up, and then the whole game was broken (skipping levels, spawning in the wrong place, etc.). So I'd rather not have that happen.

If anyone can help, please reply.

Fixed; anyway, I'll be back with an answer tomorrow.  wink

With regards,

ErnieParke

Last edited by ErnieParke (2013-03-26 22:38:59)


http://i46.tinypic.com/35ismmc.png

Offline

 

#3 2013-03-27 13:27:35

Wifflekipter
New Scratcher
Registered: 2013-03-26
Posts: 7

Re: I'm trying to improve a level-changing script.

Thanks.

Offline

 

#4 2013-03-27 13:30:38

xlk
Scratcher
Registered: 2013-03-18
Posts: 57

Re: I'm trying to improve a level-changing script.

When gf clicked
set [level] to (1)
forever
 if <touching color>
  change [level] by (1)
 end
 Set BG to (level)
end
One script

Offline

 

#5 2013-03-27 13:53:41

Wifflekipter
New Scratcher
Registered: 2013-03-26
Posts: 7

Re: I'm trying to improve a level-changing script.

Right, I'll try that, but what's BG?

Offline

 

#6 2013-03-27 13:56:48

Wifflekipter
New Scratcher
Registered: 2013-03-26
Posts: 7

Re: I'm trying to improve a level-changing script.

Never mind, I figured out what BG means.

Offline

 

#7 2013-03-27 14:09:08

7734f
Scratcher
Registered: 2010-12-23
Posts: 500+

Re: I'm trying to improve a level-changing script.

Wifflekipter wrote:

Right, I'll try that, but what's BG?

Yes, what IS BG?  hmm


http://internetometer.com/image/38992.png   http://i37.tinypic.com/2qixx6c.png

Offline

 

#8 2013-03-27 14:25:50

Wifflekipter
New Scratcher
Registered: 2013-03-26
Posts: 7

Re: I'm trying to improve a level-changing script.

@7734f: It means background.

@xlk: I don't understand, do you mean:

when gf clicked
switch to background [level1]
forever
   if <touching color etc.>
     switch to background [level2]
end 
Or do you just do the exact thing shown here?

Offline

 

#9 2013-03-27 14:34:36

Maltese_Falcon
Scratcher
Registered: 2013-03-25
Posts: 100+

Re: I'm trying to improve a level-changing script.

@xlk uses a variable called level. When the level changes, you increase the level by 1, and when level =1, set the background to level 1's background, etc.

Offline

 

#10 2013-03-27 14:46:25

7734f
Scratcher
Registered: 2010-12-23
Posts: 500+

Re: I'm trying to improve a level-changing script.

Wifflekipter wrote:

@ 7734f: It means background

*facepalm* Fail.


http://internetometer.com/image/38992.png   http://i37.tinypic.com/2qixx6c.png

Offline

 

#11 2013-03-27 14:53:41

7734f
Scratcher
Registered: 2010-12-23
Posts: 500+

Re: I'm trying to improve a level-changing script.

Wifflekipter wrote:

@7734f: It means background.

@xlk: I don't understand, do you mean:

when gf clicked
switch to background [level1]
forever
   if <touching color etc.>
     switch to background [level2]
end 
Or do you just do the exact thing shown here?

When the sprite touches the color

forever
 if <touching color [#00FF00]>//or your color
 end
end
Then it sends out a message:


forever
 if <touching color [#00FF00]>
broadcast [next level v]
 end
end
The stage receives the message:
When I receive [next level v]
And then changes it's background:

When I receive [next level v]
next background
Does that make sense?
The sprite that is touching the color broadcasts a message, the stage receives the message, and goes to the next background.

Hope that helped!

                 ~7734f

Last edited by 7734f (2013-03-27 14:57:29)


http://internetometer.com/image/38992.png   http://i37.tinypic.com/2qixx6c.png

Offline

 

#12 2013-03-27 15:05:32

ErnieParke
Scratcher
Registered: 2010-12-03
Posts: 1000+

Re: I'm trying to improve a level-changing script.

7734f wrote:

Wifflekipter wrote:

@7734f: It means background.

@xlk: I don't understand, do you mean:

when gf clicked
switch to background [level1]
forever
   if <touching color [#FFFFFF]?>
     switch to background [level2 v]
end 
Or do you just do the exact thing shown here?

When the sprite touches the color:

forever
 if <touching color [#00FF00]?>
  broadcast [next level v]
  wait until <not (touching color [#FFFFFF]?)>//Added
 end
The stage receives the message:
When I receive [next level v]
And then changes it's background:

When I receive [next level v]
next background
Does that make sense?
The sprite that is touching the color broadcasts a message, the stage receives the message, and goes to the next background.

Hope that helped!

                 ~7734f

Fixed, and you're probably going to want a [wait until <not (touching color[color]?)>] block as well to prevent skipping over multiple levels.

With regards,

ErnieParke


http://i46.tinypic.com/35ismmc.png

Offline

 

#13 2013-03-27 15:17:02

xlk
Scratcher
Registered: 2013-03-18
Posts: 57

Re: I'm trying to improve a level-changing script.

levelNah, might as well make the character go to a certain position on event "next level" with:

when I recieve [next level]
go to x: [x position] y: [y position]

Offline

 

#14 2013-03-28 12:39:52

Wifflekipter
New Scratcher
Registered: 2013-03-26
Posts: 7

Re: I'm trying to improve a level-changing script.

I'll try, thanks guys..

Offline

 

Board footer