glimmer-dsl-libui 0.10.1 → 0.10.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 21db2452d3dfbb5c34356de87e7c40380d4e887a25181854321a226cee7640b5
4
- data.tar.gz: 5f62aa411e6c890e0c8228d286f273d4ebb056af7b771313a49db0344340a773
3
+ metadata.gz: a37cb8210f604b9307693af84b47ba0e21cf2a2b1059139af1d4ffa2eb727bf8
4
+ data.tar.gz: 88443d069ff718e8d28c90dbb59fc6ff5e5a05a5f3e9f5be78418d1754868769
5
5
  SHA512:
6
- metadata.gz: fabf5fd00b7994fce070e6c200814381c3fbc7df0c38e7742e5d1207d76f0c0e9d1946d5b882ee5c372acd7cc6876e485596d760127a52ada556e6402de2dd31
7
- data.tar.gz: 37f4312b11de8d5f2678c2f31e966acfed33617224fcdd4217effdd169bcfd61721b1d1ff64236a4e0957d991f86127fc6c0db55170b3e0b92d5831c5cbc51ec
6
+ metadata.gz: 1a2e8c3f162744fe2266d66a088bceb7595b04643a141b0dd526309b6155362e24fad6c760cc8eb060030fec35352ab96b9dfad7e601e5a168271e1150aa7789
7
+ data.tar.gz: 90674bbf9623bcd0e985a94824698c3117a8a70bea79f7ee81d11364054c70d57f260466123717d2f292aa50f113cfb11201580a3f74bc74400a100f9c049d6d
data/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Change Log
2
2
 
3
+ ## 0.10.2
4
+
5
+ - In Snake example, change snake direction on key press instead of key release to be more responsive for players who are not used to releasing pressed keys quickly
6
+ - In Snake example, fix issue with detecting collision too soon if a snake fills the entire space horizontally or vertically
7
+ - In Snake example, fix issue of hearing beeps on every direction change because of not properly informing LibUI when the area key down event is handled
8
+ - In Snake example, refactor `Snake::Model::Snake` to be more readable like high-level game domain rules (especially `move` method)
9
+
3
10
  ## 0.10.1
4
11
 
5
12
  - Scaffold custom shape
@@ -8,7 +15,7 @@
8
15
 
9
16
  ## 0.10.0
10
17
 
11
- - Support Custom Shapes, describing composite shapes/text/image concepts inside an `area`
18
+ - Support Custom Shapes by mixing in `Glimmer::LibUI::CustomShape` to abstract composite shapes/text/image concepts inside an `area`
12
19
  - `examples/basic_custom_shape.rb` example
13
20
  - Support nesting listeners under a Custom Shape that will automatically get added to its `body_root` control
14
21
  - Support nesting listeners under a Custom Control that will automatically get added to its `body_root` control
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # [<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer/master/images/glimmer-logo-hi-res.png" height=85 />](https://github.com/AndyObtiva/glimmer) Glimmer DSL for LibUI 0.10.1
1
+ # [<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer/master/images/glimmer-logo-hi-res.png" height=85 />](https://github.com/AndyObtiva/glimmer) Glimmer DSL for LibUI 0.10.2
2
2
  ## Prerequisite-Free Ruby Desktop Development Cross-Platform Native GUI Library ([Fukuoka Award Winning](http://www.digitalfukuoka.jp/topics/187?locale=ja))
3
3
  ### The Quickest Way From Zero To GUI
4
4
  [![Gem Version](https://badge.fury.io/rb/glimmer-dsl-libui.svg)](http://badge.fury.io/rb/glimmer-dsl-libui)
@@ -431,7 +431,7 @@ gem install glimmer-dsl-libui
431
431
  Or install via Bundler `Gemfile`:
432
432
 
433
433
  ```ruby
434
- gem 'glimmer-dsl-libui', '~> 0.10.1'
434
+ gem 'glimmer-dsl-libui', '~> 0.10.2'
435
435
  ```
436
436
 
437
437
  Test that installation worked by running the [Glimmer Meta-Example](#examples):
@@ -548,7 +548,6 @@ glimmer
548
548
  ```
549
549
 
550
550
  ```
551
- % bin/glimmer
552
551
  Glimmer DSL for LibUI (Prerequisite-Free Ruby Desktop Development Cross-Platform Native GUI Library) - Ruby Gem: glimmer-dsl-libui v0.8.0
553
552
 
554
553
  Usage: glimmer [--bundler] [--pd] [--quiet] [--debug] [--log-level=VALUE] [[ENV_VAR=VALUE]...] [[-ruby-option]...] (application.rb or task[task_args])
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.10.1
1
+ 0.10.2
@@ -47,10 +47,33 @@ class Snake
47
47
  self.joins.clear
48
48
  end
49
49
 
50
+ def turn_right
51
+ head.orientation = RIGHT_TURN_MAP[head.orientation]
52
+ end
53
+
54
+ def turn_left
55
+ head.orientation = LEFT_TURN_MAP[head.orientation]
56
+ end
57
+
50
58
  def move
51
- @old_tail = tail.dup
59
+ create_new_head
60
+ remove_old_tail
61
+ if detect_collision?
62
+ collide_and_die
63
+ else
64
+ append_new_head
65
+ eat_apple if detect_apple?
66
+ end
67
+ end
68
+
69
+ def remove_old_tail
70
+ @old_tail = tail.dup # save in case of growing and keeping old tail
71
+ @vertebrae.delete(tail)
72
+ end
73
+
74
+ def create_new_head
52
75
  @new_head = head.dup
53
- case @new_head.orientation
76
+ case head.orientation
54
77
  when :east
55
78
  @new_head.column = (@new_head.column + 1) % @game.width
56
79
  when :west
@@ -60,25 +83,28 @@ class Snake
60
83
  when :north
61
84
  @new_head.row = (@new_head.row - 1) % @game.height
62
85
  end
63
- if @vertebrae.map {|v| [v.row, v.column]}.include?([@new_head.row, @new_head.column])
64
- self.collided = true
65
- @game.over = true
66
- else
67
- @vertebrae.append(@new_head)
68
- @vertebrae.delete(tail)
69
- if head.row == @game.apple.row && head.column == @game.apple.column
70
- grow
71
- @game.apple.generate
72
- end
73
- end
74
86
  end
75
87
 
76
- def turn_right
77
- head.orientation = RIGHT_TURN_MAP[head.orientation]
88
+ def append_new_head
89
+ @vertebrae.append(@new_head)
78
90
  end
79
91
 
80
- def turn_left
81
- head.orientation = LEFT_TURN_MAP[head.orientation]
92
+ def detect_collision?
93
+ @vertebrae.map {|v| [v.row, v.column]}.include?([@new_head.row, @new_head.column])
94
+ end
95
+
96
+ def collide_and_die
97
+ self.collided = true
98
+ @game.over = true
99
+ end
100
+
101
+ def detect_apple?
102
+ head.row == @game.apple.row && head.column == @game.apple.column
103
+ end
104
+
105
+ def eat_apple
106
+ grow
107
+ @game.apple.generate
82
108
  end
83
109
 
84
110
  def grow
data/examples/snake.rb CHANGED
@@ -72,12 +72,16 @@ class Snake
72
72
  fill <= [@grid.cells[row][column], :color] # data-bind square fill to grid cell color
73
73
  }
74
74
 
75
- on_key_up do |area_key_event|
75
+ on_key_down do |area_key_event|
76
+ handled = true # assume we will handle the event
76
77
  if area_key_event[:key] == ' '
77
78
  @game.toggle_pause
78
- else
79
+ elsif %i[up right down left].include?(area_key_event[:ext_key])
79
80
  @keypress_queue << area_key_event[:ext_key]
81
+ else
82
+ handled = false # we won't handle the event after all
80
83
  end
84
+ handled
81
85
  end
82
86
  }
83
87
  end
Binary file
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glimmer-dsl-libui
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.1
4
+ version: 0.10.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Maleh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-10-27 00:00:00.000000000 Z
11
+ date: 2023-10-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: glimmer