Bouncing off of objects can get pretty complicated. I've got a simple pinball game you can look at that maybe would give you a good start...
http://scratch.mit.edu/projects/Paddle2SeeFixIt/681997
Offline
Making a wall can be as simple as putting in the script <if on edge, bounce>
but if you want to make a sprite that acts as a wall, or a color on the background that acts as a wall you have to make a more complicated script.. an example i think would be if you want a ball to bounce off of a paddle, you program into the script so that when it touches the paddle, it moves into the opposite direction, or bounces off of the paddle like light bounces off of a mirror
Offline
NewToThis wrote:
I really don't have a clue how to draw one and for my next project I want to make a basketball game so I want to know how to make a wall, anyone help me.
i say you could make a video to make more people anser that Q.
Offline
an easy way of making walls for your sprite to detect them is to make sensors.
you can make coloured sensors or separate sensors.
-------------------------------------------------------------------------------------------------------------------------
to make coloured sensors, draw a new sprite. it should look like a square. on each side of the square draw lines of different colours
then you should make the following scrips
blocks<if><< <not> ><color[ here the colour of one side of the square ]is over[ colour of the wall.<change x by( whatever you want your sprite to move if not touching the colour of the wall/blocks)
repeat this with all of the colours of your square.
this scrips should make your square move only to the side you want if not touching the colour of the wall
now, tell the sprite you want to see moving to always go to the square sensor.
here an example of the colour sensing sprite
http://scratch.mit.edu/projects/ilikewaffles/739332
the sensor is hiden by seting its ghost effect to 100 so you cant see it while playing, but the sprite of the man moving always goes to the sensor.
-------------------------------------------------------------------------------------------------------------------------
another way of making walls, similarly to the colour sensor, is the single sensor,
to make this type of sensor, you will need to draw 4 sprites, each one will be the sensor of one side of the sprite you want to see moving and acting with walls.
then, make the following scriptson each of the sensors:
blocks<if><< <not> >><touching[ here you put the walls sprite<change x by( whatever you want/blocks
for an exaple of this method, download this project
http://scratch.mit.edu/projects/ilikewaffles/711316
the sensors are again hiden by ghost effect. in this example, there are x and y velocities so if you dont understand this, it is not nesesary to use, i mean you can use motion blocks instead. stick to the colour sensig method, its simpler and still works.
-------------------------------------------------------------------------------------------------------------------------
any doubts please let me know, i can help you improve your projects.
hope this was useful to you.
Last edited by ilikewaffles (2010-01-07 12:55:38)
Offline
just put <if><touching[ sprite whatever <stop script> then itll stop u when touching that sprite best working one yet
Offline
Thanks to all of you this information is very useful.
Offline
new script this one woprks best
<if><touching[ wall<change y by( 0
Offline
Inside the forever mouth, put 'if touching...put the name of the block(spirit) you want to be the wall, then put set y velocity to 1, then put under it (but still inside the forever) change y velocity by -1, then underneath it (but, of course, inside the forever) put change y by y velocity.
Offline
Try:
When green flag clicked
Forever
if
touching [left wall colour]
change y by -[how far you want the sprite to bounce back]
do the same for the right wall, but remove the minus sign.
Offline
Look at this: http://scratch.mit.edu/projects/MoreGamesNow/848288 It may not be exactly what you're looking for for a basketball game, but it may help. Just download it and look at the script
Offline
how do you create a solid wall when a sprite runs into it but also how do you make a sprite stand on top of the ground and not sink into it
Offline
i'm wondering that too!
Offline
Looks like everyone else stole my post
Good luck with your Basketball project anyways and post a topic on the 'Show And Tell' Forums so we can all see it!
Offline