summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorFrederico Linhares <fred@linhares.blue>2023-05-29 10:54:59 -0300
committerFrederico Linhares <fred@linhares.blue>2023-05-29 16:04:16 -0300
commit7f7515f22517509fb93ee1615c72006dca6abb03 (patch)
tree2799565116c209ff057809494e4b9eb0e90ec279 /test
parentb8614162cdbb3817a7a58ceadf8b6b0d05fae952 (diff)
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.
Diffstat (limited to 'test')
-rw-r--r--test/src/mode/demo.rb19
1 files changed, 12 insertions, 7 deletions
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|