Need help use up left right down arrow key to move homer. when homer is on the pink jelly doughnut he is suppose to go to next costume and he does but after that he cannot more for some reason. Also when he is on the green doughnut he is supposed to go to costume where is shows homer dead because he ate a vegi doughnut. I need your guys help.
YoSup
Link to my game:
http://scratch.mit.edu/projects/YoSup/60488
Offline
Hey YoSup, I noticed that you do not have a "forever if" code block for your costume changes. Try putting your costume change in a forever if block inside the "Green Flag pressed" block. This way, your program will keep checking to see if the two sprites are hitting each other.
Chris @ Scratch
Offline
Hi Yosup,
Thanks for posting in the forums.
The second script in your homer sprite says this:
[blocks]
<when green flag clicked>
forever if (score = 4)
<hide>
<go to[5][-37]>
<show>
[/blocks]
As soon as you eat the pink donut your score goes to 4 and this forever loop gets activated over and over again until your score isn't 4 anymore. What this means is that homer keeps on getting sent to x:5 y:-37. So when you push the arrows homer moves a little bit, but then he gets sent right back to x:5 y:-37. That's why if you hold down the right arrow for example, homer will vibrate back and forth:
[blocks]
<move( 10 )steps>
<go to[5][-37]>
[/blocks]
over and over again. There are lots of ways to fix this. One way is just to get rid of this whole script (the second script in homer). But the key to fixing it is understanding what is going wrong, so please ask questions if you didn't get my explanation.
Good luck!
Offline
To have objects move on their own you can use glide. Just click after the x and after the y and type in new numbers like x:100 y:100. If you want the sprites themselves to be dragable using the mouse, then look in the costume library under "things" and get the "draggable" sprite (purple and red square). This sprite is dragable in presentation mode and on the web.
A new version of scratch is coming out any day now that will have a new feature that lets you "lock" or "unlock" the dragability of sprites...
Offline
Changing variables is easy
[blocks]
<change{ v }by( -5
[/blocks]
Offline
YoSup wrote:
Thanx Jay. I have another question. When I write this scrpit under my sprite 8 scripts why doesn't it switch my backround:
<when green flag clicked>
<forever if><touching[ sprite 8]>
<switch to costume[ homerdead]>
<hide>
i think its because you told it to hide.
Offline
<when green flag clicked>
<if> you need to put if instead of FOREVER if
<color[yellow or something ]is over[green]
<switch to costume[homer dead] put all this is stage scripts
Offline