Discuss Scratch

trudiefaye
Scratcher
2 posts

Gravity!!!!!!!!!

I need help with making a smooth good gravity in my game. I tried one thing….
[i]when green flag clicked
if <touching color [#0fff6e] ?> then
set [ gravity] to [0]

else
change [ gravity] by (-0.1)
end


when green flag clicked
forever
change y by (gravity)
end[/i]


Thanks!!!!
matthewparkerstas
Scratcher
65 posts

Gravity!!!!!!!!!

Instead of
when green flag clicked
if <touching color [#0fff6e] ?> then
set [ gravity] to [0]

else
change [ gravity] by (-0.1)
end


when green flag clicked
forever
change y by (gravity)
end[/i]
you should try
when green flag clicked
if <touching color [#0fff6e] ?> then
set [ gravity] to [0]

else
set [ gravity] to [1]
end


when green flag clicked
forever
if <[gravity] = [1]> then
repeat until <touching color [#0fff6e] ?>
change y by (3)
end
end


It's free real estate

50th post on February 5th, 2018
trudiefaye
Scratcher
2 posts

Gravity!!!!!!!!!

Thank you! I will try
TromboneAndSaxophone
Scratcher
80 posts

Gravity!!!!!!!!!

matthewparkerstas wrote:

when green flag clicked
if <touching color [#0fff6e] ?> then
set [ gravity] to [0]

else
set [ gravity] to [1]
end


when green flag clicked
forever
if <[gravity] = [1]> then
repeat until <touching color [#0fff6e] ?>
change y by (3)
end
end

How is that supposed to create a gravity effect?



How about

when green flag clicked
set [ gravity v] to [0]
forever
change [ gravity v] by (-1)
change y by (gravity)
check for ground :: custom


end
define check for ground
if <touching color [#379d59] ?> then
set [ gravity v] to [0]
if <(gravity) > [0]> then
repeat until <not <touching color [#379d59] ?>>
change y by (-1)

end


else
repeat until <not <touching color [#379d59] ?>>
change y by (1)
end
When you make the custom block, click “options”, then click the check box for “run without screen refresh”. It will run faster.

Last edited by TromboneAndSaxophone (Jan. 3, 2018 16:00:40)

Charles12310
Scratcher
1000+ posts

Gravity!!!!!!!!!

TromboneAndSaxophone wrote:

matthewparkerstas wrote:

when green flag clicked
if <touching color [#0fff6e] ?> then
set [ gravity] to [0]

else
set [ gravity] to [1]
end


when green flag clicked
forever
if <[gravity] = [1]> then
repeat until <touching color [#0fff6e] ?>
change y by (3)
end
end

How is that supposed to create a gravity effect?



How about

when green flag clicked
set [ gravity v] to [0]
forever
change [ gravity v] by (-1)
change y by (gravity)
check for ground


end
define check for ground
if <touching color [#379d59] ?> then
set [ gravity v] to [0]
if <(gravity) > [0]> then
repeat until <not <touching color [#379d59] ?>>
change y by (-1)

end


else
repeat until <not <touching color [#379d59] ?>>
change y by (1)
end
The red block is supposed to be purple, but I don't know how to fix that. When you make the custom block, click “options”, then click the check box for “run without screen refresh”. It will run faster.

check for ground :: custom

check for ground :: custom

Fixed.


Click This Link For Some Secrets About Me!
A few internet communication companies want to corrupt the internet by getting rid of net neutrality. Stop Them!

Powered by DjangoBB

Standard | Mobile