This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2012-07-17 21:59:22

AgentRoop
Scratcher
Registered: 2012-02-11
Posts: 1000+

Need help with 3D rendering

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
clear
I 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.

Please help  sad

Last edited by AgentRoop (2012-07-17 21:59:53)


La La
I wrote an album.

Offline

 

#2 2012-07-17 23:03:13

AtomicBawm3
Scratcher
Registered: 2009-06-27
Posts: 1000+

Re: Need help with 3D rendering

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.


http://i50.tinypic.com/j0yw0p.jpg

Offline

 

#3 2012-07-18 00:40:34

amcerbu
Scratcher
Registered: 2009-07-21
Posts: 500+

Re: Need help with 3D rendering

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

 

#4 2012-07-18 05:40:17

SciTecCf
Scratcher
Registered: 2011-11-23
Posts: 1000+

Re: Need help with 3D rendering

You would need to do something like this:

Start with this:

when gf clicked
forever
 set [floorcount v] to [0]
end
Now, 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
Now, 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


http://bit.ly/LCZEJRhttp://bit.ly/LSONcOhttp://bit.ly/LF3vIc
http://trinary.site40.net/images/scratchrank.php?username=SciTecCf&amp;display=small

Offline

 

#5 2012-07-18 10:05:57

AgentRoop
Scratcher
Registered: 2012-02-11
Posts: 1000+

Re: Need help with 3D rendering

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.  smile


La La
I wrote an album.

Offline

 

#6 2012-07-18 10:07:05

AgentRoop
Scratcher
Registered: 2012-02-11
Posts: 1000+

Re: Need help with 3D rendering

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!  big_smile


La La
I wrote an album.

Offline

 

#7 2012-07-18 10:08:39

AgentRoop
Scratcher
Registered: 2012-02-11
Posts: 1000+

Re: Need help with 3D rendering

SciTecCf wrote:

You would need to do something like this:

Start with this:

when gf clicked
forever
 set [floorcount v] to [0]
end
Now, 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!  big_smile


La La
I wrote an album.

Offline

 

#8 2012-07-18 10:33:36

SciTecCf
Scratcher
Registered: 2011-11-23
Posts: 1000+

Re: Need help with 3D rendering

AgentRoop wrote:

SciTecCf wrote:

You would need to do something like this:

Start with this:

when gf clicked
forever
 set [floorcount v] to [0]
end
Now, 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!  big_smile

Mine and AB3's are the same.  smile


http://bit.ly/LCZEJRhttp://bit.ly/LSONcOhttp://bit.ly/LF3vIc
http://trinary.site40.net/images/scratchrank.php?username=SciTecCf&amp;display=small

Offline

 

#9 2012-07-18 19:30:53

AgentRoop
Scratcher
Registered: 2012-02-11
Posts: 1000+

Re: Need help with 3D rendering

^ oh, lol. I'm just starting in 3 Dimensional stuff, sorry.


La La
I wrote an album.

Offline

 

#10 2012-07-23 04:48:36

brandondyer64
New Scratcher
Registered: 2012-06-08
Posts: 2

Re: Need help with 3D rendering

CLEAR needs to be FIRST not LAST

forever
clear//FIRST
repeat<floor>

Offline

 

#11 2012-07-23 05:26:38

SciTecCf
Scratcher
Registered: 2011-11-23
Posts: 1000+

Re: Need help with 3D rendering

brandondyer64 wrote:

CLEAR needs to be FIRST not LAST

forever
clear//FIRST
repeat<floor>

Yeah, we know. This is kind of already resolved, though.  smile


http://bit.ly/LCZEJRhttp://bit.ly/LSONcOhttp://bit.ly/LF3vIc
http://trinary.site40.net/images/scratchrank.php?username=SciTecCf&amp;display=small

Offline

 

Board footer