Guest User

Untitled

a guest
Feb 21st, 2018
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.83 KB | None | 0 0
  1. # rbGooey. -- Game GUI library to be used with rubygame
  2. # Copyright (C) 2006 Han 'kiba' Dao
  3. #
  4. # This library is free software; you can redistribute it and/or
  5. # modify it under the terms of the GNU Lesser General Public
  6. # License as published by the Free Software Foundation; either
  7. # version 2.1 of the License, or (at your option) any later version.
  8. #
  9. # This library is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. # Lesser General Public License for more details.
  13. #
  14. # You should have received a copy of the GNU Lesser General Public
  15. # License along with this library; if not, write to the Free Software
  16. # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  17.  
  18. #Class TextRender handle the TextRender tasks. It also formed the foundation for entire text library for the RbGooey. This include the TextInput class.
  19. class TextRender
  20. def initialize main , textmode
  21. @main = main
  22. @text = textmode
  23. end
  24. def render_text
  25. # This method render the texts array one by one
  26. y_value = 0
  27. default = nil
  28. skip = @main.font.line_skip
  29. @text.text.zip(@text.size,@text.x,@text.y,@text.report).each do |string , size , x , y , report|
  30. font = TTF.new("#{@main.fname}",size)
  31. if @text.omit == false
  32. render = font.render("#{[string]}",true,@text.fgcolor,@text.bgcolor)
  33. elsif @text.omit == true
  34. render = font.render("#{[string]}",true,@text.fgcolor)
  35. end
  36. render.blit(@main.screen,[x,y+=y_value])
  37. if report == 1
  38. puts report
  39. @text.textsprite.add(x,y,render)
  40. end
  41. y_value+= skip
  42. end
  43. end
  44. def screen_clear
  45. @main.background.blit(@main.screen, [0,0])
  46. end
  47. def update
  48. #This update the screen
  49. @main.screen.flip()
  50. end
  51. end
Add Comment
Please, Sign In to add comment