OK, I've got a platformer where the yvel variable won't work right. My character keeps bobbing up and down, like this:
o
|
-----------^---
Then gradually goes down to something like this:
o
-----------|------
^
and repeats over and over and over. Here's my scripts.
when gf clicked
forever
change y by (yvel)
end
when gf clicked
forever
change [yvel] by (-0.25)
if <color [blue] is touching color [green]?>
set [yvel] to [0]
end
if <(yvel) = (-5)>
change yvel by (1)
end
if <color [red] is touching color [green]?>
change [yvel] by (0.25)
if <key [space] pressed?>
repeat (5)
change [yvel] by (1)
end
end
end
end
Blue=head and red= body.
Last edited by KyleK7 (2012-04-29 16:32:50)
Offline
I'm only familiar with x velocity but.. I think that you should not use the -0.25! Instead you should use a forever if not key space pressed script, and then do repeat until not touching color blahblahblah, change the y Thingy by minus something. Did this help?
----
Lunastar-
Offline
when gf clicked forever change [yvel v] by (-0.2) change y by (yvel) if<<color [blue] touching color [green]?> or <color [red] touching color [green]?>> set [y-vel v] to ((-0.5)*(y-vel)) change y by (y-vel) if<color [blue] touching color [green]?> change y by (y-vel) if<<key [space v] pressed?> and <(y-vel) < (0)>> set [yvel v] to (4) end endThat should do it
Offline
I was thinking of, forever if Not Color red is touching color green, change y velocity by -o.2 and keep everything else the same
I might remove the change y velocity by 0.25
Offline
start with something simple,
[scratchblocks]
when gf clicked
forever if touching color (blue is the background) and not touching color (brown is the ground)
change y by -1
Offline