From b0376d85d96a5e36246f82b069a5b5cc174f9d21 Mon Sep 17 00:00:00 2001 From: Cyberarm Date: Fri, 9 Jan 2026 08:26:55 -0600 Subject: [PATCH] Reduce allocations in Background --- lib/cyberarm_engine/background.rb | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/lib/cyberarm_engine/background.rb b/lib/cyberarm_engine/background.rb index 45d6410..4c04c46 100644 --- a/lib/cyberarm_engine/background.rb +++ b/lib/cyberarm_engine/background.rb @@ -38,12 +38,21 @@ module CyberarmEngine origin_x = (@x + (@width / 2)) origin_y = (@y + (@height / 2)) - points = [ - @top_left = Vector.new(@x, @y), - @top_right = Vector.new(@x + @width, @y), - @bottom_left = Vector.new(@x, @y + @height), - @bottom_right = Vector.new(@x + @width, @y + @height) - ] + # points = [ + # @top_left = Vector.new(@x, @y), + # @top_right = Vector.new(@x + @width, @y), + # @bottom_left = Vector.new(@x, @y + @height), + # @bottom_right = Vector.new(@x + @width, @y + @height) + # ] + + @top_left.x = @x + @top_left.y = @y + @top_right.x = @x + @width + @top_right.y = @y + @bottom_left.x = @x + @bottom_left.y = @y + @height + @bottom_right.x = @x + @width + @bottom_right.y = @y + @height [@top_left, @top_right, @bottom_left, @bottom_right].each do |vector| temp_x = vector.x - origin_x