chichilku3 5.0.0 → 14.0.4

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,74 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chichilku3
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.0.0
4
+ version: 14.0.4
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
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.
11
+ date: 2020-07-03 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: gosu
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.15.2
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 0.15.2
27
+ - !ruby/object:Gem::Dependency
28
+ name: os
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 1.0.1
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 1.0.1
41
+ - !ruby/object:Gem::Dependency
42
+ name: fileutils
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 1.2.0
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 1.2.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 3.9.0
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 3.9.0
69
+ description: Simple 2d online multiplayer stick figure battle game using the gosu
70
+ (SDL2 based) gem for client side graphics. The network protocol is tcp based and
71
+ only using ASCII printable characters.
15
72
  email: ChillerDragon@gmail.com
16
73
  executables:
17
74
  - chichilku3
@@ -26,12 +83,22 @@ files:
26
83
  - lib/client/client.rb
27
84
  - lib/client/client_cfg.rb
28
85
  - lib/client/gui.rb
86
+ - lib/client/img/arrow64.png
29
87
  - lib/client/img/background1024x512.png
30
88
  - lib/client/img/battle1024x576.png
89
+ - lib/client/img/bow64/bow0.png
90
+ - lib/client/img/bow64/bow1.png
91
+ - lib/client/img/bow64/bow2.png
92
+ - lib/client/img/bow64/bow3.png
31
93
  - lib/client/img/connecting1024x512.png
94
+ - lib/client/img/crosshair128x128.png
32
95
  - lib/client/img/grass1024x512.png
33
96
  - lib/client/img/grey128.png
34
97
  - lib/client/img/menu1920x1080.png
98
+ - lib/client/img/stick128/arm64/arm0.png
99
+ - lib/client/img/stick128/arm64/arm1.png
100
+ - lib/client/img/stick128/arm64/arm2.png
101
+ - lib/client/img/stick128/arm64/arm3.png
35
102
  - lib/client/img/stick128/stick0.png
36
103
  - lib/client/img/stick128/stick1.png
37
104
  - lib/client/img/stick128/stick2.png
@@ -44,6 +111,7 @@ files:
44
111
  - lib/client/img/stick128/stick_crouching3.png
45
112
  - lib/client/img/stick128/stick_crouching4.png
46
113
  - lib/client/img/stick128/stick_crouching5.png
114
+ - lib/client/img/stick128/stick_noarms.png
47
115
  - lib/client/scoreboard.rb
48
116
  - lib/client/test.rb
49
117
  - lib/client/text.rb
@@ -54,6 +122,7 @@ files:
54
122
  - lib/share/console.rb
55
123
  - lib/share/network.rb
56
124
  - lib/share/player.rb
125
+ - lib/share/projectile.rb
57
126
  - server.json
58
127
  homepage: https://github.com/chichilku/chichilku3
59
128
  licenses: