Hi,
This is the code I'm trying to get to work:
Sprite: multiplier Costumes (2): purple_ (34x18) inverted_Purple (34x18) Sounds (0): Stacks (7): when I receive "multiplier_Clicked" forever forever if (mouse down?) if (touching s[mouse-pointer]?) set "Score" to ((Score) * 2) glide 1 secs to x: 0 y: 0 if ((size) < "200") forever change size by 5 wait 0.01 secs if ((size) = "200") hide set size to 100% stop script end when I receive "LVL2_Start" wait 1 secs go to x: -119 y: 185 show if ((mouse down?) and (touching s[mouse-pointer]?)) else broadcast "multiplier_Clicked" else glide 1 secs to x: 0 y: 0 glide 1 secs to x: -242 y: -50 hide end when I receive "lvl3_Start" go to x: 0 y: 0 end when green flag clicked set size to 100% hide end when green flag clicked forever next costume wait 0.01 secs end show hide --------It's for a multiplier that flies across the screen in an FPS(First Person Shooter).
Offline
Edit: The Show/ Hide on the bottom is not a part of the code... i use it for short hand while programing....
And i believe i forgot to tell you what i want it to do when clicked! (oops)
What i want it to do is stay on the course i tell it to until clicked, then, if clicked i want it to go to x:0 y:0 and get to 200% in size and then disappear.
I hope that clarified things...
regards,
CAA14
Offline
I'm sorry I don't understand what your talking about I never did that kinda stuff
Offline
Hi,
Thanks for responding,
No problem, it is complicated believe me!
regards,
CAA14
Offline
Okay, maybe i can clear this up by instead of posting code(Which I'm still new at:)), I'll type a certain goal.
The Goal:
What i want it to have this sprite called "multiplier" appear once it receives a message that a certain level(for example, level 1) and start going to certain x/y coordinates.
But, IF it is clicked, i want it to stop, play a sound, and go to 0,0 and get 200% bigger, then disappear.(Of course, I want it to multiply "score" by 2).
I have both of these things in script, but it skips the second half.
I know it's probably a simple bug, as all programmers make bugs, but i really need to know before i release the project.
regards,
CAA14
Offline
Edit to original post:
The block of code isn't displaying right, Please disregard it.
regards,
CAA14
Offline
When do you need help by?
Edit: Just to say, you can always report a post to be edited if sommething needs to be changed.
Anyway, hello CAA14 and welcome to Scratch! I wish you momorable, great times here!
Last edited by ErnieParke (2013-01-17 21:36:05)
Offline
this is why new scratchers should be able to edit their posts
Offline
Try using these scripts, with any changes to the moving system you want.
when I receive [Level 2 Start v] wait (pick random [4] to [10]) secs set [moving? v] to [yes] go to x: [0] y: [0] show set [number v] to (pick random [0] to [1]) if <(number) = [1]> set [x direction v] to [1] else set [x direction v] to [-1] end set [number v] to (pick random [0] to [1]) if <(number) = [1]> set [y direction v] to [1] else set [y direction v] to [-1] end repeat [25] if <not <(clicked?) = [yes]>> change x by ((x direction) * [5]) change y by ((y direction) * [5]) else stop script end end set [moving? v] to [no] hide
when I receive [Level 2 Start v] set size to [100] % set [ghost v] effect to [0] set [clicked v] to [no] wait until <(moving?) = [yes]> repeat until <(moving?) = [no]> if <<touching [mouse pointer v]?> and <mouse down?>> set [clicked v] to [yes] set [multiplier v] to [2] glide [1] secs to x: [0] y: [0] repeat [50] change [ghost v] effect by [2] change size by [2] end endThis should fix your problems.
Last edited by sonicfan12p (2013-01-18 11:28:30)
Offline
Hi,
Thanks again sonicfan.
I'll give it a try and report back here.
Thanks you, ErnieParke for another warm welcome.
I would like to release my project this week, and i think i can make that with all this help I'm getting.
Regards,
CAA14
Offline
Question for sonicfan:
Umm, you can't set a variable to "yes".
What did you mean by that?
regards,
CAA14
Offline
Another Question:
Wasn't there a less complicated solution?
To be honest, being totally new to scratch, I am confused by the code.
Where can i put the part about multiplying the score by 2?
Thanks again,
Regards,
CAA14
Offline
I slightly altered the script you gave me to try to accommodate the following things:
1. I tried to make it so that The multiplier would not show up if a level had not started.
*I THINK WORKS*
2. To make it multiply "score" by 2. *WORKS*
3. To repeat a random amount of times. *DON'T KNOW IF WORKS, ALL WAYS 1*
4. To reset the size to 100% after one appearance.
The problem:
Sometimes, the multiplier shows up in the middle and does not move.
Here's the script:
[scratch]
when I receive [lvl1_Start v]
set size to (100)%
set "ghost" effect to (0)
set "clicked?" to (no)
wait until ((multiplier_Moving?) = (yes))
repeat until ((multiplier_Moving?) = (no))
if ((touching s[mouse-pointer]?) and (mouse down?))
set "Score" to ((Score) * (2))
set "clicked?" to (yes)
set "multiplier" to (2)
glide 1 secs to x: 0 y: 0
repeat 50
change "ghost" effect by (2)
change size by (2)
set "multiplier_Done" to (yes)
wait until ((size) = (100))
set "multiplier_Done" to (no)
end
when I receive [lvl1_Start v]
set "multiplier_Done" to (no)
set "times_To_Repeat" to (pick random (1) to (3))
repeat (times_To_Repeat)
wait (pick random 4 to 10) secs
set "multiplier_Moving?" to (yes)
go to x: 0 y: 0
show
set "number" to (pick random 0 to 1)
if ((number) = (1)) else
set "x_Direction" to (1)
else
set "x_Direction" to (-1)
set "number" to (pick random 0 to 1)
if ((number) = (1)) else
set "y_Direction" to (1)
else
set "y_Direction" to (-1)
repeat 25
if (not ((clicked?) = (yes))) else
change x by ((x_Direction) * (5))
change y by ((y_Direction) * (5))
else
stop script
set "multiplier_Moving?" to (no)
hide
end
[/scratch]
Please compare to your previous script to see what changed.
Any suggestions?
Regards,
CAA14
Offline
Edit:
The script:
when I receive [lvl1_Start v] set size to (100)% set "ghost" effect to (0) set "clicked?" to (no) wait until ((multiplier_Moving?) = (yes)) repeat until ((multiplier_Moving?) = (no)) if ((touching s[mouse-pointer]?) and (mouse down?)) set "Score" to ((Score) * (2)) set "clicked?" to (yes) set "multiplier" to (2) glide 1 secs to x: 0 y: 0 repeat 50 change "ghost" effect by (2) change size by (2) set "multiplier_Done" to (yes) wait until ((size) = (100)) set "multiplier_Done" to (no) end when I receive [lvl1_Start v] set "multiplier_Done" to (no) set "times_To_Repeat" to (pick random (1) to (3)) repeat (times_To_Repeat) wait (pick random 4 to 10) secs set "multiplier_Moving?" to (yes) go to x: 0 y: 0 show set "number" to (pick random 0 to 1) if ((number) = (1)) else set "x_Direction" to (1) else set "x_Direction" to (-1) set "number" to (pick random 0 to 1) if ((number) = (1)) else set "y_Direction" to (1) else set "y_Direction" to (-1) repeat 25 if (not ((clicked?) = (yes))) else change x by ((x_Direction) * (5)) change y by ((y_Direction) * (5)) else stop script set "multiplier_Moving?" to (no) hide end
Offline
I slightly altered the script you gave me to try to accommodate the following things: 1. I tried to make it so that The multiplier would not show up if a level had not started. *I THINK WORKS* 2. To make it multiply "score" by 2. *WORKS* 3. To repeat a random amount of times. *DON'T KNOW IF WORKS, ALL WAYS 1* 4. To reset the size to 100% after one appearance. The problem: Sometimes, the multiplier shows up in the middle and does not move. Here's the script: [scratchblocks] when I receive [lvl1_Start v] set size to (100)% set [ghost v] effect to (0) set [clicked? v] to [no] wait until <(multiplier_Moving?) = [yes]> repeat until <(multiplier_Moving?) = [no]> if <<touching [mouse-pointer v]?> and <mouse down?>> set [Score v] to ((Score) * [2]) set [clicked? v] to [yes] set [multiplier v] to [2] glide [1] secs to x: [0] y: [0] repeat [50] change [ghost v] effect by [2] change size by [2] end set [multiplier_Done v] to [yes] wait until <(size) = [100]> set [multiplier_Done v] to [no] end [/scratchblocks] [scratchblocks] when I receive [lvl1_Start v] set [multiplier_Done v] to [no] set [times_To_Repeat v] to (pick random [1] to [3]) repeat (times_To_Repeat) wait (pick random [1] to [7]) secs set [multiplier_Moving? v] to [yes] go to x: [0] y: [0] show set [number v] to (pick random [0] to [1]) // this number variable controls direction. if <(number) = [1]> set [x_Direction v] to [1] else set [x_Direction v] to [-1] end set [number v] to (pick random [0] to [1]) if <(number) = [1]> set [y_Direction v] to [1] else set [y_Direction v] to [-1] end repeat [25] if <not <(clicked?) = [yes]>> change x by ((x_Direction) * (5))// this changes x by 5, or -5, depending on the number variable change y by ((y_Direction) * (5))//same concept as before, except with y else stop script//this stops it from moving to random places, so it can glide to origin if clicked end end set [multiplier_Moving? v] to [no] hide [/scratchblocks] Please compare to your previous script to see what changed. Any suggestions? Regards, CAA14
How I have it set up here, it will make your sprite go in a random direction. I didn't see any problems when I looked at it first, you said it works now right? Also, I had to use the code box so you could read the comments, sorry about that.
Last edited by sonicfan12p (2013-01-18 15:29:48)
Offline
It is with these alterations:
1. The repeat (50) block only has the two purple blocks in it; the set multiplier done to yes block, wait until size = 100 block, and the set multiplier to no block are only encapsulated in the repeat until moving = no loop and an extra repeat (times_to_repeat) block i added.
2. Also, i changed the number of seconds that it randomly picks(1 to 7 now.)
hope that's clear,
CAA14
P.S. Sorry about my block scripting skills....
Offline
I think its working now, I just tested it....
I still believe there's an easier way, like making the click thing happen if clicked and then setting a second block up that gives it several options for moving...
BTW, how does the moving thing work? it seems to move in a randomly selected line each time, i guess it has something to do with those y and x position variables....
Thanks so much for your help, brother,
CAA14
Offline
CAA14 wrote:
I think its working now, I just tested it....
I still believe there's an easier way, like making the click thing happen if clicked and then setting a second block up that gives it several options for moving...
BTW, how does the moving thing work? it seems to move in a randomly selected line each time, i guess it has something to do with those y and x position variables....
Thanks so much for your help, brother,
CAA14
Alright, I'll edit it with some comment to help, and change what you said was changed.
Edit: Done.
Last edited by sonicfan12p (2013-01-18 15:30:17)
Offline
Hi,
Thanks alot sonicfan,
regards,
CAA14
P.S. Just wondering, what is the variable, "multiplier" doing?
My score is going crazy, it will add the correct amount of points if the cross-hair hits a certain color on the target the first time, but then add insane amounts of points to "score" after that.
To bad I'm a new scratcher... otherwise i'd send you a picture of my score scripts aswell...
Offline
Ok, i just saw your code box you sent earlier(for some reason it did not show up before, weird). I sort of understand, and I want to thank you again for your time and patients with this newbie.
I think the multiplier is working well, but the score of my project(as posted above) is going crazy.... i cant find a bug.
I think it will just take me time and experience to understand how that script got those random directions...
CAA14
Offline
Well, I meant it to be what multiplies your score, as in the other targets giving you whatever score they give you, times the multiplier. Just a thought, but if you already had that part worked out it's uneccessary. You could upload your project as a beta and I could look at it if it gets too out of control.
Offline
Hi,
What's a "beta"
If its what i think it is, it's an unfinished program.
Regards,
CAA14
Offline
CAA14 wrote:
Hi,
What's a "beta"
If its what i think it is, it's an unfinished program.
Regards,
CAA14
Yes, it's one of two test stages, alpha, and beta. Scratch 2.0 is currently in alpha stage, on the 28th it will go to beta stage, if that helps. To upload something as a beta, just upload it with beta in the name. Normally only people who are asked to look at them look at them, so if you want to keep it hidden until release, this won't affect that.
Offline
Ok, Cool.
My project is in beta stage I guess.
I will probably do that later... I want to look at it some more before I upload it... Just in case I can save you that work!
Regards,
CAA14
Offline
CAA14 wrote:
Question for sonicfan:
Umm, you can't set a variable to "yes".
What did you mean by that?
regards,
CAA14
You indeed can set a variable to "yes" though it doesn't have any meaning until you add something like "if variable = yes do this"
Offline