dragonruby-parallax

a simple parallax made with dragon-ruby
git clone https://github.com/TanguyAndreani/dragonruby-parallax
Log | Files | Refs | README

commit f15ff518958cf4776da63a2141d40c322ff1ebe9
parent 78d9bec201c2133c65fdf697540053623709ae05
Author: Tanguy Andreani <tanguy.andreani@tuta.io>
Date:   Tue, 10 Mar 2020 15:12:35 +0100

avoid unnecessary computation

Diffstat:
Mapp/main.rb | 8+++-----
1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/app/main.rb b/app/main.rb @@ -1,17 +1,15 @@ WIDTH, HEIGHT = 1280, 720 -def layers - [ +LAYERS = [ 'layer1.png', 'layer2.png', 'layer3.png', 'layer4.png', 'layer5.png', - ].map { |s| "assets/#{s}" } -end +].map { |s| "assets/#{s}" } def tick args - layers.each_with_index do |f, i| + LAYERS.each_with_index do |f, i| i += 1 t = args.state.tick_count % (WIDTH / i) x_coord = t * i * -1