From 4206c7d84977e40d092610fe35e2d937d693bd1c Mon Sep 17 00:00:00 2001 From: Michael Appell Date: Sun, 28 Aug 2016 17:56:30 -0400 Subject: Made Text objects changeable dynamically Modified text.rb so that the text= method modifies the instance variable Modified ruby2d.c so that before rendering Text objects, it sets their value to whatever their @text variable is Modified textcard.rb to demonstrate that Text objects can be dynamically changed --- lib/ruby2d/text.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'lib') diff --git a/lib/ruby2d/text.rb b/lib/ruby2d/text.rb index a695b31..9ba4e41 100644 --- a/lib/ruby2d/text.rb +++ b/lib/ruby2d/text.rb @@ -2,11 +2,11 @@ module Ruby2D class Text - + attr_accessor :x, :y, :size, :text def initialize(x=0, y=0, size=20, msg="Hello World!", font="Arial", c="white") - + if File.exists? font @font = font else @@ -29,7 +29,7 @@ module Ruby2D end def text=(t) - + @text = t end def remove @@ -43,7 +43,7 @@ module Ruby2D def resolve_path(font) if RUBY_PLATFORM =~ /darwin/ font_path = "/Library/Fonts/#{font}.ttf" - else + else # Linux font_path = "/usr/share/fonts/truetype/#{font}.ttf" end -- cgit v1.2.3