Luxturna said he needed some help for his game, so I'm going to give her a guide.
So, he needed help with sensing on his platformer:
Sensing is difficult, especially since Scratch does not support atomocity. There are many ways to do it efficiently, but the one thing that will glitch so much is: color sensors. The main problem is you go through walls because: the colors on the costume are too thin and it gets through the wall or the whole thing goes into the wall and it get's stuck. So basically, color sensing is off the list.
However, there are still many other methods, such as the reliable (but tacky and annoying) wall colors. Technically this is still color sensing but more efficient. You also have the most efficient method on Scratch, various versions have been made by me, eRKSToCK, RHY3756547, Rahi-Tak, and Kileymeister. This is what it's all about. Basically when it hits the level sprite, or the basic layout of the sprite, it checks the terrain. It can be: a horizontal wall, a vertical wall, or a 45° slope. So first we will check for a slope (assuming you are using velocities):
change x by (xvel) if <touching [level v]?> change y by (([abs v] of (xvel)) + (1)) endWhat this does is it checks for collision, and if it collides with a wall, it reacts to it as if it were a slope. This works because it take the absolute value (abs, always positive) of the x velocity and changes the y position by it, but plus one more to be safe. This way it travels up a 45° slope.
change x by (xvel) if <touching [level v]?> change y by (([abs v] of (xvel)) + (1)) if <touching [level v]?> change x by ((xvel) * (-1)) change [xvel v] by ((xvel) / (-2)) endNow we have checked for wall collisions and avoided getting stuck. But we still need to enable y collisions. Se first we'll do jumping, add this after the x collision script, but keep it in the same loop:
if <key [up arrow v] pressed?> change y by (-3) change y by (3) endNow your probably asking if I'm drunk. I'm just getting you comfortable with the style. Basically what it's going to do is go down 3 pixels, check for collisions, and move back up. If it hits the floor, that means it can jump, you get it?
if <key [up arrow v] pressed?> change y by (-3) if <touching [level v]?> set [yvel v] to (10) end change y by (3) endNow jumping still won't work, because nothing is commanding it to. Now we'll get to collisions and coming back down.
if <key [up arrow v] pressed?> change y by (-3) if <touching [level v]?> set [yvel v] to (10) end change y by (3) end change y by (-3) if <not <touching [level v]?>> change [yvel v] by (-1) end change y by (3)Now it goes back down, but it still needs to move.
if <key [up arrow v] pressed?> change y by (-3) if <touching [level v]?> set [yvel v] to (10) end change y by (3) end change y by (-3) if <not <touching [level v]?>> change [yvel v] by (-1) end change y by (3) change y by (yvel)Okay, now collisions.
if <key [up arrow v] pressed?> change y by (-3) if <touching [level v]?> set [yvel v] to (10) end change y by (3) end change y by (-3) if <not <touching [level v]?>> change [yvel v] by (-1) end change y by (3) change y by (yvel) if <touching [level v]?> change y by ((yvel) * (-1)) change [yvel v] by ((yvel) / (-2)) endThat should work, just make sure you've also implemented a good x moving system. I don't wanna give it all to ya'.
Last edited by chanmanpartyman (2012-07-17 17:52:31)
Offline
Luxturna wrote:
Thanks! And thanks for not giving me everything. Now I know not to use color sensing. how did you do the blocks? and I'm a girl, btw
Oh, sorry. You do the blocks with the [scratchblocks] tag.
Last edited by chanmanpartyman (2012-07-16 16:00:26)
Offline
color sensing does work, as you can switch to a "sensor" costume at the top of the loop, switch back to the regular costume at the bottom and it works out fine. I learned it from thesuperguidegames' Paper Mario a while back.
Offline
thebriculator wrote:
color sensing does work, as you can switch to a "sensor" costume at the top of the loop, switch back to the regular costume at the bottom and it works out fine. I learned it from thesuperguidegames' Paper Mario a while back.
Which is color sensing, that's what I meant, and what I used in my final Egg game, the one that was the scroller. If you look at it you can see how efficient that was. Now compare it to 2030, which is the project I developed this method on. The collision barely have any glitches, and the glitches is has only effects it visually, it still runs normal.
Offline
Luxturna wrote:
It doesn't work. I'm falling through the ground. Help. I re-uploaded with the changes.
Try redoing the scripts. I also noticed just by playing it there was no decay on your velocity. Try and put the line:
set [xvel v] to ((xvel) * (0.87))
Offline
chanmanpartyman wrote:
thebriculator wrote:
color sensing does work, as you can switch to a "sensor" costume at the top of the loop, switch back to the regular costume at the bottom and it works out fine. I learned it from thesuperguidegames' Paper Mario a while back.
Which is color sensing, that's what I meant, and what I used in my final Egg game, the one that was the scroller. If you look at it you can see how efficient that was. Now compare it to 2030, which is the project I developed this method on. The collision barely have any glitches, and the glitches is has only effects it visually, it still runs normal.
true, your 2030 and 2031 do have great physics.
as a side note, are you ever going to finish 2031?
Last edited by thebriculator (2012-07-17 22:06:59)
Offline