Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » 3d game tutorial
- simongolf03
-
Scratcher
15 posts
3d game tutorial
First you need three sprites two sprites with one pixel only and the third with 8 pixels width and high and an L inside. Rename the first with a pixel to the “player” and the other with a pixel to “render”. And the sprite with 8*8 and a “L” inside to “World”.
Place this script inside the “player”:
Place this script in the “World”
Place this script in the “render”:
Place this script inside the “player”:
when green flag clicked
set [ghost v] effect to (100)
go to x: (0) y: (0)
set [vel v] to [0]
set [velocity v] to [0]
set [velocity 3 v] to [0]
point in direction (90 v)
forever
if <key [a v] pressed?> then
change [velocity v] by (-4)
end
if <key [d v] pressed?> then
change [velocity v] by (4)
end
set [velocity v] to ((velocity) * (0.5))
turn cw (velocity) degrees
if <key [w v] pressed?> then
change [velocity 2 v] by (1)
end
if <key [s v] pressed?> then
change [velocity 2 v] by (-1)
end
move (velocity 2) steps
if <touching [world v] ?> then
move ((0) - (velocity 2)) steps
set [velocity 2 v] to [0]
end
broadcast [move v]
when green flag clicked
forever
if <key [up arrow v] pressed?> then
change [velocity3 v] by (-20)
end
if <key [down arrow v] pressed?> then
change [velocity3 v] by (20)
end
Place this script in the “World”
when green flag clicked
show
set [ghost v] effect to (100)
set size to (1600) %
go to x: (0) y: (0)
Place this script in the “render”:
define render
go to x: (-236) y: (180)
set pen size to ((1) + (quality))
clear
pen down
set pen color to [#ff2222]
set [i v] to (length of [distances v])
repeat (length of [distances v])
set pen shade to ((item (i) of [distances v]) * ((1) + ((2) / (3))))
set y to ((item (i) of [distances v]) + (velocity3))
pen down
set y to (((0) - ((item (i) of [distances v]) * (4))) + (0))
pen up
change [i v] by (-1)
change x by (quality)
end
define sense
delete (all v) of [distances v]
set [distance v] to [0]
set [fov v] to ((240) / (quality))
repeat (((240) / (quality)) * (2))
set [distance v] to [60]
go to [player v]
point in direction ((fov) + ([direction v] of [player v]))
repeat until <<[0] = (distance)> or <touching [world v] ?>>
move (1) steps
change [distance v] by (-1)
end
add [distance] to [distances v]
change [fov v] by (-1)
end
when I receive [move v]
sense
render
- CatsUnited
-
Scratcher
1000+ posts
3d game tutorial
That's not what's called true 3D in scratch, it's pusedo-3D. If you want to do “true 3D”, you will need a huge knowledge of maths.
- simongolf03
-
Scratcher
15 posts
3d game tutorial
Ok whats fore code? Anyway is this script an labyrinthscript. 

- HardClaw57
-
Scratcher
500+ posts
3d game tutorial
Ok whats fore code? Anyway is this script an labyrinthscript.Uhh…
don't exactly understand what you're trying to say.
- HardClaw57
-
Scratcher
500+ posts
3d game tutorial
Glitch block. It's probably something left over from 1.4whats that dark block?
(distance)
Last edited by HardClaw57 (Sept. 1, 2015 05:20:14)
- HardClaw57
-
Scratcher
500+ posts
3d game tutorial
How is the “true 3d” script look?It's huuuuuuge and requires algebra, trigonomtry, pen, etc.
- ZozaTech
-
Scratcher
500+ posts
3d game tutorial
It is nice you like to help other scratchers. But the help with scripts is only for helping others! Thanks though ! 

- liam48D
-
Scratcher
1000+ posts
3d game tutorial
It's nice that you like to help other Scratchers,
but the Help with Scripts forum is for helping other Scratchers!
Thanks though!
Highlighted text is what makes me confused.
- Crimson19
-
Scratcher
1000+ posts
3d game tutorial
It is nice you like to help other scratchers. But the help with scripts is only for helping others! Thanks though !
Actually, tutorials are allowed but topics asking for people to come and get help aren't.
- ZozaTech
-
Scratcher
500+ posts
3d game tutorial
It is allowed but it is inhumane. We end up with so many posts like this fighting to remain on or near the first page that there's no room for people to actually ask for help. There are dozens of topics that could be covered in this way.It is nice you like to help other scratchers. But the help with scripts is only for helping others! Thanks though !
Actually, tutorials are allowed but topics asking for people to come and get help aren't.
If its good enough it will get referred to by people helping here.
- liam48D
-
Scratcher
1000+ posts
3d game tutorial
Whoa, it's only been like a week since the previous person posted.. not a necro.OK?Please don't necropost.
@simongolf03 Please don't post things that are offtopic.

- allo34
-
Scratcher
31 posts
3d game tutorial
when clickedset ghost effect to 100go to x: 0 y: 0set vel to 0set velocity to 0set velocity 3 to 0point in direction 90foreverif key a pressed? thenchange velocity by -4if key d pressed? thenchange velocity by 4set velocity to velocity * 0.5turn velocity degreesif key w pressed? thenchange velocity 2 by 1if key s pressed? thenchange velocity 2 by -1move velocity 2 stepsif touching world ? thenmove 0 - velocity 2 stepsset velocity 2 to 0broadcast move
when clickedforeverif key up arrow pressed? thenchange velocity3 by -20if key down arrow pressed? thenchange velocity3 by 20
Place this script in the “World”
when clickedshowset ghost effect to 100set size to 1600 %go to x: 0 y: 0
Place this script in the “render”:
definerendergo to x: -236 y: 180set pen size to 1 + qualityclearpen downset pen color to set i to length of distancesrepeat length of distancesset pen shade to item i of distances * 1 + 2 / 3set y to item i of distances + velocity3pen downset y to 0 - item i of distances * 4 + 0pen upchange i by -1change x by quality
definesensedelete all of distancesset distance to 0set fov to 240 / qualityrepeat 240 / quality * 2set distance to 60go to playerpoint in direction fov + direction of playerrepeat until 0 = distance or touching world ?move 1 stepschange distance by -1add distance to distanceschange fov by -1
when I receive movesenserender
when clickedforeversimongolf03
when clickedforeverif key up arrow pressed? thenchange velocity3 by -20if key down arrow pressed? thenchange velocity3 by 20
Place this script in the “World”
when clickedshowset ghost effect to 100set size to 1600 %go to x: 0 y: 0
Place this script in the “render”:
definerendergo to x: -236 y: 180set pen size to 1 + qualityclearpen downset pen color to set i to length of distancesrepeat length of distancesset pen shade to item i of distances * 1 + 2 / 3set y to item i of distances + velocity3pen downset y to 0 - item i of distances * 4 + 0pen upchange i by -1change x by quality
definesensedelete all of distancesset distance to 0set fov to 240 / qualityrepeat 240 / quality * 2set distance to 60go to playerpoint in direction fov + direction of playerrepeat until 0 = distance or touching world ?move 1 stepschange distance by -1add distance to distanceschange fov by -1
when I receive movesenserender
when clickedforeversimongolf03
- scratchinghead
-
Scratcher
1000+ posts
3d game tutorial
when clickedset ghost effect to 100go to x: 0 y: 0set vel to 0set velocity to 0set velocity 3 to 0point in direction 90foreverif key a pressed? thenchange velocity by -4if key d pressed? thenchange velocity by 4set velocity to velocity * 0.5turn velocity degreesif key w pressed? thenchange velocity 2 by 1if key s pressed? thenchange velocity 2 by -1move velocity 2 stepsif touching world ? thenmove 0 - velocity 2 stepsset velocity 2 to 0broadcast moveNecropost…
when clickedforeverif key up arrow pressed? thenchange velocity3 by -20if key down arrow pressed? thenchange velocity3 by 20
Place this script in the “World”
when clickedshowset ghost effect to 100set size to 1600 %go to x: 0 y: 0
Place this script in the “render”:
definerendergo to x: -236 y: 180set pen size to 1 + qualityclearpen downset pen color to set i to length of distancesrepeat length of distancesset pen shade to item i of distances * 1 + 2 / 3set y to item i of distances + velocity3pen downset y to 0 - item i of distances * 4 + 0pen upchange i by -1change x by quality
definesensedelete all of distancesset distance to 0set fov to 240 / qualityrepeat 240 / quality * 2set distance to 60go to playerpoint in direction fov + direction of playerrepeat until 0 = distance or touching world ?move 1 stepschange distance by -1add distance to distanceschange fov by -1
when I receive movesenserender
when clickedforeversimongolf03
- liam48D
-
Scratcher
1000+ posts
3d game tutorial
And spam..when clickedset ghost effect to 100go to x: 0 y: 0set vel to 0set velocity to 0set velocity 3 to 0point in direction 90foreverif key a pressed? thenchange velocity by -4if key d pressed? thenchange velocity by 4set velocity to velocity * 0.5turn velocity degreesif key w pressed? thenchange velocity 2 by 1if key s pressed? thenchange velocity 2 by -1move velocity 2 stepsif touching world ? thenmove 0 - velocity 2 stepsset velocity 2 to 0broadcast moveNecropost…
when clickedforeverif key up arrow pressed? thenchange velocity3 by -20if key down arrow pressed? thenchange velocity3 by 20
Place this script in the “World”
when clickedshowset ghost effect to 100set size to 1600 %go to x: 0 y: 0
Place this script in the “render”:
definerendergo to x: -236 y: 180set pen size to 1 + qualityclearpen downset pen color to set i to length of distancesrepeat length of distancesset pen shade to item i of distances * 1 + 2 / 3set y to item i of distances + velocity3pen downset y to 0 - item i of distances * 4 + 0pen upchange i by -1change x by quality
definesensedelete all of distancesset distance to 0set fov to 240 / qualityrepeat 240 / quality * 2set distance to 60go to playerpoint in direction fov + direction of playerrepeat until 0 = distance or touching world ?move 1 stepschange distance by -1add distance to distanceschange fov by -1
when I receive movesenserender
when clickedforeversimongolf03
- epickitty6104
-
Scratcher
54 posts
3d game tutorial
First you need three sprites two sprites with one pixel only and the third with 8 pixels width and high and an L inside. Rename the first with a pixel to the “player” and the other with a pixel to “render”. And the sprite with 8*8 and a “L” inside to “World”.
Place this script inside the “player”:when green flag clicked
set [ghost v] effect to (100)
go to x: (0) y: (0)
set [vel v] to [0]
set [velocity v] to [0]
set [velocity 3 v] to [0]
point in direction (90 v)
forever
if <key [a v] pressed?> then
change [velocity v] by (-4)
end
if <key [d v] pressed?> then
change [velocity v] by (4)
end
set [velocity v] to ((velocity) * (0.5))
turn cw (velocity) degrees
if <key [w v] pressed?> then
change [velocity 2 v] by (1)
end
if <key [s v] pressed?> then
change [velocity 2 v] by (-1)
end
move (velocity 2) steps
if <touching [world v] ?> then
move ((0) - (velocity 2)) steps
set [velocity 2 v] to [0]
end
broadcast [move v]
when green flag clicked
forever
if <key [up arrow v] pressed?> then
change [velocity3 v] by (-20)
end
if <key [down arrow v] pressed?> then
change [velocity3 v] by (20)
end
Place this script in the “World”when green flag clicked
show
set [ghost v] effect to (100)
set size to (1600) %
go to x: (0) y: (0)
Place this script in the “render”:define render
go to x: (-236) y: (180)
set pen size to ((1) + (quality))
clear
pen down
set pen color to [#ff2222]
set [i v] to (length of [distances v])
repeat (length of [distances v])
set pen shade to ((item (i) of [distances v]) * ((1) + ((2) / (3))))
set y to ((item (i) of [distances v]) + (velocity3))
pen down
set y to (((0) - ((item (i) of [distances v]) * (4))) + (0))
pen up
change [i v] by (-1)
change x by (quality)
end
define sense
delete (all v) of [distances v]
set [distance v] to [0]
set [fov v] to ((240) / (quality))
repeat (((240) / (quality)) * (2))
set [distance v] to [60]
go to [player v]
point in direction ((fov) + ([direction v] of [player v]))
repeat until <<[0] = (distance)> or <touching [world v] ?>>
move (1) steps
change [distance v] by (-1)
end
add [distance] to [distances v]
change [fov v] by (-1)
end
when I receive [move v]
sense
render
- scratchinghead
-
Scratcher
1000+ posts
3d game tutorial
Please don't necropost…First you need three sprites two sprites with one pixel only and the third with 8 pixels width and high and an L inside. Rename the first with a pixel to the “player” and the other with a pixel to “render”. And the sprite with 8*8 and a “L” inside to “World”.
Place this script inside the “player”:
-snip-
- Discussion Forums
- » Help with Scripts
-
» 3d game tutorial




whats that dark block?




