Conversation
Member
|
@MoiRouhs thanks for that, I have a few issues with code:-
Running # Terreno
# Transcrito a JRubyArt por Carlos Rocha
# Tomado de The Coding Train https://www.youtube.com/watch?v=IKB1hWWedMk
def settings
size 800, 800, P3D
end
def setup
sketch_title 'Terreno'
@w = 1400
@h = 1100
@scl = 30
@col = @w / @scl
@filas = @h / @scl
@terreno = {}
@mover = 0
end
def draw
background 0
@mover -= 0.1
yoff = @mover
(0..@filas).each do |y|
xoff = 0
(0..@col).each do |x|
@terreno["#{x}.#{y}"] = map1d(noise(xoff, yoff), 0..1, -65..65)
xoff += 0.2
end
yoff += 0.2
end
stroke 255
no_fill
stroke 235, 69, 129
translate width / 2, height / 2
rotate_x PI / 3
translate(-@w / 2, -@h / 2)
(0...@filas).each do |y|
begin_shape(TRIANGLE_STRIP)
(0..@col).each do |x|
vertex(x * @scl, y * @scl, @terreno["#{x}.#{y}"])
vertex(x * @scl, (y + 1) * @scl, @terreno["#{x}.#{y + 1}"])
# vertex(x * @scl, y.succ * @scl, @terreno["#{x}.#{y.succ}"]) # even cooler
end
end_shape(CLOSE)
end
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Submitting a PR is the simplest way to contribute a sketch, or to submit a modification to an existing sketch. It is suggested that you add your new sketch to the contributed folder in the first instance. Should you require data, that should be in the data sub-folder or a library place that in the libraries sub-folder. Any ruby files that are not the sketch should be placed in libraries sub-folder otherwise the interfere with the autorun feature. It pays to run at least run
rubocopon your sketches, and pay attention to code format suggestions,reekcan also be helpful (these are useful tools to use, however it is not expected that you follow all their suggestions).