I am playing around with a platform game (really just experimenting to see how things work) and I am trying to get a ball sprite to move up a diagonal line.
I have all my lines in a single sprite and I use the touching sensor to know when the ball sprite touches the line sprite.
If the ball sprite isn't touching the line sprite the ball starts to fall until it lands on the line sprite again.
But I can't get the sprite to move up a diagonal line.
Offline
zammer990 wrote:
change x by (10) change y by (10)
Well, umm, yeah that much I know. LOL! It's the sensing part that I am having difficulty with.
All of the lines are in a single sprite and I want another sprite to follow the lines.
It works when the line is diagonal but as soon as the line is diagonal it stops.
Offline
Let me help:
when gf clicked forever if <touching [line v]?> change x by (1) change y by (1) else change y by (-1)//[Or whatever you use for gravity.] endI hope that this helps!
Last edited by ErnieParke (2012-08-03 12:00:34)
Offline
Hey Ernie,
I don't think that will work with the way I have the game set up.
I've uploaded the example if you would be willing to take a look.
http://scratch.mit.edu/projects/whiteflame115/2711883
Thanks a bunch.
Steve
(itek5bux aka whiteflame115's dad)
Offline
*epiphany*
Ernie your suggestion worked once I started over and built the logic around your code example.
Thanks!
Offline
whiteflame115 wrote:
*epiphany*
I never heard of that word. Let me look it up...
whiteflame115 wrote:
Ernie your suggestion worked once I started over and built the logic around your code example.
Thanks!
Your welcome! I like to help scratchers, which is what I did to you!
Just curious, is the uploaded version of your project the most up to date one? If it isn't, then can you tell me when you'll update it? And when you do, could you give me a link? Thanks.
Anyway, this is what I've found for epiphany on Dictionary.com:
Dictionary.com wrote:
e·piph·a·ny
[ih-pif-uh-nee]
noun, plural e·piph·a·nies.
Cutting part of it out...
3. A sudden, intuitive perception of or insight into the reality or essential meaning of something, usually initiated by some simple, homely, or commonplace occurrence or experience.
4. A literary work or section of a work presenting, usually symbolically, such a moment of revelation and insight.
I think that you were using definition 3.
Last edited by ErnieParke (2012-08-03 16:19:25)
Offline
I believe you are looking for slope detection, which is a very valuable skill when making a platformer. I'm really surprised that the wiki has no article on it.
Basically you want something like this:
forever if <key [right arrow v] pressed?> change x by (2) if <touching [ground v]?> change y by (4) if <touching [ground v]?> change y by (-4) else change y by (-2) end end end end
Offline
You use this.
go to x:(0)y:(0)
Last edited by maxamillion321 (2012-08-03 17:26:18)
Offline
For your sensor, you'll need to follow these steps:
1). Pick five different colors.
2). Find and copy the sprite that you want the sensor for.
3). Go and edit the 2nd copied sprite.
4). While in paint editor, use four of the five colors to create a box around the sprite. Use one color per side, and leave out the corners. Also, make the box's lines several pixels thick.
5). Pick your 5th color and make a line below, but touching, the bottom side of the box.
An example of this type of sensor can be viewed in The Dangerous Adventure, which I created to help shrey15 with sensing and moving platforms.
6). Delete everything except for the lines you had drawn earlier.
Now, put this script in the sensor:
When gf clicked hide//Or you can use [set [ghost effect v] to (100)]. forever go to [tennis ball v] if < color [ ] is touching color [black]?>// Color of the top part of the box. set [up v] to (0) else set [up v] to (1) end if < color [ ] is touching color [black]?>// Color of the left part of the box. set [left v] to (0) else set [left v] to (1) end if < color [ ] is touching color [black]?>// Color of the right part of the box. set [right v] to (0) else set [right v] to (1) end if < color [ ] is touching color [black]?>// Color of the 2nd to bottom line of box. set [down 1 v] to (0) else set [down 1 v] to (1) end if < color [ ] is touching color [black]?>// Color of the bottom line of the box. set [down 2 v] to (0) else set [down 2 v] to (1) endSome of the comments kept on getting cut off, so I had to shorten them considerably.
when gf clicked forever if <<key [up arrow v] pressed?> and <<(up) = (1)> and <(down 2) = (0)>>> Whatever script you use to jump. end if <(down 2) = (1)> change y by (-1) end when gf clicked forever if <(down 1) = (0)> change y by (1) end if <<key [left arrow v] pressed?> and <(left) = (1)>> change x by (-1) end if <<key [right arrow v] pressed?> and <(right) = (1)>> change x by (1) endThe comments on the script don't seem to be appearing, so here they are:
Last edited by ErnieParke (2012-08-05 13:22:38)
Offline