|Please expand this article or section. You can help by talk page.if you are an editor. More information might be found in a section of the|
|This article or section may not have content matching Scratch Wiki editing standards. Please improve it according to Scratch Wiki:Guidelines. |
Reason: Too short, little explanation.
|Note:||This tutorial is recommended for a bit more experienced Scratchers due to its intricacy.|
What is a 3D environment?
A 3D environment is a place that involves the common X and Y axes, as well as the additional Z axis. The Z axis is a Cartesian coordinate, much like the X and Y axes, but the Z axis usually is the axis for depth. In real life, the Z axis exists, but in Scratch, it does not. We can incorporate size and movement that causes an illusion of depth.
Example using size to create a 3D effect
when green flag clicked set [scroll z v] to  set [scroll y v] to  set [scroll x v] to [-30] forever set size to ((scroll z) + ((40) * (0)))% set x to ((scroll x) + ((480) * (0))) set y to ((scroll y) + ((360) * (0))) if <key [up arrow v] pressed?> then change [scroll z v] by ((size) / (45)) change [scroll x v] by ((x position) / (55)) end if <key [down arrow v] pressed?> then change [scroll z v] by ((size) / (-45)) change [scroll x v] by ((x position) / (-55)) end if <key [left arrow v] pressed?> then change [scroll x v] by ((size) / (55)) end if <key [right arrow v] pressed?> then change [scroll x v] by ((size) / (-55)) end if < <(scroll z) < > or <(scroll z) > > > then hide else show end
The "scroll x" and "scroll y" variables' value can be changed so the sprite's position can be changed. The "scroll z" variable is rather special. It does not change the sprite's position, but it changes The size of the sprite.
This method of 3D scripting is very rudimentary, and it does not involve any collision detection, and it would not apply to a moving object.
This is one of the ways you can make the illusion of 3D. Scratch doesn't allow you to make three dimensional games, but it allows you to make the illusion of one. The X axis is the sprites position from left to right. The Y axis is the position from top to bottom, and the Z axis is the sprites size, allowing you to make the sprite small or large. As said in the beginning of this article, we can always incorporate size and movement to create the 3D illusion. If you stroll down a street, you will notice that the farther the things are, the smaller they look. If you put this same principle in video games, you will get a 3D effect. A Raycaster is a more efficient way of 3D in Scratch.
Example using pen and layering
This is a slightly more efficient way of making a 3D illusion. This technique uses layering and stamping. Here is the script:
when flag clicked forever clear go to x(0) y(0) stamp change y by(2) stamp change y by(2) stamp change y by(2) stamp change y by(2) stamp change y by(2) stamp change y by(2) stamp end when green flag clicked forever point towards [mouse-pointer v] end
This method does not use size to create the 3D effect. It changes the position of the sprite and stamps the sprite on the background. This makes several copies of the same sprite, in different positions. This creates a 3D effect.