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

#1 2012-02-13 13:03:17

Flippers777
Scratcher
Registered: 2009-10-17
Posts: 100+

Censors for a game :P

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.)


I need a new signature. so ignore this empty boring space until i find or make one XD

Offline

 

#2 2012-02-13 13:05:33

CheeseMunchy
Scratcher
Registered: 2008-10-13
Posts: 1000+

Re: Censors for a game :P

I've never done it. I would love to find out how too.


6418,

Offline

 

#3 2012-02-13 13:10:35

RedRocker227
Scratcher
Registered: 2011-10-26
Posts: 1000+

Re: Censors for a game :P

What a coincidence, I've just discovered an awesome new way to do this  tongue  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.


Why

Offline

 

#4 2012-02-13 13:18:25

Flippers777
Scratcher
Registered: 2009-10-17
Posts: 100+

Re: Censors for a game :P

i totally forgot how to switch to turbo mode XD how do you do it again...?

OK, i figured it out  smile  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)


I need a new signature. so ignore this empty boring space until i find or make one XD

Offline

 

#5 2012-02-13 13:27:57

RedRocker227
Scratcher
Registered: 2011-10-26
Posts: 1000+

Re: Censors for a game :P

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.


Why

Offline

 

#6 2012-02-13 13:29:19

Flippers777
Scratcher
Registered: 2009-10-17
Posts: 100+

Re: Censors for a game :P

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.  smile


I need a new signature. so ignore this empty boring space until i find or make one XD

Offline

 

#7 2012-02-13 13:40:34

RedRocker227
Scratcher
Registered: 2011-10-26
Posts: 1000+

Re: Censors for a game :P

Oh, okay.


Why

Offline

 

#8 2012-02-13 13:56:04

LS97
Scratcher
Registered: 2009-06-14
Posts: 1000+

Re: Censors for a game :P

The stuff doesn't need to be that complicated  smile

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!  smile

Offline

 

#9 2012-02-13 14:03:21

Flippers777
Scratcher
Registered: 2009-10-17
Posts: 100+

Re: Censors for a game :P

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)


I need a new signature. so ignore this empty boring space until i find or make one XD

Offline

 

#10 2012-02-13 14:53:25

LS97
Scratcher
Registered: 2009-06-14
Posts: 1000+

Re: Censors for a game :P

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  smile

Offline

 

#11 2012-02-13 15:07:18

Flippers777
Scratcher
Registered: 2009-10-17
Posts: 100+

Re: Censors for a game :P

ok i'll try it. Thanks  smile


I need a new signature. so ignore this empty boring space until i find or make one XD

Offline

 

#12 2012-02-13 16:47:40

MoreGamesNow
Scratcher
Registered: 2009-10-12
Posts: 1000+

Re: Censors for a game :P

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


http://images2.layoutsparks.com/1/218929/rubiks-cube-animated-rotating.gif
"Cogito ergo sum" --  I think, therefore I am

Offline

 

#13 2012-02-13 17:06:01

Flippers777
Scratcher
Registered: 2009-10-17
Posts: 100+

Re: Censors for a game :P

thank you, i'll try that one too!  smile

EDIT: It works perfectly! Thank you everyone for the help  big_smile

Last edited by Flippers777 (2012-02-13 17:10:35)


I need a new signature. so ignore this empty boring space until i find or make one XD

Offline

 

Board footer