Created
April 9, 2020 21:12
-
-
Save mroberti/df71b094a252491a721d5bbbaf9b123e to your computer and use it in GitHub Desktop.
Dragon Ruby high tech paragraph generator
This file contains 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
$gtk.reset() | |
$xStart = 0 | |
$xLocation = 0 | |
$yLocation = 720 | |
$width = 200 | |
$height = 300 | |
$lineThickness = 2 | |
$lineSpacing = 4 | |
def defaults args | |
args.state.theBorders ||= [] | |
end | |
def render args | |
args.outputs.solids << [0, 0, 1280, 720, 0, 0, 0, 255] | |
args.outputs.borders << args.state.theBorders | |
end | |
def calc args | |
# I fyou want to print less fast, you | |
# can check the tick count... | |
# if(args.state.tick_count%10==0)then | |
length = args.state.theBorders.length() | |
randLength = rand(15)+5 | |
if($xLocation>($width+$xStart))then | |
# Random paragraph indentation?!?! | |
tempNum = rand(5) | |
puts "tempNum: " + tempNum.to_s | |
case tempNum | |
when 2 | |
$xLocation = $xStart+10 | |
$width = rand(75)+25 | |
$yLocation = $yLocation - $lineSpacing | |
else | |
$xLocation = $xStart | |
$width = rand(75)+25 | |
end | |
$yLocation = $yLocation - $lineSpacing | |
if($yLocation <10)then | |
$xStart = $xStart + 120 | |
$yLocation = 720 | |
end | |
end | |
if(length>1)then | |
tempNum = rand(10) | |
puts "tempNum: " + tempNum.to_s | |
case tempNum | |
when 2 | |
args.state.theBorders << [$xLocation+1, $yLocation, randLength, $lineThickness, 255, 0,0,255] | |
else | |
args.state.theBorders << [$xLocation+1, $yLocation, randLength, $lineThickness, 0, 200,255,255] | |
end | |
$xLocation = $xLocation + (randLength + 2) | |
else | |
puts 'oNLY ONCE!' | |
args.state.theBorders << [$xLocation+1, $yLocation, randLength, $lineThickness, 255, 0,0,255] | |
end | |
# end | |
end | |
def tick args | |
defaults args | |
render args | |
calc args | |
#let's call it again next to it and explicitly calling the image location. | |
# args.outputs.sprites << [50, 200, 250, 250, '/sprites/circle-red.png'] | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment