Ok, so I am making this game for school, and Im having a little bit of trouble with it. I want to make it so that the player can not pass through the black lines which are representing walls. I know there is a way to make censors and script them so that the character can't pass through certain sprites or colors, i just have no idea on how to do it. Help please? (sorry if that doesn't make sense, im bad at explaining.)
Offline
I've never done it. I would love to find out how too.
Offline
What a coincidence, I've just discovered an awesome new way to do this It requires Turbo Mode though. It basically flicks through about 100 costumes a second, to detect how close the nearest wall is. It then acts accordingly. You can check it out here.
Offline
i totally forgot how to switch to turbo mode XD how do you do it again...?
OK, i figured it out that's pretty awesome! But would it work if the player was controlled by the arrow keys instead of following the mouse?
Last edited by Flippers777 (2012-02-13 13:24:15)
Offline
Yeah, that'd be possible. I'd be happy to try and make it for you if you'd like, but I won't be able to start it until tomorrow at the earliest. Sorry.
Offline
I kinda need it by today, so that's fine you dont have to. Thank you for offering though! ^_^ im pretty sure the game wouldn't work in turbo mode either, so i'll just find an alternative.
Offline
Oh, okay.
Offline
The stuff doesn't need to be that complicated
The easiest way to do it is to use 4 invisible sprites that always move to where the player is (using the go to block). The sprites should be positioned at the four sides of the player (top bottom left right) and have a variable that will tell the player whether that side is being touched by black.
If it is, the player should act accordingly by moving a couple pixels/steps in the opposite direction.
The game chop shop by m44 is an example of what I mean.
There's also a nice Wiki article explaining in detail what I mean, you can find it here. The part you're interested in starts at about two paragraphs before the big mario with the four black T's sticking out!
Offline
thank you so much! This should really help ^-^
EDIT: Oh, i probably should've mentioned this, but is there a way to do that if im not using the <scrollx> kind of scripting? It's still kind of a scrolling game. I set it up so the player moves like the one in this game: http://scratch.mit.edu/projects/Flippers777/1232819
Last edited by Flippers777 (2012-02-13 14:08:50)
Offline
Flippers777 wrote:
thank you so much! This should really help ^-^
EDIT: Oh, i probably should've mentioned this, but is there a way to do that if im not using the <scrollx> kind of scripting? It's still kind of a scrolling game. I set it up so the player moves like the one in this game: http://scratch.mit.edu/projects/Flippers777/1232819
well, instead of changing the scroll value, you can change the player's position directly
Offline
ok i'll try it. Thanks
Offline
when gf clicked forever if <key [right] pressed?> change x by (5) if <touching color [black]?> change x by (-5) end end if <key [left] pressed?> change x by (-5) if <touching color [black]?> change x by (5) end if <key [up] pressed?> change y by (5) if <touching color [black]?> change y by (-5) end end if <key [down] pressed?> change y by (-5) if <touching color [black]?> change y by (5) end end end end
Offline
thank you, i'll try that one too!
EDIT: It works perfectly! Thank you everyone for the help
Last edited by Flippers777 (2012-02-13 17:10:35)
Offline