Hi All,
Firstly - Scratch is amazing - what a great idea!
I have just started looking at Scratch and I am using it to teach my 6 year old son some of the things I learnt as a kid (albeit I am trying to re-learn myself as I go - it has been a while...).
Anyway, I thought we would have a go at creating a shark fishing game (after seeing the screenshots of a similar scratch game on the internet), and we managed to get something working quite nicely on our apple mac, however when we "share" it on the Scratch website it does not run correctly and I can not work out why.
The problem is, that we have a forever loop around the code for each of our sprites, but the forever loop only works with one of the sprites (the shark) and not with the 3 fish (which should reappear on the right of the screen once they have reached the left hand side - they don't, they just stop on the left hand side of the screen and do not loop).
Can anyone let me know what is happening and why it doesn't work?
http://scratch.mit.edu/projects/TJandRB/2616865
Thanks
RB
Offline
For the fish, you make them forever go to their place and then do the stuff, but then when it loops, it goes back to the same place. you set you variables for the first time outside the loop and do the rest of the stuff with the detection in the loop.
Offline
Thanks Aux2,
Just to clarify my situation, the code works correctly when I run it within the Scratch programme, but does not work when it is "Shared" (compiled) on the Scratch website.
I suppose my question is, why should the code work in Scratch but not once the same code is "shared" on the website?
Offline
TJandRB wrote:
Thanks Aux2,
Just to clarify my situation, the code works correctly when I run it within the Scratch programme, but does not work when it is "Shared" (compiled) on the Scratch website.
I suppose my question is, why should the code work in Scratch but not once the same code is "shared" on the website?
Your problem is that you used
<(x position) = (-241)>That is not possible online as the max is -240 and 240. Try using
<(x position) > (239)>instead.
Offline
SciTecCf,
That sounds like it could be the problem. Nice one - I shall try it tonight when I get home.
I have to get this working so that he can use it for "Show and Tell" at school on Friday :-).
I will report back.
RB
Offline
Yeah, the only way it would be exactly = 241 is if the sprite was 2 pixels big. If SciTecCf's script didn't work, keep in mind that squeak and flash/java may process things differently. You usually have to fiddle around a bit to make it work.
Offline
berberberber wrote:
Yeah, the only way it would be exactly = 241 is if the sprite was 2 pixels big. If SciTecCf's script didn't work, keep in mind that squeak and flash/java may process things differently. You usually have to fiddle around a bit to make it work.
I only just saw this after trying the previous suggestion and then realising that I should be using X<-251 rather than X=251. I changed this line and it all worked fine.
Thanks all - Show and Tell is back on!
RB
Offline
SciTecCf wrote:
TJandRB wrote:
Thanks Aux2,
Just to clarify my situation, the code works correctly when I run it within the Scratch programme, but does not work when it is "Shared" (compiled) on the Scratch website.
I suppose my question is, why should the code work in Scratch but not once the same code is "shared" on the website?Your problem is that you used
<(x position) = (-241)>That is not possible online as the max is -240 and 240. Try using<(x position) > (239)>instead.
actually that isn't a problem if you do it. even if you told it to go to x=-99999 it would put it at -240
Offline
radicalace wrote:
actually that isn't a problem if you do it. even if you told it to go to x=-99999 it would put it at -240
Well, if you have a costume that's 480x360 pixels, you can tell it to go to positions pretty far off the screen (I got it to go to x = 462). In fact, the position limit has to do with the size of the costume. Scratch will allow a sprite to go all most all the way out of the viewing window.
Offline