Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Solid Wall's
- pixlecode
- Scratcher
100+ posts
Solid Wall's
i was welcoming new scratchers, making everybody feel welcome and somebody asked me if i could help them with there script witch is “making solid walls” so i told them i would find out because i love that satisfaction you get when you help someone! Thank you ~pixlecode
Last edited by pixlecode (Aug. 17, 2014 19:27:25)
Money and fame is just an object and a rank but friends, and family is what matters most please don't say different because if you do you are not true to yourself Do a good deed everyday ~ here to help pixlecode
- master_tolkien
- Scratcher
100+ posts
Solid Wall's
For simple wall detection, like in pac-man, use something that turns the sprite in the opposite direction that it is facing, and then moves it 5 steps, or less depending on the size of the sprite (or maybe not, that's just what I assume, it's probably wrong ). Example:
if <touching [wall v] ?> thenThere are other more complicated ways to do the same thing that make it more perfect, but I'm not sure about those ways. I hope this helps
turn ccw (180) degrees
move (5) steps
end
SCRRRRRRAAAAAAYYYYYTTTTCCHHHHH…
Swift, computer architecture, hippos.
Repeat: Programming Language in Scratch | Jump
- Cyoce
- Scratcher
500+ posts
Solid Wall's
when green flag clicked
forever
if <key [right arrow v] pressed?> then
change x by (5)
if <touching [wall v] ?>
change x by (-5)
end
end
if <key [left arrow v] pressed?> then
change x by (-5)
if <touching [wall v] ?>
change x by (5)
end
end
- marioman20
- Scratcher
43 posts
Solid Wall's
when green flag clicked
forever
if <key [right arrow v] pressed?> then
point in direction (90 v)
if <touching [wall (insert wall sprite name here) v] ?> then
move (0) steps
else
move (5) steps
end
end
repeat for all keys
a
- pixlecode
- Scratcher
100+ posts
Solid Wall's
thank you..when green flag clicked
forever
if <key [right arrow v] pressed?> then
point in direction (90 v)
if <touching [wall (insert wall sprite name here) v] ?> then
move (0) steps
else
move (5) steps
end
end
repeat for all keys
Money and fame is just an object and a rank but friends, and family is what matters most please don't say different because if you do you are not true to yourself Do a good deed everyday ~ here to help pixlecode
- Cyoce
- Scratcher
500+ posts
Solid Wall's
That will not work. The problem is if you are right next to a wall, you will move 5. then you will be in the wall, and unable to move in any direction. Use the script I gave you. Repeat the process for up and down arrows. It will work. Trust me. Also, don't use the point in direction block with the move block like that. It gets weird. Use the change x by () and change y by () blocks.thank you..when green flag clicked
forever
if <key [right arrow v] pressed?> then
point in direction (90 v)
if <touching [wall (insert wall sprite name here) v] ?> then
move (0) steps
else
move (5) steps
end
end
repeat for all keys
when green flag clicked
forever
if <key [right arrow v] pressed?> then
change x by (5)
if <touching [wall v] ?>
change x by (-5)
end
end
if <key [left arrow v] pressed?> then
change x by (-5)
if <touching [wall v] ?>
change x by (5)
end
end
- pixlecode
- Scratcher
100+ posts
Solid Wall's
oh ok thanks so much!
That will not work. The problem is if you are right next to a wall, you will move 5. then you will be in the wall, and unable to move in any direction. Use the script I gave you. Repeat the process for up and down arrows. It will work. Trust me. Also, don't use the point in direction block with the move block like that. It gets weird. Use the change x by () and change y by () blocks.thank you..when green flag clicked
forever
if <key [right arrow v] pressed?> then
point in direction (90 v)
if <touching [wall (insert wall sprite name here) v] ?> then
move (0) steps
else
move (5) steps
end
end
repeat for all keyswhen green flag clicked
forever
if <key [right arrow v] pressed?> then
change x by (5)
if <touching [wall v] ?>
change x by (-5)
end
end
if <key [left arrow v] pressed?> then
change x by (-5)
if <touching [wall v] ?>
change x by (5)
end
end
Money and fame is just an object and a rank but friends, and family is what matters most please don't say different because if you do you are not true to yourself Do a good deed everyday ~ here to help pixlecode
- Cyoce
- Scratcher
500+ posts
Solid Wall's
NP. Believe me, I tried using Marioman's code in one of my games and it got me stuck. Good idea, though.
- wkelly42
- Scratcher
100+ posts
Solid Wall's
My Retro Arcade:
COMPLETED: Frogger, Missile Command, Computer Space.
IN DEVELOPMENT: Barnstorming, Time Pilot, Defender, River Raid, Karateka
- NoChutney
- Scratcher
48 posts
Solid Wall's
If you're happy to build your wall with sprites (preferably clones) then the collision detection in my platformer could be used. I prefer this to colour collisions as it removes restrictions on graphic design.
This is definitely work-in-progress. I haven't finished adding comments to the script, but the collision detection is there.
Feel free to take a look and see what you can make of it. http://scratch.mit.edu/projects/25711091/
This is definitely work-in-progress. I haven't finished adding comments to the script, but the collision detection is there.
Feel free to take a look and see what you can make of it. http://scratch.mit.edu/projects/25711091/
- Cyoce
- Scratcher
500+ posts
Solid Wall's
Check out If you're happy to build your wall with sprites (preferably clones) then the collision detection in my platformer could be used. I prefer this to colour collisions as it removes restrictions on graphic design. my platformer engine.
This is definitely work-in-progress. I haven't finished adding comments to the script, but the collision detection is there.
Feel free to take a look and see what you can make of it. http://scratch.mit.edu/projects/25711091/
Last edited by Cyoce (Aug. 22, 2014 00:42:20)
- Cyoce
- Scratcher
500+ posts
Solid Wall's
Look at my solid wall engine.
Last edited by Cyoce (Aug. 21, 2014 23:36:20)
- pixlecode
- Scratcher
100+ posts
Solid Wall's
cool! If you're happy to build your wall with sprites (preferably clones) then the collision detection in my platformer could be used. I prefer this to colour collisions as it removes restrictions on graphic design.
This is definitely work-in-progress. I haven't finished adding comments to the script, but the collision detection is there.
Feel free to take a look and see what you can make of it. http://scratch.mit.edu/projects/25711091/
Money and fame is just an object and a rank but friends, and family is what matters most please don't say different because if you do you are not true to yourself Do a good deed everyday ~ here to help pixlecode
- NoChutney
- Scratcher
48 posts
Solid Wall's
It's good, but there seems to be a bit issue - if you move the wall into a midair position, the player can hit the site of the wall and won't fall. That's the problem that I was trying to overcome, by making the block detect where the player is touching.Check out If you're happy to build your wall with sprites (preferably clones) then the collision detection in my platformer could be used. I prefer this to colour collisions as it removes restrictions on graphic design. my platformer engine.
This is definitely work-in-progress. I haven't finished adding comments to the script, but the collision detection is there.
Feel free to take a look and see what you can make of it. http://scratch.mit.edu/projects/25711091/
- Cyoce
- Scratcher
500+ posts
Solid Wall's
I'll work on that.It's good, but there seems to be a bit issue - if you move the wall into a midair position, the player can hit the site of the wall and won't fall. That's the problem that I was trying to overcome, by making the block detect where the player is touching.Check out If you're happy to build your wall with sprites (preferably clones) then the collision detection in my platformer could be used. I prefer this to colour collisions as it removes restrictions on graphic design. my platformer engine.
This is definitely work-in-progress. I haven't finished adding comments to the script, but the collision detection is there.
Feel free to take a look and see what you can make of it. http://scratch.mit.edu/projects/25711091/
- Discussion Forums
- » Help with Scripts
- » Solid Wall's