Discuss Scratch

meowmoo
Scratcher
500+ posts

how can i make a level editor?

you know how some famous scratchers have level editors in their projects so they dont have to go inside to change the level? i want to know how to make one, because that would be really handy. does anyone know how?

http://fyucha.com/

R a i n b o w
ErnieParke
Scratcher
1000+ posts

how can i make a level editor?

A very simple way to do this is through the pen. Let's say green is the floor, red is lava, and yellow is the goal. Then all you need to do is add in a feature where the player uses the pen to draw the level.

But then how would put the player in a different space then where it starts? Just make a variable called (Creating Level?). When you start the project, set it to Yes, but whenever you test a level, set it to No. And finally, when you finish testing a level, set it to Yes again. This way, in your player sprite, you can use this script:

when gf clicked
if <(mouse down) and (touching [mouse pointer v]?)> then
if <(Creating Level?) = [Yes]> then
go to [Mouse Pointer v]
end
end

You can also use stamping instead of the pen for other game features like spikes, torches, chests, ect…

Any questions? Is there anything else you'd like to know how to do?

Helping,

ErnieParke

meowmoo
Scratcher
500+ posts

how can i make a level editor?

ErnieParke wrote:

A very simple way to do this is through the pen. Let's say green is the floor, red is lava, and yellow is the goal. Then all you need to do is add in a feature where the player uses the pen to draw the level.

But then how would put the player in a different space then where it starts? Just make a variable called (Creating Level?). When you start the project, set it to Yes, but whenever you test a level, set it to No. And finally, when you finish testing a level, set it to Yes again. This way, in your player sprite, you can use this script:

when gf clicked
if <(mouse down) and (touching [mouse pointer v]?)> then
if <(Creating Level?) = [Yes]> then
go to [Mouse Pointer v]
end
end

You can also use stamping instead of the pen for other game features like spikes, torches, chests, ect…

Any questions? Is there anything else you'd like to know how to do?

Helping,

ErnieParke
but how would it be saved?

http://fyucha.com/

R a i n b o w
1234abcdcba4321
Scratcher
1000+ posts

how can i make a level editor?

You need to give each type of block a certain ID.

Eg.
Block = a (Black)
Lava = b (Red)
Spring = c (Blue)
Empty = d (White)

Then, the game just needs to look into each tile.
define save
set y to (-179)
set [save v] to []
repeat (36)
set x to (-239)
repeat (48)
if <touching color [Black]?> then
set [save v] to (join (save) [a])
else
if <touching color [Red]?> then
set [save v] to (join (save) [b])
else
if <touching color [Blue]?> then
set [save v] to (join (save) [c])
else
set [save v] to (join (save) [d])
end
end
end
change x by (10)
end
change y by (10)
end
insert some stuff here ::gray
//Prepare a costume for each color...
define load
set y to (-179)
set [i v] to [0]
repeat (36)
set x to (-239)
repeat (48)
change [i v] by (1)
if <(letter (i) of (save)) = [a]> then
switch costume to [black v]
else
if <(letter (i) of (save)) = [b]> then
switch costume to [red v]
else
if <(letter (i) of (save)) = [c]> then
switch costume to [blue v]
else
switch costume to [white v]
end
end
end
stamp
change x by (10)
end
change y by (10)
end

This is assuming that the tiles are 10x10 and cover the whole screen…

when this sprite clicked // in save button
save :: custom
delete (all v) of [YOUR SAVE v]
add [Just copy that code down there and post it in the comments!] to [YOUR SAVE v]
add (save) to [YOUR SAVE v]
when this sprite clicked // in load button
ask [Paste the save code!] and wait
set [save v] to (answer)
load :: custom

Last edited by 1234abcdcba4321 (April 12, 2014 20:58:06)


I'd highly appreciate it if you were to follow me. Don't forget to go to my profile.
All of my programming suggestions <— You should really get the suggestions move back to the suggestions forum!
Five hundred posts! I never expected to get up there… In only 2-3 months.
Does anyone know what a signature is? I mean, I've already seen 6-7 people get confused.
meowmoo
Scratcher
500+ posts

how can i make a level editor?

1234abcdcba4321 wrote:

You need to give each type of block a certain ID.

Eg.
Block = a (Black)
Lava = b (Red)
Spring = c (Blue)
Empty = d (White)

Then, the game just needs to look into each tile.
define save
set y to (-179)
set [save v] to []
repeat (36)
set x to (-239)
repeat (48)
if <touching color [Black]?> then
set [save v] to (join (save) [a])
else
if <touching color [Red]?> then
set [save v] to (join (save) [b])
else
if <touching color [Blue]?> then
set [save v] to (join (save) [c])
else
set [save v] to (join (save) [d])
end
end
end
change x by (10)
end
change y by (10)
end
insert some stuff here ::gray
//Prepare a costume for each color...
define load
set y to (-179)
set [i v] to [0]
repeat (36)
set x to (-239)
repeat (48)
change [i v] by (1)
if <(letter (i) of (save)) = [a]> then
switch costume to [black v]
else
if <(letter (i) of (save)) = [b]> then
switch costume to [red v]
else
if <(letter (i) of (save)) = [c]> then
switch costume to [blue v]
else
switch costume to [white v]
end
end
end
stamp
change x by (10)
end
change y by (10)
end

This is assuming that the tiles are 10x10 and cover the whole screen…
think i got it…

http://fyucha.com/

R a i n b o w
OfficalCatCatMeowM
Scratcher
4 posts

how can i make a level editor?

ok

Powered by DjangoBB