Sha256: 89f1908fb50350e155116e525951448a0b97368eb06e8b95ae74b6d01c319690

Contents?: true

Size: 1.01 KB

Versions: 5

Compression:

Stored size: 1.01 KB

Contents

# encoding: utf-8
# frozen_string_literal: true
# Letters. 
# 
require 'propane'

LETTERS = ('A'..'Z').to_a + ('0'..'9').to_a  + ('a'..'z').to_a

# Draws letters to the screen. This requires loading a font, 
# setting the font, and then drawing the letters.
class Letters < Propane::App
  def setup    
    size 640, 360    
    @font = create_font 'Georgia', 24 
    text_font @font
    text_align CENTER, CENTER    
  end
  
  def draw    
    background 0  	
    translate 24, 32  	
    x, y = 0.0, 0.0
    gap = 30  
    # ranges -> arrays -> joined!  	
    LETTERS.each do |letter|  	    
      fill 255
      fill 204, 204, 0 if letter =~ /[AEIOU]/
      fill 0, 204, 204 if letter =~ /[aeiou]/
      fill 153 if letter =~ /[0-9]/
      fill 255, 100, 0 if key_pressed? && (letter.downcase.eql? key) 
      fill 0, 100, 255 if key_pressed? && (letter.upcase.eql? key)  	
      text letter, x, y  		
      x += gap  		
      if x > width - 30
        x = 0
        y += gap
      end
    end
  end
end

Letters.new title: 'Letters'

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
propane-0.7.0-java examples/regular/letters.rb
propane-0.6.0-java examples/regular/letters.rb
propane-0.5.0-java examples/regular/letters.rb
propane-0.4.0.pre-java examples/regular/letters.rb
propane-0.3.0.pre-java examples/regular/letters.rb