diff options
| author | Amir Rajan <[email protected]> | 2020-03-26 20:59:09 -0500 |
|---|---|---|
| committer | Amir Rajan <[email protected]> | 2020-03-26 20:59:09 -0500 |
| commit | bf6be11f52f143ae88d7db0e43e067b5f42afe15 (patch) | |
| tree | 6ae992ac2cb95d69160886eb7a415489f833d027 /dragon/grid.rb | |
| parent | 7d87a47c3fcae9ae33d91177f497d1a4adac635d (diff) | |
| download | dragonruby-game-toolkit-contrib-bf6be11f52f143ae88d7db0e43e067b5f42afe15.tar.gz dragonruby-game-toolkit-contrib-bf6be11f52f143ae88d7db0e43e067b5f42afe15.zip | |
synchronized with game toolkit 1.3
Diffstat (limited to 'dragon/grid.rb')
| -rw-r--r-- | dragon/grid.rb | 45 |
1 files changed, 26 insertions, 19 deletions
diff --git a/dragon/grid.rb b/dragon/grid.rb index ff6676a..b794a7d 100644 --- a/dragon/grid.rb +++ b/dragon/grid.rb @@ -7,10 +7,9 @@ module GTK class Grid include Serialize SCREEN_Y_DIRECTION = -1.0 - attr_accessor :bottom, :left, :right, :top, :rect, :origin_x, :origin_y, :center_x, :center_y, - :name, :ffi_draw + :name def initialize ffi_draw @ffi_draw = ffi_draw @@ -33,18 +32,26 @@ module GTK @origin_y + y * SCREEN_Y_DIRECTION end + def ffi_draw + @ffi_draw + end + + def ffi_draw= value + @ffi_draw = value + end + def origin_bottom_left! return if @name == :bottom_left @name = :bottom_left @origin_x = 0.0 - @origin_y = 720.0 + @origin_y = GAME_HEIGHT @left = 0.0 - @right = 1280.0 - @top = 720.0 + @right = GAME_WIDTH + @top = GAME_HEIGHT @bottom = 0.0 - @center_x = 640.0 - @center_y = 360.0 - @rect = [@left, @bottom, 1280.0, 720.0].rect + @center_x = GAME_WIDTH.half + @center_y = GAME_HEIGHT.half + @rect = [@left, @bottom, GAME_WIDTH, GAME_HEIGHT].rect @center = [@center_x, @center_y].point @ffi_draw.set_gtk_grid @origin_x, @origin_y, SCREEN_Y_DIRECTION end @@ -52,33 +59,33 @@ module GTK def origin_center! return if @name == :center @name = :center - @origin_x = 640.0 - @origin_y = 360.0 - @left = -640.0 - @right = 640.0 - @top = 360.0 - @bottom = -360.0 + @origin_x = GAME_WIDTH.half + @origin_y = GAME_HEIGHT.half + @left = -GAME_WIDTH.half + @right = GAME_WIDTH.half + @top = GAME_HEIGHT.half + @bottom = -GAME_HEIGHT.half @center_x = 0.0 @center_y = 0.0 - @rect = [@left, @bottom, 1280.0, 720.0].rect + @rect = [@left, @bottom, GAME_WIDTH, GAME_HEIGHT].rect @center = [@center_x, @center_y].point @ffi_draw.set_gtk_grid @origin_x, @origin_y, SCREEN_Y_DIRECTION end def w - 1280.0 + GAME_WIDTH end def w_half - 640.0 + w.half end def h - 720.0 + GAME_HEIGHT end def h_half - 360.0 + h.half end def center |
