From 7f7515f22517509fb93ee1615c72006dca6abb03 Mon Sep 17 00:00:00 2001 From: Frederico Linhares Date: Mon, 29 May 2023 10:54:59 -0300 Subject: refa Sprite receives floats instead of Vector4D * lib/menu.rb: Uses the new interface for Sprite. * src/sprite.cpp (Sprite#new, Sprite#draw): By requiring a Vector4D as an argument, sometimes the code calling a Sprite method needs to instantiate a Vector4D and use the stance once. The functions now require four float variables to eliminate this unnecessary instantiation. --- test/src/mode/demo.rb | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'test/src/mode') diff --git a/test/src/mode/demo.rb b/test/src/mode/demo.rb index b3be78d..5f28454 100644 --- a/test/src/mode/demo.rb +++ b/test/src/mode/demo.rb @@ -29,16 +29,15 @@ module Mode @color = CandyGear::Vector3D.new(0.8, 0.2, 0.2); @model = CandyGear::Model.new(mesh, texture); - @sprite = CandyGear::Sprite.new( - texture, CandyGear::Vector4D.new(0, 0, 1.0, 1.0)); + @sprite = CandyGear::Sprite.new(texture, 0, 0, 1.0, 1.0); @rectangle = CandyGear::Vector4D.new(103.0, 1.0, 100.0, 100.0); @sprite_position = CandyGear::Vector4D.new(1.0, 1.0, 100.0, 100.0); @japanese_text_sprite = CandyGear::Sprite.new( - japanese_text, CandyGear::Vector4D.new(0, 0, 1.0, 1.0)); + japanese_text, 0, 0, 1.0, 1.0); @japanese_text_position = CandyGear::Vector4D.new( 204.0, 1.0, japanese_text.width, japanese_text.height); @english_text_sprite = CandyGear::Sprite.new( - english_text, CandyGear::Vector4D.new(0, 0, 1.0, 1.0)); + english_text, 0, 0, 1.0, 1.0); @english_text_position = CandyGear::Vector4D.new( 204.0, japanese_text.height + 2.0, english_text.width, english_text.height); @@ -100,9 +99,15 @@ module Mode end def tick() - @sprite.draw(@view1, @sprite_position); - @japanese_text_sprite.draw(@view1, @japanese_text_position); - @english_text_sprite.draw(@view1, @english_text_position); + @sprite.draw( + @view1, @sprite_position.x, @sprite_position.y, + @sprite_position.w, @sprite_position.h); + @japanese_text_sprite.draw( + @view1, @japanese_text_position.x, @japanese_text_position.y, + @japanese_text_position.w, @japanese_text_position.h); + @english_text_sprite.draw( + @view1, @english_text_position.x, @english_text_position.y, + @english_text_position.w, @english_text_position.h); @instances_rotation.rotate(0.0, BOX_ROTATION_SPEED); @rectangle.draw_rectangle(@view1, @color); @instances.each do |i| -- cgit v1.2.3