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

#1 2009-04-15 19:44:33

dfinlay
Scratcher
Registered: 2009-04-15
Posts: 2

Gravity and Ground from the Side of a Game

We're trying to make blue space empty, and black space solid, so a character moving over black space stays on its surface, but if he walks off it, he falls.

Also, if he falls into lava, we wanted certain conditions met, and have had trouble making these conditions supercede our falling conditions.

Offline

 

#2 2009-04-15 19:53:18

Mike_W
Scratcher
Registered: 2009-02-05
Posts: 100+

Re: Gravity and Ground from the Side of a Game

Never tried what you are doing but I think you need to set up a state machine to the multiple conditions cannot apply at once.

Set a sprite variable standing = if it's a 3 you are touching lava, 2 touching blue, and 1 touching black

And three trumps 2 and 1 and 2 trumps 1.

So if you touching 3 you die.

If you are touching 2 you stand

If you are touching 1 and  (and there fore not anything else) you fall.

Offline

 

#3 2009-04-16 10:03:28

dfinlay
Scratcher
Registered: 2009-04-15
Posts: 2

Re: Gravity and Ground from the Side of a Game

I found a nearly acceptable solution.  It requires an if/else block inside another if/else block inside a forever loop on a "when green flag pressed" condition, to create a hierarchy of priority that is always running.  The first if is if touching death color, die, the highest priority.  Else, If touching ground color, (the second highest priority) change Y by 0 (in other words, do nothing), else change y by -5.

The biggest problem I'm having now is that my jump command (which is a loop 12 times increase y by 5) can be pressed over and over, and is not effected by the player holding down the forward arrow key.  This allows for some interesting controls, kindof like flying, but not the very intuitive mario-style controls my students were hoping to achieve.

Offline

 

Board footer