chichilku3 5.0.1 → 14.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,115 @@
1
+ require_relative 'console'
2
+
3
+ class Projectile
4
+ attr_accessor :x, :y, :dx, :dy, :r, :w, :h, :owner_id
5
+
6
+ def initialize
7
+ @x = 0
8
+ @y = 0
9
+ @dx = 0
10
+ @dy = 0
11
+ @w = 16
12
+ @h = 16
13
+ @owner = nil
14
+ @left_owner = false
15
+ @flying = false
16
+ @tick = 0
17
+ end
18
+
19
+ def fire(x, y, dx, dy, owner)
20
+ return if @flying
21
+
22
+ @x = x
23
+ @y = y
24
+ @dx = dx
25
+ @dy = dy
26
+ calc_rotation()
27
+ @owner = owner
28
+ @left_owner = false
29
+ @flying = true
30
+ $console.dbg "Projectile(x=#{x}, y=#{y}, dx=#{dx}, dy=#{dy})"
31
+ end
32
+
33
+ def hit
34
+ @flying = false
35
+ @x = 0
36
+ @y = 0
37
+ end
38
+
39
+ def tick(players)
40
+ return unless @flying
41
+
42
+ @tick += 1
43
+ @x = @x + @dx
44
+ @y = @y + @dy
45
+ @dy += 1 if @tick % 3 == 0
46
+ calc_rotation()
47
+ check_hit(players)
48
+ hit if @y > WINDOW_SIZE_Y
49
+ hit if @x > WINDOW_SIZE_X
50
+ hit if @x < 0
51
+ end
52
+
53
+ def check_hit(players)
54
+ owner_hit = false
55
+ players.each do |player|
56
+ if player.x + player.w > @x && player.x < @x + @w
57
+ if player.y + player.h > @y && player.y < @y + @h
58
+ if @owner.id == player.id
59
+ owner_hit = true
60
+ if @left_owner
61
+ player.damage(@owner)
62
+ hit()
63
+ end
64
+ else
65
+ player.damage(@owner)
66
+ hit()
67
+ end
68
+ end
69
+ end
70
+ end
71
+ if owner_hit == false
72
+ @left_owner = true
73
+ end
74
+ end
75
+
76
+ # NETWORK ROTATION
77
+ # 0 -> 4 <-
78
+
79
+ # ^
80
+ # 1 \ 5 \
81
+ # v
82
+
83
+ # ^
84
+ # 2 | 6 |
85
+ # v
86
+
87
+ # ^
88
+ # 3 / 7 /
89
+ # v
90
+ def calc_rotation
91
+ if @dy > -3 && @dy < 3
92
+ if @dx < 0
93
+ @r = 4
94
+ else
95
+ @r = 0
96
+ end
97
+ elsif @dy < 0
98
+ if @dx > -3 && @dx < 3
99
+ @r = 6
100
+ elsif @dx < 0
101
+ @r = 5
102
+ else
103
+ @r = 7
104
+ end
105
+ else
106
+ if @dx > -3 && @dx < 3
107
+ @r = 2
108
+ elsif @dx < 0
109
+ @r = 3
110
+ else
111
+ @r = 1
112
+ end
113
+ end
114
+ end
115
+ end
metadata CHANGED
@@ -1,17 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chichilku3
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.0.1
4
+ version: 14.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ChillerDragon
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-04-15 00:00:00.000000000 Z
11
+ date: 2020-06-29 00:00:00.000000000 Z
12
12
  dependencies: []
13
- description: Simple 2d multiplayer stick figure battle game using the gosu (SDL2 based)
14
- gem for client side graphics. The network protocol is tcp based.
13
+ description: Simple 2d online multiplayer stick figure battle game using the gosu
14
+ (SDL2 based) gem for client side graphics. The network protocol is tcp based and
15
+ only using ASCII printable characters.
15
16
  email: ChillerDragon@gmail.com
16
17
  executables:
17
18
  - chichilku3
@@ -26,9 +27,15 @@ files:
26
27
  - lib/client/client.rb
27
28
  - lib/client/client_cfg.rb
28
29
  - lib/client/gui.rb
30
+ - lib/client/img/arrow64.png
29
31
  - lib/client/img/background1024x512.png
30
32
  - lib/client/img/battle1024x576.png
33
+ - lib/client/img/bow64/bow0.png
34
+ - lib/client/img/bow64/bow1.png
35
+ - lib/client/img/bow64/bow2.png
36
+ - lib/client/img/bow64/bow3.png
31
37
  - lib/client/img/connecting1024x512.png
38
+ - lib/client/img/crosshair128x128.png
32
39
  - lib/client/img/grass1024x512.png
33
40
  - lib/client/img/grey128.png
34
41
  - lib/client/img/menu1920x1080.png
@@ -44,6 +51,7 @@ files:
44
51
  - lib/client/img/stick128/stick_crouching3.png
45
52
  - lib/client/img/stick128/stick_crouching4.png
46
53
  - lib/client/img/stick128/stick_crouching5.png
54
+ - lib/client/img/stick128/stick_noarms.png
47
55
  - lib/client/scoreboard.rb
48
56
  - lib/client/test.rb
49
57
  - lib/client/text.rb
@@ -54,6 +62,7 @@ files:
54
62
  - lib/share/console.rb
55
63
  - lib/share/network.rb
56
64
  - lib/share/player.rb
65
+ - lib/share/projectile.rb
57
66
  - server.json
58
67
  homepage: https://github.com/chichilku/chichilku3
59
68
  licenses: