Hello, I'm trying to program a game where you build a tower, making it taller and taller while getting money. I wanted to make the tower 3 Dimensional and rotate, giving a cool effect as you played the game, but I've encountered a problem:
When the script clears pen marks, it takes about a second for the tower to rebuild itself, and while that happens, it looks quite glitchy and slow.
I used this script:
forever repeat (floors) stamp change y by (1) stamp change y by (1) stamp change y by (1) stamp change y by (1) etc... end clearI understand that the repeating block can make it lag, but since there's a variable number of floors, it's impossible (I think) to make it without using the repeat script.
Last edited by AgentRoop (2012-07-17 21:59:53)
Offline
You'd have to hard code it for the maximum number of floors and have it only stamp the number it needs based off if blocks around each floor section...also, put the clear at the top of the script, not at the bottom.
Offline
Or, you could design the project to run only in turbo mode, put in a framerate lock (so it runs at a constant speed), and use as many repeat blocks as you want. Check out some of the turbo projects on my test account (most of them are for turbo mode). http://scratch.mit.edu/users/ubrecma
Offline
You would need to do something like this:
Start with this:
when gf clicked forever set [floorcount v] to [0] endNow, add this to the end of the forever loop. Repeat for maximum amount of floors.
if <not <(floorcount) = (floors)>> stamp change y by (1) stamp change y by (1) stamp change y by (1) stamp change y by (1) etc... change [floorcount v] by (1) endNow, let's say your max would be ten. The script would look like this:
when gf clicked forever set [floorcount v] to [0] if <not <(floorcount) = (floors)>> stamp change y by (1) stamp change y by (1) stamp change y by (1) stamp change y by (1) etc... change [floorcount v] by (1) end if <not <(floorcount) = (floors)>> stamp change y by (1) stamp change y by (1) stamp change y by (1) stamp change y by (1) etc... change [floorcount v] by (1) end if <not <(floorcount) = (floors)>> stamp change y by (1) stamp change y by (1) stamp change y by (1) stamp change y by (1) etc... change [floorcount v] by (1) end if <not <(floorcount) = (floors)>> stamp change y by (1) stamp change y by (1) stamp change y by (1) stamp change y by (1) etc... change [floorcount v] by (1) end if <not <(floorcount) = (floors)>> stamp change y by (1) stamp change y by (1) stamp change y by (1) stamp change y by (1) etc... change [floorcount v] by (1) end if <not <(floorcount) = (floors)>> stamp change y by (1) stamp change y by (1) stamp change y by (1) stamp change y by (1) etc... change [floorcount v] by (1) end if <not <(floorcount) = (floors)>> stamp change y by (1) stamp change y by (1) stamp change y by (1) stamp change y by (1) etc... change [floorcount v] by (1) end if <not <(floorcount) = (floors)>> stamp change y by (1) stamp change y by (1) stamp change y by (1) stamp change y by (1) etc... change [floorcount v] by (1) end if <not <(floorcount) = (floors)>> stamp change y by (1) stamp change y by (1) stamp change y by (1) stamp change y by (1) etc... change [floorcount v] by (1) end if <not <(floorcount) = (floors)>> stamp change y by (1) stamp change y by (1) stamp change y by (1) stamp change y by (1) etc... change [floorcount v] by (1) end end
Offline
AtomicBawm3 wrote:
You'd have to hard code it for the maximum number of floors and have it only stamp the number it needs based off if blocks around each floor section...also, put the clear at the top of the script, not at the bottom.
Thanks for the advice, I'll try that out.
Offline
amcerbu wrote:
Or, you could design the project to run only in turbo mode, put in a framerate lock (so it runs at a constant speed), and use as many repeat blocks as you want. Check out some of the turbo projects on my test account (most of them are for turbo mode). http://scratch.mit.edu/users/ubrecma
I was thinking that I could do that, but I wasn't sure. I'll check out your projects that work in turbo mode and see if I can do that with my own project. Thank you!
Offline
SciTecCf wrote:
You would need to do something like this:
Start with this:when gf clicked forever set [floorcount v] to [0] endNow, add this to the end of the forever loop. Repeat for maximum amount of floors.if <not <(floorcount) = (floors)>> stamp change y by (1) stamp change y by (1) stamp change y by (1) stamp change y by (1) etc... change [floorcount v] by (1) end
Thank you, this is also a great idea! I'll try all three and see which one is most efficient and works the best.
Thanks again, everyone!
Offline
AgentRoop wrote:
SciTecCf wrote:
You would need to do something like this:
Start with this:when gf clicked forever set [floorcount v] to [0] endNow, add this to the end of the forever loop. Repeat for maximum amount of floors.if <not <(floorcount) = (floors)>> stamp change y by (1) stamp change y by (1) stamp change y by (1) stamp change y by (1) etc... change [floorcount v] by (1) endThank you, this is also a great idea! I'll try all three and see which one is most efficient and works the best.
Thanks again, everyone!
Mine and AB3's are the same.
Offline
CLEAR needs to be FIRST not LAST
forever clear//FIRST repeat<floor>
Offline