module Gosu

require ‘math.rb’

Constants

AM_MODES

amMultiply -> The color’s channels will be multiplied with each other.

BF_SMOOTH

Flags that affect the tileability of an image

BF_TILEABLE
BF_TILEABLE_BOTTOM
BF_TILEABLE_LEFT
BF_TILEABLE_RIGHT
BF_TILEABLE_TOP
DESCRIPTION
FF_BOLD
FF_COMBINATIONS
FF_ITALIC
FF_UNDERLINE
GpButton0

Game pad

GpButton1
GpButton10
GpButton11
GpButton12
GpButton13
GpButton14
GpButton15
GpButton2
GpButton3
GpButton4
GpButton5
GpButton6
GpButton7
GpButton8
GpButton9
Kb0
Kb1
Kb2
Kb3
Kb4
Kb5
Kb6
Kb7
Kb8
Kb9
KbA
KbB
KbBackspace
KbC
KbD
KbDelete
KbDown
KbE
KbEnd
KbEnter

On Numpad

KbEscape
KbF
KbF1
KbF10
KbF11
KbF12
KbF2
KbF3
KbF4
KbF5
KbF6
KbF7
KbF8
KbF9
KbG
KbH
KbHome

On Numpad

KbI
KbInsert
KbJ
KbK
KbL
KbLeft
KbLeftAlt
KbLeftControl
KbLeftShift
KbM
KbN
KbNumpad0
KbNumpad1
KbNumpad2
KbNumpad3
KbNumpad4
KbNumpad5
KbNumpad6
KbNumpad7
KbNumpad8
KbNumpad9
KbNumpadAdd
KbNumpadDivide
KbNumpadMultiply
KbNumpadSubtract
KbO
KbP
KbPageDown
KbPageUp
KbQ
KbR
KbReturn

Above the right shift key

KbRight
KbRightAlt
KbRightControl

Above the right shift key

KbRightShift

KbRightControl = JavaImports::KeyEvent::KEYCODE_CTRL_RIGHT

KbS
KbSpace
KbT
KbTab
KbU
KbUp
KbV
KbW
KbX
KbY
KbZ
MAX_SAMPLES
NO_CLIPPING
NO_TEXTURE
NoButton

TODO Fix mouse buttons, Mouse access to motion event MsLeft = JavaImports::MotionEvent::BUTTON_PRIMARY MsMiddle = JavaImports::MotionEvent::BUTTON_TERTIARY MsRight = JavaImports::MotionEvent::BUTTON_SECONDARY TODO Axis wheel is not right MsWheelDown = JavaImports::MotionEvent::AXIS_WHEEL MsWheelUp = JavaImports::MotionEvent::AXIS_WHEEL

TA_JUSTIFY
VERSION

Public Class Methods

apply_border_flags(dest, source, src_x, src_y, src_width, src_height, border_flags) click to toggle source
# File lib/gosu_android/graphics/bitmapUtils.rb, line 4
def self.apply_border_flags(dest, source, src_x, src_y, src_width, src_height, border_flags)
  dest.resize(src_width + 2, src_height + 2)

  #The borders are made "harder" by duplicating the original bitmap's
  #borders.

  #Top.
  if (border_flags & BF_TILEABLE_TOP)
      dest.insert(source, 1, 0, src_x, src_y, src_width, 1)
  end
  #Bottom.
  if (border_flags & BF_TILEABLE_BOTTOM)
      dest.insert(source, 1, dest.height - 1,
          src_x, src_y + src_height - 1, src_width, 1)
  end
  #Left.
  if (border_flags & BF_TILEABLE_LEFT)
      dest.insert(source, 0, 1, src_x, src_y, 1, src_height)
  end
  #Right.
  if (border_flags & BF_TILEABLE_RIGHT)
      dest.insert(source, dest.width - 1, 1,
          src_x + src_width - 1, src_y, 1, src_height)
  end
  #Top left.
  if ((border_flags & BF_TILEABLE_TOP) and (border_flags & BF_TILEABLE_LEFT))
      dest.set_pixel(0, 0,
          source.get_pixel(src_x, src_y))
  end
  #Top right.
  if ((border_flags & BF_TILEABLE_TOP) and (border_flags & BF_TILEABLE_RIGHT))
      dest.set_pixel(dest.width - 1, 0,
          source.get_pixel(src_x + src_width - 1, src_y))
  end
  #Bottom left.
  if ((border_flags & BF_TILEABLE_BOTTOM) and (border_flags & BF_TILEABLE_LEFT))
      dest.set_pixel(0, dest.height - 1,
          source.get_pixel(src_x, src_y + src_height - 1))
  end
  #Bottom right.
  if ((border_flags & BF_TILEABLE_BOTTOM) and (border_flags & BF_TILEABLE_RIGHT))
      dest.set_pixel(dest.width - 1, dest.height - 1,
          source.get_pixel(src_x + src_width - 1, src_y + src_height - 1))
  end
  #Now put the final image into the prepared borders.
  dest.insert(source, 1, 1, src_x, src_y, src_width, src_height)
end
default_font_name() click to toggle source
# File lib/gosu_android/graphics/font.rb, line 57
def self.default_font_name
  JavaImports::Typeface::MONOSPACE
end
distance(x1, y1, x2, y2) click to toggle source

Returns the distance between two points.

# File lib/gosu_android/math.rb, line 17
def self.distance(x1, y1, x2, y2)
  Math::sqrt((x1 - x2)**2 + (y1 - y2)**2)
end
distance_sqr(x1, y1, x2, y2) click to toggle source

Returns the square of the distance between two points.

# File lib/gosu_android/math.rb, line 12
def self.distance_sqr(x1, y1, x2, y2)
  (x1 - x2)**2 + (y1 - y2)**2
end
is_p_to_the_left_of_ab(xa, ya, xb, yb, xp, yp) click to toggle source
# File lib/gosu_android/graphics/common.rb, line 8
def self.is_p_to_the_left_of_ab(xa, ya, xb, yb, xp, yp)
  ((xb - xa) * (yp - ya) - (xp - xa) * (yb - ya)) > 0
end
load_image_file(window, file_name) click to toggle source

TODO define load_image with reader argument

# File lib/gosu_android/graphics/bitmap.rb, line 9
def self.load_image_file(window, file_name)
  Gosu::Bitmap.new(window.activity.getApplicationContext, file_name)
end
milliseconds() click to toggle source
# File lib/gosu_android/timing.rb, line 3
def self.milliseconds
  tp = Time.now.to_f
  (tp*1000).to_i
end
offset_x(angle, radius) click to toggle source
# File lib/gosu_android/math.rb, line 3
def self.offset_x(angle, radius)
  Math::sin(angle / 180 * Math::PI) * radius
end
offset_y(angle, radius) click to toggle source
# File lib/gosu_android/math.rb, line 7
def self.offset_y(angle, radius)
  Math::cos(angle / 180 * Math::PI) * radius
end
reorder_coordinates_if_necessary(x1, y1, x2, y2, x3, y3, c3, x4, y4, c4) click to toggle source
# File lib/gosu_android/graphics/common.rb, line 12
def self.reorder_coordinates_if_necessary(x1, y1, x2, y2, x3, y3, c3, x4, y4, c4)
  if (Gosu::is_p_to_the_left_of_ab(x1, y1, x2, y2, x3, y3) ==
    Gosu::is_p_to_the_left_of_ab(x2, y2, x3, y3, x4, y4))
    true
  else
    false
  end    
end