Module: DXOpal

Includes:
Constants::Colors, Input::KeyCodes, Input::MouseCodes, SoundEffect::WaveTypes
Defined in:
lib/dxopal.rb,
lib/dxopal/font.rb,
lib/dxopal/image.rb,
lib/dxopal/input.rb,
lib/dxopal/sound.rb,
lib/dxopal/sprite.rb,
lib/dxopal/window.rb,
lib/dxopal/version.rb,
lib/dxopal/sound_effect.rb,
lib/dxopal/sprite/physics.rb,
lib/dxopal/input/key_codes.rb,
lib/dxopal/remote_resource.rb,
lib/dxopal/constants/colors.rb,
lib/dxopal/sprite/collision_area.rb,
lib/dxopal/sprite/collision_check.rb

Defined Under Namespace

Modules: Constants, Input, Window Classes: Font, Image, RemoteResource, Sound, SoundEffect, Sprite

Constant Summary collapse

P_CT =

Like ‘Kernel.p`, but prints only limited times for each `key` This is useful for debugging your game without flooding the developer console.

Example:

p_ player_x: @player.x
p_({player_x: @player.x}, 20)
Hash.new{|h, k| h[k] = 0}
VERSION =
"1.6.0"

Constants included from SoundEffect::WaveTypes

SoundEffect::WaveTypes::WAVE_RECT, SoundEffect::WaveTypes::WAVE_SAW, SoundEffect::WaveTypes::WAVE_SIN, SoundEffect::WaveTypes::WAVE_TRI

Constants included from Input::MouseCodes

Input::MouseCodes::M_4TH_BUTTON, Input::MouseCodes::M_5TH_BUTTON, Input::MouseCodes::M_LBUTTON, Input::MouseCodes::M_MBUTTON, Input::MouseCodes::M_RBUTTON

Constants included from Input::KeyCodes

Input::KeyCodes::K_0, Input::KeyCodes::K_1, Input::KeyCodes::K_2, Input::KeyCodes::K_3, Input::KeyCodes::K_4, Input::KeyCodes::K_5, Input::KeyCodes::K_6, Input::KeyCodes::K_7, Input::KeyCodes::K_8, Input::KeyCodes::K_9, Input::KeyCodes::K_A, Input::KeyCodes::K_ADD, Input::KeyCodes::K_APOSTROPHE, Input::KeyCodes::K_B, Input::KeyCodes::K_BACK, Input::KeyCodes::K_BACKSLASH, Input::KeyCodes::K_BACKSPACE, Input::KeyCodes::K_C, Input::KeyCodes::K_CAPSLOCK, Input::KeyCodes::K_COLON, Input::KeyCodes::K_COMMA, Input::KeyCodes::K_CONVERT, Input::KeyCodes::K_D, Input::KeyCodes::K_DECIMAL, Input::KeyCodes::K_DELETE, Input::KeyCodes::K_DIVIDE, Input::KeyCodes::K_DOWN, Input::KeyCodes::K_DOWNARROW, Input::KeyCodes::K_E, Input::KeyCodes::K_END, Input::KeyCodes::K_ENTER, Input::KeyCodes::K_EQUALS, Input::KeyCodes::K_ESCAPE, Input::KeyCodes::K_F, Input::KeyCodes::K_F1, Input::KeyCodes::K_F10, Input::KeyCodes::K_F11, Input::KeyCodes::K_F12, Input::KeyCodes::K_F13, Input::KeyCodes::K_F14, Input::KeyCodes::K_F15, Input::KeyCodes::K_F2, Input::KeyCodes::K_F3, Input::KeyCodes::K_F4, Input::KeyCodes::K_F5, Input::KeyCodes::K_F6, Input::KeyCodes::K_F7, Input::KeyCodes::K_F8, Input::KeyCodes::K_F9, Input::KeyCodes::K_G, Input::KeyCodes::K_GRAVE, Input::KeyCodes::K_H, Input::KeyCodes::K_HOME, Input::KeyCodes::K_I, Input::KeyCodes::K_INSERT, Input::KeyCodes::K_J, Input::KeyCodes::K_K, Input::KeyCodes::K_KANA, Input::KeyCodes::K_L, Input::KeyCodes::K_LALT, Input::KeyCodes::K_LBRACKET, Input::KeyCodes::K_LCONTROL, Input::KeyCodes::K_LEFT, Input::KeyCodes::K_LEFTARROW, Input::KeyCodes::K_LSHIFT, Input::KeyCodes::K_M, Input::KeyCodes::K_MINUS, Input::KeyCodes::K_MULTIPLY, Input::KeyCodes::K_MUTE, Input::KeyCodes::K_N, Input::KeyCodes::K_NOCONVERT, Input::KeyCodes::K_NUMLOCK, Input::KeyCodes::K_NUMPAD0, Input::KeyCodes::K_NUMPAD1, Input::KeyCodes::K_NUMPAD2, Input::KeyCodes::K_NUMPAD3, Input::KeyCodes::K_NUMPAD4, Input::KeyCodes::K_NUMPAD5, Input::KeyCodes::K_NUMPAD6, Input::KeyCodes::K_NUMPAD7, Input::KeyCodes::K_NUMPAD8, Input::KeyCodes::K_NUMPAD9, Input::KeyCodes::K_NUMPADENTER, Input::KeyCodes::K_NUMPADMINUS, Input::KeyCodes::K_NUMPADPERIOD, Input::KeyCodes::K_NUMPADPLUS, Input::KeyCodes::K_NUMPADSLASH, Input::KeyCodes::K_NUMPADSTAR, Input::KeyCodes::K_O, Input::KeyCodes::K_P, Input::KeyCodes::K_PAUSE, Input::KeyCodes::K_PERIOD, Input::KeyCodes::K_PGDN, Input::KeyCodes::K_PGUP, Input::KeyCodes::K_Q, Input::KeyCodes::K_R, Input::KeyCodes::K_RALT, Input::KeyCodes::K_RBRACKET, Input::KeyCodes::K_RCONTROL, Input::KeyCodes::K_RETURN, Input::KeyCodes::K_RIGHT, Input::KeyCodes::K_RIGHTARROW, Input::KeyCodes::K_RSHIFT, Input::KeyCodes::K_S, Input::KeyCodes::K_SCROLL, Input::KeyCodes::K_SEMICOLON, Input::KeyCodes::K_SLASH, Input::KeyCodes::K_SPACE, Input::KeyCodes::K_SUBTRACT, Input::KeyCodes::K_T, Input::KeyCodes::K_TAB, Input::KeyCodes::K_U, Input::KeyCodes::K_UNDERLINE, Input::KeyCodes::K_UP, Input::KeyCodes::K_UPARROW, Input::KeyCodes::K_V, Input::KeyCodes::K_VOLUMEDOWN, Input::KeyCodes::K_VOLUMEUP, Input::KeyCodes::K_W, Input::KeyCodes::K_WEBBACK, Input::KeyCodes::K_WEBFAVORITES, Input::KeyCodes::K_WEBFORWARD, Input::KeyCodes::K_WEBHOME, Input::KeyCodes::K_WEBREFRESH, Input::KeyCodes::K_WEBSEARCH, Input::KeyCodes::K_WEBSTOP, Input::KeyCodes::K_X, Input::KeyCodes::K_Y, Input::KeyCodes::K_YEN, Input::KeyCodes::K_Z

Constants included from Constants::Colors

Constants::Colors::C_BLACK, Constants::Colors::C_BLUE, Constants::Colors::C_CYAN, Constants::Colors::C_DEFAULT, Constants::Colors::C_GREEN, Constants::Colors::C_MAGENTA, Constants::Colors::C_RED, Constants::Colors::C_WHITE, Constants::Colors::C_YELLOW

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.dump_error(&block) ⇒ Object

Call block and dump backtrace if an exception is raised. Nothing is shown if a tag with ‘id=’dxopal-errors’‘ does not exist



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/dxopal.rb', line 40

def self.dump_error(&block)
  block.call
rescue Exception => ex
  div = `document.getElementById('dxopal-errors')`
  if `div && !ex.DXOpalPrinted`
    %x{
      div.textContent = "ERROR: " + #{ex.class.name};
      var ul = document.createElement('ul');
      // Note: ex.backtrace may be an Array or a String
      #{Array(ex.backtrace)}.forEach(function(line){
        var li = document.createElement('li');
        li.textContent = line;
        ul.appendChild(li);
      });
      div.appendChild(ul);
      ex.DXOpalPrinted = true;
    }
  end
  raise ex
end

Instance Method Details

#p_(hash, n = 10) ⇒ Object



69
70
71
72
73
74
# File 'lib/dxopal.rb', line 69

def p_(hash, n=10)
  key = hash.keys.sort.join
  return if P_CT[key] >= n
  `console.log(#{hash.inspect})`
  P_CT[key] += 1
end