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

#1 2010-06-23 17:28:50

Mike358
Scratcher
Registered: 2009-02-20
Posts: 11

Uneven Road?

How can you make a character change angles to follow a route that curves slowly upward, sometimes even turning upside down?  Like, in Super Mario Galaxy 2, with Dash Pepper Yoshi, if you've played that game.

Offline

 

#2 2010-06-23 19:21:06

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

Re: Uneven Road?

use a multicolor sensor sprite that will read the ground angle and turn the sprite accordingly


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

Offline

 

#3 2010-06-24 06:57:52

Mike358
Scratcher
Registered: 2009-02-20
Posts: 11

Re: Uneven Road?

What do you mean?

Offline

 

#4 2010-06-24 07:20:37

Paddle2See
Scratch Team
Registered: 2007-10-27
Posts: 1000+

Re: Uneven Road?

Maybe you can use this as a base...

http://scratch.mit.edu/projects/Paddle2See/173249


http://i39.tinypic.com/2nav6o7.gif

Offline

 

#5 2010-06-27 19:04:03

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

Re: Uneven Road?

A "sensor sprite" is a sprite that you hide from the player but that always goes to the player sprite's position on the screen. You use it to do collision detection instead of the cool, animated sprite image that the player sees. The benefit of this is that you can check for collisions in multiple directions and then use that data to rotate and/or move the player. Here is an example of a sensor sprite in use...
Random Dungeon Generator

I am using it to keep the player from walking through walls.
Note:
1) it gets hidden so that the player doesn't see it
2) it has multi-colored 'feelers' in 4 directions. By checking each color seperately, I can determine which way is blocked and which way is cleared. !!Also!! it allows me to overcome a common problem where running into a wall freezes a player by limiting movement only in the direction of the wall or whatever is blocking the sprite.

A major factor in collision detection is Scratch is how fast the sprite is moving across the screen, the faster the harder to do correct detections. In your case with inverted ground, you may need to add some arms to the sensor sprite. Mine has 4 but all my walls are either vertical or horizontal so it works fine. Adding 4 more (between the others) will allow you finer control over rotating the player sprite to match the ground angle as it inverts. Another thing you can do is split each arm into multiple colors. Make the color closest to the end rotate the player a small amount, with successive color closer to the center of the sensor sprite adding increasingly to the rotation amount. More coding but this will give you even finer control.


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

Offline

 

#6 2010-06-28 15:47:50

Mike358
Scratcher
Registered: 2009-02-20
Posts: 11

Re: Uneven Road?

Ok, I'll have to try that.

Offline

 

#7 2010-06-28 16:21:44

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

Re: Uneven Road?

Hmmm.. here is another system. You'd have to change the gravity so that it changed the direction it pulled the sprite according to the sprite's rotation instead of always down. The beauty of this system is that it would allow for fine rotation without all the crazy color/feeler coding. It only uses two color feelers, a round one in the front and a round one in the back and they turn the sprite back and forth depending on if they are touching the ground. Since this is a motorcycle sim (not mine btw) the tires also propel the sprite forward when they touch ground so you'd want to change that.
moto sim


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

Offline

 

Board footer