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

#1 2010-08-04 15:52:04

Sunrise-Moon
Scratcher
Registered: 2009-06-27
Posts: 1000+

This Is Going Too Far!

No, really- my sprite is going too far into the ground/land because of the y velocity. When it finally touches land, it goes too far into the land and ends up being half above the land, and half below. Anyone know of a way to fix this?

Last edited by Sunrise-Moon (2010-08-04 15:54:01)


http://i1067.photobucket.com/albums/u427/HulKDzN/RebornBlade.png

Offline

 

#2 2010-08-04 15:53:47

coolstuff
Community Moderator
Registered: 2008-03-06
Posts: 1000+

Re: This Is Going Too Far!

The only solution I know of is making it move up a little bit slower until it is no longer touching the land.

Offline

 

#3 2010-08-04 15:54:06

terminator68
Scratcher
Registered: 2008-02-26
Posts: 1000+

Re: This Is Going Too Far!

Perhaps change the script so the sprite falls down slower...


--------------------Scratcher since '08--------------------
http://images1.wikia.nocookie.net/__cb20110314152018/mlpfanart/images/5/5d/Applejack_chewing.gif

Offline

 

#4 2010-08-04 15:57:36

Sunrise-Moon
Scratcher
Registered: 2009-06-27
Posts: 1000+

Re: This Is Going Too Far!

terminator68 wrote:

Perhaps change the script so the sprite falls down slower...

The problem is actually that 'Change Y by [yVel]' continues even if the sprite is touching land. I could fix it by getting a different system for gravity, like this one:
http://i821.photobucket.com/albums/zz140/Sunrisemoon/showing.gif
That'll make it change the y by -1 until it's touching the color, and it acts like:
If not touching color
Change y by -5
End if
Except of course, that it stops upon 1 pixel of contact. Should I sacrifice realistic jumping for working jumping?

Last edited by Sunrise-Moon (2010-08-04 16:05:37)


http://i1067.photobucket.com/albums/u427/HulKDzN/RebornBlade.png

Offline

 

#5 2010-08-04 16:03:45

Harakou
Community Moderator
Registered: 2009-10-11
Posts: 1000+

Re: This Is Going Too Far!

Sunrise-Moon wrote:

terminator68 wrote:

Perhaps change the script so the sprite falls down slower...

The problem is actually that 'Change Y by [yVel]' continues even if the sprite is touching land.

It's because when you use change Y by _, it jumps there, so like you said, it goes half in and then senses. There's no real way to fix it other than having it go slower, or making an invisible sprite to test ahead of the regular one.

Last edited by Harakou (2010-08-04 16:04:01)


http://www.blocks.scratchr.org/API.php?action=random&return=image&link1=http://i.imgur.com/OZn2RD3.png&link2=http://i.imgur.com/duzaGTB.png&link3=http://i.imgur.com/CrDGvvZ.png&link4=http://i.imgur.com/POEpQyZ.png&link5=http://i.imgur.com/ZKJF8ac.png

Offline

 

#6 2010-08-04 16:08:23

graham7sarah9
Scratcher
Registered: 2009-07-19
Posts: 28

Re: This Is Going Too Far!

Is the ground flat? If so, you could add something in script that checks to see if "Yvel" is greater than the distance to the ground. But beware, the "distance to" block calculates from the center of the sprite.

Offline

 

#7 2010-08-04 16:10:59

Sunrise-Moon
Scratcher
Registered: 2009-06-27
Posts: 1000+

Re: This Is Going Too Far!

graham7sarah9 wrote:

Is the ground flat? If so, you could add something in script that checks to see if "Yvel" is greater than the distance to the ground. But beware, the "distance to" block calculates from the center of the sprite.

The level is flat, but the level is in teh backgroundz, so that won't quite work.

Last edited by Sunrise-Moon (2010-08-04 16:11:42)


http://i1067.photobucket.com/albums/u427/HulKDzN/RebornBlade.png

Offline

 

#8 2010-08-04 16:21:48

jman13
Scratcher
Registered: 2009-12-09
Posts: 65

Re: This Is Going Too Far!

Sunrise-Moon wrote:

graham7sarah9 wrote:

Is the ground flat? If so, you could add something in script that checks to see if "Y velocity" is greater than the distance to the ground. But beware, the "distance to" block calculates from the center of the sprite.

The level is flat, but the level is in the backgrounds, so that won't quite work.

I don't think scratch has a <distance to[ stage] block for the stage, but if there is would be one it would be the distance to the center, since its a scroller the sprite isn't really moving, the terrain is.

Last edited by jman13 (2010-08-04 16:24:19)

Offline

 

#9 2010-08-04 16:23:13

Sunrise-Moon
Scratcher
Registered: 2009-06-27
Posts: 1000+

Re: This Is Going Too Far!

jman13 wrote:

Sunrise-Moon wrote:

graham7sarah9 wrote:

Is the ground flat? If so, you could add something in script that checks to see if "Y velocity" is greater than the distance to the ground. But beware, the "distance to" block calculates from the center of the sprite.

The level is flat, but the level is in the backgrounds, so that won't quite work.

I don't think scratch has a <distance to  []> block for the stage, but if there is would be one it would be the distance to the center, since its a scroller the sprite isn't really moving, the terrain is.

That's what I meant. And by the way, this isn't a scroller- the levels stay still and stuff.


http://i1067.photobucket.com/albums/u427/HulKDzN/RebornBlade.png

Offline

 

#10 2010-08-04 16:25:02

jman13
Scratcher
Registered: 2009-12-09
Posts: 65

Re: This Is Going Too Far!

Oh.

Offline

 

#11 2010-08-04 16:33:14

murpho
Scratcher
Registered: 2010-07-01
Posts: 1000+

Re: This Is Going Too Far!

What if like you dont jump high enough. Youll get stuck in the middle of the thing you want to jump on


https://lh6.googleusercontent.com/-l-rgCPiQ9pY/Tp32n1MRUEI/AAAAAAAADoA/HNQWbO8OOaA/s510/soccerleague.gif

Offline

 

#12 2010-08-04 16:33:44

Sunrise-Moon
Scratcher
Registered: 2009-06-27
Posts: 1000+

Re: This Is Going Too Far!

murpho wrote:

What if like you dont jump high enough. Youll get stuck in the middle of the thing you want to jump on

Eh?


http://i1067.photobucket.com/albums/u427/HulKDzN/RebornBlade.png

Offline

 

#13 2010-08-04 16:41:24

murpho
Scratcher
Registered: 2010-07-01
Posts: 1000+

Re: This Is Going Too Far!

Like hmm.... In some platformers on here if you dont get on top but half way through where you want to land you are in the middle of it


https://lh6.googleusercontent.com/-l-rgCPiQ9pY/Tp32n1MRUEI/AAAAAAAADoA/HNQWbO8OOaA/s510/soccerleague.gif

Offline

 

#14 2010-08-04 16:42:41

Sunrise-Moon
Scratcher
Registered: 2009-06-27
Posts: 1000+

Re: This Is Going Too Far!

murpho wrote:

Like hmm.... In some platformers on here if you dont get on top but half way through where you want to land you are in the middle of it

That can be fixed with sensors  smile


http://i1067.photobucket.com/albums/u427/HulKDzN/RebornBlade.png

Offline

 

#15 2010-08-04 16:42:47

terminator68
Scratcher
Registered: 2008-02-26
Posts: 1000+

Re: This Is Going Too Far!

If you want, I can give you a script for correct y movement. It even has velocity  big_smile


--------------------Scratcher since '08--------------------
http://images1.wikia.nocookie.net/__cb20110314152018/mlpfanart/images/5/5d/Applejack_chewing.gif

Offline

 

#16 2010-08-04 16:46:16

Sunrise-Moon
Scratcher
Registered: 2009-06-27
Posts: 1000+

Re: This Is Going Too Far!

terminator68 wrote:

If you want, I can give you a script for correct y movement. It even has velocity  big_smile

Please do  smile


http://i1067.photobucket.com/albums/u427/HulKDzN/RebornBlade.png

Offline

 

#17 2010-08-04 17:02:32

Harakou
Community Moderator
Registered: 2009-10-11
Posts: 1000+

Re: This Is Going Too Far!

Sunrise-Moon wrote:

graham7sarah9 wrote:

Is the ground flat? If so, you could add something in script that checks to see if "Yvel" is greater than the distance to the ground. But beware, the "distance to" block calculates from the center of the sprite.

The level is flat, but the level is in teh backgroundz, so that won't quite work.

Well just figure out the y position of the ground.

Code:

When green flag clicked
Forever if not ((y postion + Yvel) < y position of ground)
   Change y by Yvel

http://www.blocks.scratchr.org/API.php?action=random&amp;return=image&amp;link1=http://i.imgur.com/OZn2RD3.png&amp;link2=http://i.imgur.com/duzaGTB.png&amp;link3=http://i.imgur.com/CrDGvvZ.png&amp;link4=http://i.imgur.com/POEpQyZ.png&amp;link5=http://i.imgur.com/ZKJF8ac.png

Offline

 

#18 2010-08-04 17:04:41

Sunrise-Moon
Scratcher
Registered: 2009-06-27
Posts: 1000+

Re: This Is Going Too Far!

Harakou wrote:

Sunrise-Moon wrote:

graham7sarah9 wrote:

Is the ground flat? If so, you could add something in script that checks to see if "Yvel" is greater than the distance to the ground. But beware, the "distance to" block calculates from the center of the sprite.

The level is flat, but the level is in teh backgroundz, so that won't quite work.

Well just figure out the y position of the ground.

Code:

When green flag clicked
Forever if not ((y postion + Yvel) < y position of ground)
   Change y by Yvel

It won't work fast enough is the problem.


http://i1067.photobucket.com/albums/u427/HulKDzN/RebornBlade.png

Offline

 

#19 2010-08-04 17:10:16

terminator68
Scratcher
Registered: 2008-02-26
Posts: 1000+

Re: This Is Going Too Far!

Sunrise-Moon wrote:

terminator68 wrote:

If you want, I can give you a script for correct y movement. It even has velocity  big_smile

Please do  smile

http://resources.scratchr.org/view/221. You may need to change the costumes  tongue .


--------------------Scratcher since '08--------------------
http://images1.wikia.nocookie.net/__cb20110314152018/mlpfanart/images/5/5d/Applejack_chewing.gif

Offline

 

#20 2010-08-04 17:16:13

Sunrise-Moon
Scratcher
Registered: 2009-06-27
Posts: 1000+

Re: This Is Going Too Far!

terminator68 wrote:

Sunrise-Moon wrote:

terminator68 wrote:

If you want, I can give you a script for correct y movement. It even has velocity  big_smile

Please do  smile

http://resources.scratchr.org/view/221. You may need to change the costumes  tongue .

That's what I was talking about with my script above^.

For now, I think it's impossible to fix my problem- I've tried everything (except the kitchen sink).


http://i1067.photobucket.com/albums/u427/HulKDzN/RebornBlade.png

Offline

 

#21 2010-08-04 17:37:25

Locomule
Scratcher
Registered: 2009-08-24
Posts: 500+

Re: This Is Going Too Far!

I'll fix it  smile  Can you post a link to it here first though? I gotta go get my wife at work so I'll check for it when  get back.


aka Pain from DragonSpires, Delrith Online, BotBattle, Urban Dead etc etc lol

Offline

 

#22 2010-08-04 17:44:35

Harakou
Community Moderator
Registered: 2009-10-11
Posts: 1000+

Re: This Is Going Too Far!

Sunrise-Moon wrote:

Harakou wrote:

Sunrise-Moon wrote:


The level is flat, but the level is in teh backgroundz, so that won't quite work.

Well just figure out the y position of the ground.

Code:

When green flag clicked
Forever if not ((y postion + Yvel) < y position of ground)
   Change y by Yvel

It won't work fast enough is the problem.

Why not? It will go the same speed, but will check if it will go past the ground first.


http://www.blocks.scratchr.org/API.php?action=random&amp;return=image&amp;link1=http://i.imgur.com/OZn2RD3.png&amp;link2=http://i.imgur.com/duzaGTB.png&amp;link3=http://i.imgur.com/CrDGvvZ.png&amp;link4=http://i.imgur.com/POEpQyZ.png&amp;link5=http://i.imgur.com/ZKJF8ac.png

Offline

 

#23 2010-08-04 17:46:23

Sunrise-Moon
Scratcher
Registered: 2009-06-27
Posts: 1000+

Re: This Is Going Too Far!

Locomule wrote:

I'll fix it  smile  Can you post a link to it here first though? I gotta go get my wife at work so I'll check for it when  get back.

Here you go:
http://scratch.mit.edu/projects/Sunrise-Moon/1229445
Delete the sprite that is 'lol' when you download it- I only added it so the game would appear to be some stupid noob thing  tongue


http://i1067.photobucket.com/albums/u427/HulKDzN/RebornBlade.png

Offline

 

#24 2010-08-04 18:46:47

archmage
Scratcher
Registered: 2007-05-18
Posts: 1000+

Re: This Is Going Too Far!

Wow, so much struggling for such an simple problem. What happens when your sprite moves too far down (or any direction), you move it in the opposite direction, which in this case is up. The only problem now is telling the sprite when it is stuck in the ground, and for this I use sensor sprites.

I made a demo for this @ http://scratch.mit.edu/projects/archmage/101212

This is how I learned in flash, except in flash there is a command called a "hitTest" which lets you see if a sprite is in contact with a specific coordinate. Traditional games do not use an "Art Based" approach like scratch projects do. Instead all the information for the terrain, player and enemies are stored in Multi-dimentional arrays (simply lists of lists, think tables) and the game checks different values in the  array to see if the player is hitting anything.

Last edited by archmage (2010-08-04 18:51:26)


Hi, I am Archmage coder extraordinaire. I do Scratch,pascal,java,php,html, AS2 and AS3. Leave me a message if you want coding advice. Also check out my personal website, lots of good stuff about web development, Flash, and Scratch (v1 and v2) !

Offline

 

#25 2010-08-04 19:46:35

Locomule
Scratcher
Registered: 2009-08-24
Posts: 500+

Re: This Is Going Too Far!

Obviously any solution depends on your future plans. I'm assuming you will eventually have multiple maps with varying platform heights. I see you already have a sensor sprite started, is that the route you wanna take? Because if you are gonna make multiple, varied maps, the sensor sprite is a pretty easy and reliable way to go.


aka Pain from DragonSpires, Delrith Online, BotBattle, Urban Dead etc etc lol

Offline

 

Board footer