voxelamming 0.3.2 → 0.3.7

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: 653a6e648abd3cae2bb721b8e39c0ff46f96f9c605d9724463294c0e5c174540
4
- data.tar.gz: 440c68675c73e5a6e4a957c19322653fcd7be6431c1ca8dcafcf11d6723c23e2
3
+ metadata.gz: 5a0cafac62266bced6de5a7489b57f65ce968a3758121e4179267192607cdcb7
4
+ data.tar.gz: ec9e456649b8a4d678ec328f7000050fb3c17ec47ecded609e47fb1e77016392
5
5
  SHA512:
6
- metadata.gz: 637d500db8f2847b4c91b0ee1c6c0fe9f363f20ab562afcc9f18566bf5968c55b6d4838734895ce8ce728756d8451ffe79e95c622c639496d83d35626f7f43d6
7
- data.tar.gz: 60c6b83b10b434266e854999a2bb276f7a27b669536af70a48333a43ac2db7e4dceeb3fd750cbdbeeae78c58d0651d1134409ac1857b815c5c68fbe91f3397a1
6
+ metadata.gz: 866ab0795c3626c9d6e830c4f0cf40c6c546b8e6f3e3c5c0636965af9e25c43742ef90d4e62f481d8b524a2f0d68e29d1581b90c32bcb06b7d15d65dc3db95fe
7
+ data.tar.gz: '0276639399de789d7506011c822dcea75ffab08e5c28a5c7a687c5cdc8aa272bdf208b64df4e65b531f929c7f7f40ad48aeae6627d21f9b3b1c8c81de3bc730d'
data/CHANGELOG.md ADDED
@@ -0,0 +1,26 @@
1
+ ## VoxelammingGem Change log
2
+
3
+ ### ver. 0.1.0
4
+
5
+ - first release
6
+
7
+ ### ver. 0.1.1
8
+
9
+ - Map and ply file paths changed to be specified as relative paths.
10
+ - a few bug fixes
11
+
12
+ ### ver. 0.1.2
13
+
14
+ - Changed so that the size of the map can be specified.
15
+
16
+ ### ver. 0.2.0
17
+
18
+ - History can be saved.
19
+
20
+ ### ver. 0.3.0
21
+
22
+ - Game mode implemented.
23
+
24
+ ### ver. 0.3.2
25
+
26
+ - a few bug fixes
data/README.md CHANGED
@@ -77,7 +77,7 @@ This code snippet demonstrates a simple example where a red voxel is created at
77
77
  | `set_frame_repeats(repeats)` | Sets the number of frame repetitions (default: 10). | `repeats`: Number of repetitions (int) |
78
78
  | Game Method Name | Description | Arguments |
79
79
  | `set_game_screen(width, height, angle=90, r=1, g=1, b=0, alpha=0.5)` | Sets the game screen size. | `width`, `height`: screen size (float), `angle`: angle (float), `r`, `g`, `b`, `alpha`: color (float, 0-1) |
80
- | `set_game_score(score)` | Sets the game score. | `score`: game score (int) |
80
+ | `set_game_score(score, x=0, y=0)` | Sets the game score. | `score`: game score (int), `x`, `y`: position (float) |
81
81
  | `send_game_over()` | Triggers game over. | |
82
82
  | `create_sprite(sprite_name, color_list, x, y, direction=90, scale=1, visible=True)` | Creates a sprite. | `sprite_name`: sprite name (string), `color_list`: dot color data (string), `x`, `y`: position (float), `direction`: angle (float), `scale`: scale (float), `visible`: visibility (boolean) |
83
83
  | `move_sprite(sprite_name, x, y, direction=90, scale=1, visible=True)` | Moves a sprite. | `sprite_name`: sprite name (string), `x`, `y`: position (float), `direction`: angle (float), `scale`: scale (float), `visible`: visibility (boolean) |
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Voxelamming
4
- VERSION = "0.3.2"
4
+ VERSION = "0.3.7"
5
5
  end
data/lib/voxelamming.rb CHANGED
@@ -40,7 +40,7 @@ module Voxelamming
40
40
  @model_moves = []
41
41
  @sprites = []
42
42
  @sprite_moves = []
43
- @game_score = -1
43
+ @game_score = []
44
44
  @game_screen = [] # width, height, angle=90, red=1, green=1, blue=1, alpha=0.5
45
45
  @size = 1
46
46
  @shape = 'box'
@@ -68,7 +68,7 @@ module Voxelamming
68
68
  @sentences = []
69
69
  @sprites = []
70
70
  @sprite_moves = []
71
- @game_score = -1
71
+ @game_score = []
72
72
  @game_screen = [] # width, height, angle=90, red=1, green=1, blue=1, alpha=0.5
73
73
  @lights = []
74
74
  @commands = []
@@ -325,58 +325,120 @@ module Voxelamming
325
325
  @game_screen = [width, height, angle, r, g, b, alpha]
326
326
  end
327
327
 
328
- def set_game_score(score)
329
- @game_score = score.to_f
328
+ def set_game_score(score, x = 0, y = 0)
329
+ score, x, y = [score, x, y].map(&:to_f)
330
+ @game_score = [score, x, y]
330
331
  end
331
332
 
332
333
  def send_game_over
333
334
  @commands << 'gameOver'
334
335
  end
335
336
 
337
+ def send_game_clear
338
+ @commands << 'gameClear'
339
+ end
340
+
336
341
  def set_rotation_style(sprite_name, rotation_style = 'all around')
337
342
  @rotation_styles[sprite_name] = rotation_style
338
343
  end
339
344
 
340
- def create_sprite(sprite_name, color_list, x, y, direction = 0, scale = 1, visible = true)
341
- # 新しいスプライトデータを配列に追加
342
- x, y, direction = round_numbers([x, y, direction])
343
- x, y, direction, scale = [x, y, direction, scale].map(&:to_s)
344
- @sprites << [sprite_name, color_list, x, y, direction, scale, visible ? '1' : '0']
345
+ # スプライトの作成と表示について、テンプレートとクローンの概念を導入する
346
+ # テンプレートはボクセルの集合で、標準サイズは8x8に設定する
347
+ # この概念により、スプライトの複数作成が可能となる(敵キャラや球など)
348
+ # スプライトは、ボクセラミングアプリ上で、テンプレートとして作成される(isEnable=falseにより表示されない)
349
+ # スプライトは、テンプレートのクローンとして画面上に表示される
350
+ # 送信ごとに、クローンはすべて削除されて、新しいクローンが作成される
351
+ # 上記の仕様により、テンプレートからスプライトを複数作成できる
352
+
353
+ # スプライトのテンプレートを作成(スプライトは配置されない)
354
+ def create_sprite_template(sprite_name, color_list)
355
+ @sprites << [sprite_name, color_list]
345
356
  end
346
357
 
347
- def move_sprite(sprite_name, x, y, direction = 0, scale = 1, visible = true)
358
+ # スプライトのテンプレートを使って、複数のスプライトを表示する
359
+ def display_sprite_template(sprite_name, x, y, direction = 0, scale = 1)
348
360
  # x, y, directionを丸める
349
361
  x, y, direction = round_numbers([x, y, direction])
350
362
  x, y, direction, scale = [x, y, direction, scale].map(&:to_s)
351
363
 
352
364
  # rotation_styleを取得
353
- if @rotation_styles.has_key?(sprite_name)
365
+ if @rotation_styles[sprite_name]
354
366
  rotation_style = @rotation_styles[sprite_name]
355
367
 
356
368
  # rotation_styleが変更された場合、新しいスプライトデータを配列に追加
357
- case rotation_style
358
- when 'left-right'
359
- direction_mod = direction.to_i % 360 # 常に0から359の範囲で処理(常に正の数になる)
369
+ if rotation_style == 'left-right'
370
+ direction_mod = direction.to_i % 360 # 常に0から359の範囲で処理(常に正の数になる)
360
371
  if direction_mod > 90 && direction_mod < 270
361
- direction = '-180' # -180は左右反転するようにボクセラミング側で実装されている
372
+ direction = "-180" # -180は左右反転するようにボクセラミング側で実装されている
362
373
  else
363
- direction = '0'
374
+ direction = "0"
364
375
  end
365
- when "don't rotate"
366
- direction = '0'
376
+ elsif rotation_style == "don't rotate"
377
+ direction = "0"
367
378
  else
368
379
  direction = direction.to_s
369
380
  end
370
381
  else
371
- # rotation_styleが設定されていない場合、そのままの値を使う
372
382
  direction = direction.to_s
373
383
  end
374
384
 
375
- # sprites配列から同じスプライト名の要素を削除
376
- @sprite_moves.reject! { |sprite_info| sprite_info[0] == sprite_name }
385
+ # sprite_moves 配列から指定されたスプライト名の情報を検索
386
+ matching_sprites = @sprite_moves.select { |info| info[0] == sprite_name }
387
+
388
+ # スプライトの移動データを保存または更新
389
+ if matching_sprites.empty?
390
+ @sprite_moves.push([sprite_name, x, y, direction, scale])
391
+ else
392
+ index = @sprite_moves.index(matching_sprites[0])
393
+ @sprite_moves[index] += [x, y, direction, scale]
394
+ end
395
+ end
396
+
397
+ # 通常のスプライトの作成
398
+ def create_sprite(sprite_name, color_list, x = 0, y = 0, direction = 0, scale = 1, visible = true)
399
+ # スプライトのテンプレートデータを配列に追加
400
+ create_sprite_template(sprite_name, color_list)
401
+
402
+ # スプライトの移動データを配列に追加
403
+ if visible || !(x == 0 && y == 0 && direction == 0 && scale == 1)
404
+ x, y, direction = round_numbers([x, y, direction])
405
+ x, y, direction, scale = [x, y, direction, scale].map(&:to_s)
406
+ @sprite_moves.push([sprite_name, x, y, direction, scale])
407
+ end
408
+ end
409
+
410
+ # 通常のスプライトの移動
411
+ def move_sprite(sprite_name, x, y, direction = 0, scale = 1, visible = true)
412
+ if visible
413
+ display_sprite_template(sprite_name, x, y, direction, scale)
414
+ end
415
+ end
416
+
417
+ # スプライトクローンの移動
418
+ def move_sprite_clone(sprite_name, x, y, direction = 0, scale = 1)
419
+ display_sprite_template(sprite_name, x, y, direction, scale)
420
+ end
421
+
422
+ # ドット(弾)を表示する
423
+ def display_dot(x, y, direction = 0, color_id = 10, width = 1, height = 1)
424
+ template_name = "dot_#{color_id}_#{width}_#{height}"
425
+ display_sprite_template(template_name, x, y, direction, 1)
426
+ end
427
+
428
+ # テキストを表示する
429
+ def display_text(text, x, y, direction = 0, scale = 1, color_id = 7, is_vertical = false, align = '')
430
+ text_format = ''
431
+ align = align.downcase # 破壊的メソッドの代わりに非破壊的メソッドを使用
432
+
433
+ text_format += 't' if align.include?('top')
434
+ text_format += 'b' if align.include?('bottom')
435
+ text_format += 'l' if align.include?('left')
436
+ text_format += 'r' if align.include?('right')
437
+
438
+ text_format += is_vertical ? 'v' : 'h'
377
439
 
378
- # 新しいスプライトデータを配列に追加
379
- @sprite_moves << [sprite_name, x, y, direction, scale, visible ? '1' : '0']
440
+ template_name = "text_#{text}_#{color_id}_#{text_format}"
441
+ display_sprite_template(template_name, x, y, direction, scale)
380
442
  end
381
443
 
382
444
  def send_data(name: '')
Binary file
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: voxelamming
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - creativival
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-08-27 00:00:00.000000000 Z
11
+ date: 2024-10-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faye-websocket
@@ -33,6 +33,7 @@ executables: []
33
33
  extensions: []
34
34
  extra_rdoc_files: []
35
35
  files:
36
+ - CHANGELOG.md
36
37
  - CODE_OF_CONDUCT.md
37
38
  - LICENSE.txt
38
39
  - README.md
@@ -45,6 +46,7 @@ files:
45
46
  - voxelamming-0.2.0.gem
46
47
  - voxelamming-0.3.0.gem
47
48
  - voxelamming-0.3.1.gem
49
+ - voxelamming-0.3.2.gem
48
50
  homepage: https://creativival.github.io/voxelamming
49
51
  licenses:
50
52
  - MIT