ScratchData LogoScratchData
Back to boisvert's profile

3D ball and background

BOboisvert•Created February 25, 2009
3D ball and background
21
10
507 views
View on Scratch

Description

The same bouncy ball as before, but the background is drawn as a wireframe. The co-ordinates for the room are in a few sprites that draw the walls. For the ball, one loop does all the 3D display. Another does the movement - bouncing and falling. To remix, try duplicating the ball (and its shadow), or putting in a different wireframe drawing. The old notes are here: To understand this, download it first (!). The ball has 3 co-ordinates in the room: x, y, z positions (z is depth away from you). First, we decide on the proportions of the space where we are working. I wanted the ball to be half the size when it's at the far end, so z is transformed following this formula: zfactor = 1+(z/400) This way, if - z=0, zfactor = 1 (max size) - z=400, zfactor = 2 (furthest away, min size) Now to place the ball we do: screen x = x/zfactor screen y = y/zfactor size % = 100/zfactor Simple, innit? It's the perspective formula. To get the ball to move, we use speed co-ordinates, like a ball in 2D, only there are 3 speeds, for the 3 axes. I added a co-ordinate to the "gravity ball" example provided with the samples. Enjoy scratching!

Project Details

Project ID430951
CreatedFebruary 25, 2009
Last ModifiedFebruary 25, 2009
SharedFebruary 25, 2009
Visibilityvisible
CommentsAllowed

Remix Information

Parent ProjectView Parent
Root ProjectView Root