Hi. I have got an OS basic running in Scratch. I am adding a screensaver. I need to know how to work out how long the mouse has stayed still. Does anyone know how to do this?
Please use the embed Scratch blocks to tell me what to do. Thanks!
Offline
By the way, code is:
Stage:
Script 1:
[blocks]
<when green flag clicked>
<reset timer>
[/blocks]
Sprite2:
Script 1:
[blocks]
<when green flag clicked>
<forever>
<if><<<(<mouse x> <=> <x position>)> <and> <(<mouse y> <=> <y position>)>>>
<switch to costume[costume2]>
<else>
<switch to costume[costume1]>
<end>
<end>
[/blocks]
Sprite6:
Script 1:
[blocks]
<when green flag clicked>
<forever>
<set x to(<mouse x>)>
<set y to(<mouse y>)>
<end>
[/blocks]
Script 2:
There is a Script 2 but it is far too long.
Yes there are other sprites that don't yet have code.
No there is no Sprite1.
Offline
Um... maybe try this:
When Green Flag Clicked
forever
set [variable] to (0)
set [mouse x] to (0)
set [mouse y] to (0)
repeat until not (mouse x) = (mouse x) or not (mouse y) = (mouse y)
change [variable] by (1)
wait (1) secs
if (variable) > (30)
broadcast [screensaver]
It may not work, but it's what I thought of.
Last edited by Chrischb (2009-11-14 22:39:11)
Offline
Cool idea!
First of all... what does the timer have to do with this? I don't see anything about if the timer is over a certain amount.
I'm not sure how to say things by editing your scripts, so I'll say it differently.
•Have a sprite that follows the mouse. It can have ghost effect at 100 or have it hide.
•Have a forever loop that does this: First, it sets two variables (let's call them X and Y) to whatever the X and Y of the mouse sprite is. Next, it checks if the mouse sprite's X and Y equals the amount of the X and Y variables. If they're equal, that shows that the mouse hasn't moved. If they're not equal, it shows that the mouse has been moved. Make the timer reset if the mouse has been moved. Last, it checks if the timer is over a certain amount (let's say 15 seconds). If the timer's value is past 15, have the screensaver show.
Note that Scratch doesn't sense the equals for the timer; the timer changes too quickly and Scratch won't sense it quick enough. Use the greater sign instead of the equals sign; you won't have any problems.
Hope that helps! If there are other questions or problems, just ask.
Last edited by Jonathanpb (2009-11-14 22:43:07)
Offline
You posted before me Chrischb! Grrr!
Oh! You put that into one script! Stupid me! I'll edit that.
Offline
Jonathanpb wrote:
Cool idea!
First of all... what does the timer have to do with this? I don't see anything about if the timer is over a certain amount.
I'm not sure how to say things by editing your scripts, so I'll say it differently.
•Have a sprite that follows the mouse. It can have ghost effect at 100 or have it hide.
•Have a forever loop that does this: First, it sets two variables (let's call them X and Y) to whatever the X and Y of the mouse sprite is. Next, it checks if the mouse sprite's X and Y equals the amount of the X and Y variables. If they're equal, that shows that the mouse hasn't moved. If they're not equal, it shows that the mouse has been moved. Make the timer reset if the mouse has been moved. Last, it checks if the timer is over a certain amount (let's say 15 seconds). If the timer's value is past 15, have the screensaver show.
Note that Scratch doesn't sense the equals for the timer; the timer changes too quickly and Scratch won't sense it quick enough. Use the greater sign instead of the equals sign; you won't have any problems.
Hope that helps! If there are other questions or problems, just ask.![]()
Hi! The timer is to say, 'If the mouse is still for so-and-so seconds, initiate screensaver'.
I haven't yet coded this to work. Thanks!
EDIT: I, at first, used 'timer' as a replacement for 'time'. However, I realised it could be useful and that's where the idea for a screensaver from.
Last edited by nobugs (2010-01-01 18:29:07)
Offline
Oh. I didn't see that script, so I was confused.
Last edited by Jonathanpb (2009-11-14 23:02:15)
Offline
Thanks guys, you were a great help.
I'm going to keep on asking if I need any more help with problems.
And that is right now.
I know how to do the click thing, but how do you hide sprites?
I want to make a Start menu that appears when you click on the buttons and disappears when you click on a button in it or on an area around it.
Once I have finished this wait a few days/weeks and I will probably post it.
See you!
Last edited by nobugs (2009-11-14 23:31:24)
Offline
Chrischb wrote:
Um... maybe try this:
When Green Flag Clicked
forever
set [variable] to (0)
set [mouse x] to (0)
set [mouse y] to (0)
repeat until not (mouse x) = (mouse x) or not (mouse y) = (mouse y)
change [variable] by (1)
wait (1) secs
if (variable) > (30)
broadcast [screensaver]
It may not work, but it's what I thought of.![]()
i don't think this will work because the mouse x will always equal the mouse x, no matter what. same with mouse y. instead maybe do
repeat until not (mouse x) = (0) or not (mouse y) = (0)
if you're gonna do it like that
Offline
funkymonkey wrote:
Chrischb wrote:
Um... maybe try this:
When Green Flag Clicked
forever
set [variable] to (0)
set [mouse x] to (0)
set [mouse y] to (0)
repeat until not (mouse x) = (mouse x) or not (mouse y) = (mouse y)
change [variable] by (1)
wait (1) secs
if (variable) > (30)
broadcast [screensaver]
It may not work, but it's what I thought of.![]()
i don't think this will work because the mouse x will always equal the mouse x, no matter what. same with mouse y. instead maybe do
repeat until not (mouse x) = (0) or not (mouse y) = (0)
if you're gonna do it like that
You know what? That was exactly what I didn't get. As in, mousex=mousex and mousey=mousey. LOL. A quote within a quote.
Last edited by nobugs (2009-11-14 23:50:26)
Offline
i mean i know what he's talking about, and i think what he meant was to have variables called mousex and mousey, and forever set them to mouse x and mouse y. it seems like it would work, but then it really wouldnt. try Jonathanpb's idea
Offline
funkymonkey wrote:
i mean i know what he's talking about, and i think what he meant was to have variables called mousex and mousey, and forever set them to mouse x and mouse y. it seems like it would work, but then it really wouldnt. try Jonathanpb's idea
I did and only Jonathanpb's works. But thank him for trying anyway!
Last edited by nobugs (2009-11-15 00:24:40)
Offline
Sorry, but nobody seems to notice my other question. How do you hide sprites until they need to be used?
Offline
nobugs wrote:
Sorry, but nobody seems to notice my other question. How do you hide sprites until they need to be used?
[blocks]<when green flag clicked>
<forever>
<if><( <{ SpriteName needs to be used }> <=> 1 )>
<show>
<else>
<hide>
<end>
<end>[/blocks]
There.
Offline
ihaveamac wrote:
nobugs wrote:
Sorry, but nobody seems to notice my other question. How do you hide sprites until they need to be used?
[blocks]<when green flag clicked>
<forever>
<if><( <{ SpriteName needs to be used }> <=> 1 )>
<show>
<else>
<hide>
<end>
<end>[/blocks]
There.![]()
Thanks! I didn't notice show and hide.
Last edited by nobugs (2009-11-15 01:09:34)
Offline
Everybody who helped me has their username on the emulated OS's desktop.
If you would like to download it, search 'windows 7 emulator 1.0alpha' and it will pop up. Test it out in the browser. Make changes if you want, but please DO NOT PUBLISH THEM JUST YET! Wait till the full version comes out.
Last edited by nobugs (2009-11-15 01:20:46)
Offline
Sorry guys, one last thing before I publish. Can you upload by saving to a different PC and a file thing on the Scratch website? Tell me whether or not you can. I need it because the computer with Scratch installed is different to the one with the Internet connection. We have a wireless network but it is broken.
Offline
nobugs wrote:
Sorry guys, one last thing before I publish. Can you upload by saving to a different PC and a file thing on the Scratch website? Tell me whether or not you can. I need it because the computer with Scratch installed is different to the one with the Internet connection. We have a wireless network but it is broken.
You can send a project over to another computer and let is share from there... if that's what you're asking.
Offline
Chrischb wrote:
nobugs wrote:
Sorry guys, one last thing before I publish. Can you upload by saving to a different PC and a file thing on the Scratch website? Tell me whether or not you can. I need it because the computer with Scratch installed is different to the one with the Internet connection. We have a wireless network but it is broken.
You can send a project over to another computer and let is share from there... if that's what you're asking.
![]()
But the computer that'll be sharing it has to have Scratch (I think, but I'm quite sure).
Offline
Guys, thanks anyway. I'll tell you something funny. I was going to recreate SHIFT 1-4 (my favorite one, SHIFT2, is at http://armorgames.com/play/964/shift-2) in Scratch as games you can play in the basic OS. Well, I have collected every single medal, and here is what the guys wrote: 'Classic Character--After spending all this time collecting all the medals, haven't you learnt not to trust me yet? Don't you remember SHIFT 1? Sure, I could let you play as the classic character, but he's dead! Duh!? Please do not mention that you cannot unlock him in your reviews, as that would spoil the 'fun' for others. If you would like to secretly let me know you got here, include in your review: 'The CC is a lie' '.
Last edited by nobugs (2009-11-15 15:59:42)
Offline
Jonathanpb wrote:
Chrischb wrote:
nobugs wrote:
Sorry guys, one last thing before I publish. Can you upload by saving to a different PC and a file thing on the Scratch website? Tell me whether or not you can. I need it because the computer with Scratch installed is different to the one with the Internet connection. We have a wireless network but it is broken.
You can send a project over to another computer and let is share from there... if that's what you're asking.
![]()
But the computer that'll be sharing it has to have Scratch (I think, but I'm quite sure).
Do you mean 'I think, but I'm not quite sure'? Also, I meant can you upload it without Scratch?
Offline
Hi guys, I am making a script to detect whether or not a button was pressed on the keyboard. Do you know a bit that does this with 2 or 3 lines? As in psuedocode, 'Make sure you reset the timer when any key is pressed, don't care what it is'?
Offline
fg123 wrote:
if key a pressed or key b pressed
so on.![]()
I have tried doing this, but is there a way to do this without having to choose every single key?
Offline
Oops. Guys, it should be uploaded any minute now.
Offline