Skip to content

Commit a59ce23

Browse files
committed
fall in puddle hurt interration 1
1 parent 0714542 commit a59ce23

40 files changed

Lines changed: 5750 additions & 235 deletions

.kiro/specs/puddle-fall-damage/tasks.md

Lines changed: 127 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,108 +1,142 @@
11
# Implementation Plan
22

3-
- [ ] 1. Extend WaterPuddle with unique identifier
3+
- [x] 1. Extend WaterPuddle with unique identifier
4+
45
- Add UUID-based ID field to WaterPuddle class
56
- Generate unique ID in reset() method when puddle spawns
67
- Add getId() getter method
78
- _Requirements: 3.1, 4.1_
89

9-
- [ ] 2. Create PuddleCollisionSystem class
10-
- [ ] 2.1 Implement core collision detection logic
10+
- [x] 2. Create PuddleCollisionSystem class
11+
12+
13+
14+
15+
16+
- [x] 2.1 Implement core collision detection logic
17+
18+
1119
- Create PuddleCollisionSystem class with collision checking
1220
- Implement calculateDistance() method using Euclidean distance
1321
- Implement checkCollision() method with 12-pixel radius check
1422
- Create PuddleCollisionResult data class
1523
- _Requirements: 1.1, 3.2, 3.3_
1624

17-
- [ ] 2.2 Write property test for collision detection
25+
- [x] 2.2 Write property test for collision detection
26+
27+
1828
- **Property 1: Collision triggers fall**
1929
- **Validates: Requirements 1.1, 3.2**
2030

21-
- [ ] 2.3 Implement triggered state tracking
31+
- [x] 2.3 Implement triggered state tracking
32+
2233
- Add Set<String> for triggered puddle IDs
2334
- Implement markPuddleTriggered() method
2435
- Implement isTriggered() check in collision detection
2536
- _Requirements: 4.1, 4.2_
2637

27-
- [ ] 2.4 Write property test for triggered state prevention
38+
- [x] 2.4 Write property test for triggered state prevention
39+
40+
2841
- **Property 9: Triggered state prevents re-trigger**
2942
- **Validates: Requirements 4.1, 4.2**
3043

31-
- [ ] 2.5 Implement triggered state reset logic
44+
- [x] 2.5 Implement triggered state reset logic
45+
3246
- Add Map<String, Boolean> for player-in-zone tracking
3347
- Implement updateTriggeredStates() method
3448
- Reset triggered state when player exits zone (distance > 12)
3549
- _Requirements: 4.3_
3650

37-
- [ ] 2.6 Write property test for triggered state reset
51+
- [x] 2.6 Write property test for triggered state reset
52+
53+
3854
- **Property 10: Triggered state reset on exit**
3955
- **Validates: Requirements 4.3**
4056

41-
- [ ] 2.7 Implement cleanup methods
57+
- [x] 2.7 Implement cleanup methods
58+
4259
- Implement clearAllTriggeredStates() method
4360
- Clear both triggered set and in-zone map
4461
- _Requirements: 1.5, 3.4, 3.5, 4.4_
4562

46-
- [ ] 2.8 Write property test for cleanup
63+
- [x] 2.8 Write property test for cleanup
64+
65+
4766
- **Property 5: Cleanup on puddle despawn**
4867
- **Validates: Requirements 1.5, 3.4, 3.5, 4.4**
4968

50-
- [ ] 3. Create FallAnimationSystem class
51-
- [ ] 3.1 Implement animation state management
69+
- [x] 3. Create FallAnimationSystem class
70+
71+
72+
73+
- [x] 3.1 Implement animation state management
74+
5275
- Create FallAnimationState enum (NONE, FALL, STANDUP_1-4, COMPLETE)
5376
- Create FallAnimationFrame data class with coordinates and duration
5477
- Initialize frame sequence with correct sprite coordinates
5578
- Add animation state tracking fields
5679
- _Requirements: 2.1, 2.2, 2.3, 2.4, 2.5_
5780

58-
- [ ] 3.2 Implement animation timing logic
81+
- [x] 3.2 Implement animation timing logic
82+
5983
- Implement startFallSequence() method
6084
- Implement update() method with delta time accumulation
6185
- Advance frames every 0.8 seconds
6286
- Preserve remainder time for smooth transitions
6387
- _Requirements: 2.2, 2.3, 2.4, 2.5_
6488

65-
- [ ] 3.3 Write property test for animation timing
89+
- [x] 3.3 Write property test for animation timing
90+
6691
- **Property 6: Animation sequence timing**
6792
- **Validates: Requirements 2.2, 2.3, 2.4, 2.5**
6893

69-
- [ ] 3.4 Implement frame extraction from sprite sheet
94+
- [x] 3.4 Implement frame extraction from sprite sheet
95+
96+
7097
- Implement getCurrentFallFrame() method
7198
- Extract 64x64 TextureRegion from sprite sheet
7299
- Use coordinates based on current animation state
73100
- Handle sprite sheet from PlayerConfig
74101
- _Requirements: 2.1, 2.7, 5.1, 5.2_
75102

76-
- [ ] 3.5 Write property test for sprite sheet consistency
103+
- [x] 3.5 Write property test for sprite sheet consistency
104+
77105
- **Property 7: Sprite sheet consistency**
78106
- **Validates: Requirements 2.7, 5.3**
79107

80-
- [ ] 3.6 Write property test for frame dimensions
108+
- [x] 3.6 Write property test for frame dimensions
109+
81110
- **Property 12: Frame dimensions are correct**
82111
- **Validates: Requirements 5.1**
83112

84-
- [ ] 3.7 Implement state query methods
113+
- [x] 3.7 Implement state query methods
114+
85115
- Implement isFallSequenceActive() method
86116
- Implement isFallSequenceComplete() method
87117
- Implement reset() method
88118
- _Requirements: 1.3, 1.4_
89119

90-
- [ ] 4. Integrate collision and animation systems into Player class
91-
- [ ] 4.1 Add new fields to Player class
120+
- [x] 4. Integrate collision and animation systems into Player class
121+
122+
- [x] 4.1 Add new fields to Player class
123+
92124
- Add PuddleCollisionSystem field
93125
- Add FallAnimationSystem field
94126
- Add boolean isFalling flag
95127
- Initialize systems in constructor
96128
- _Requirements: 1.1, 1.3_
97129

98-
- [ ] 4.2 Modify Player.update() for collision detection
130+
- [x] 4.2 Modify Player.update() for collision detection
131+
99132
- Check puddle collision only when not falling
100133
- Get active puddles from PuddleManager
101134
- Call checkCollision() on collision system
102135
- Trigger fall if collision detected
103136
- _Requirements: 1.1, 3.2_
104137

105-
- [ ] 4.3 Implement triggerFall() method
138+
- [x] 4.3 Implement triggerFall() method
139+
106140
- Set isFalling flag to true
107141
- Start fall animation sequence
108142
- Mark puddle as triggered
@@ -111,155 +145,193 @@
111145
- Send health update in multiplayer
112146
- _Requirements: 1.2, 4.1_
113147

114-
- [ ] 4.4 Write property test for fall damage
148+
- [x] 4.4 Write property test for fall damage
149+
115150
- **Property 2: Fall damage is consistent**
116151
- **Validates: Requirements 1.2**
117152

118-
- [ ] 4.5 Modify Player.update() for fall animation
153+
- [x] 4.5 Modify Player.update() for fall animation
154+
119155
- Update fall animation system with delta time
120156
- Check if sequence complete and call completeFall()
121157
- Skip normal movement processing while falling
122158
- Update triggered states after normal movement
123159
- _Requirements: 1.3, 1.4, 2.2-2.5_
124160

125-
- [ ] 4.6 Write property test for movement blocking
161+
- [x] 4.6 Write property test for movement blocking
162+
126163
- **Property 3: Movement blocked during fall**
127164
- **Validates: Requirements 1.3**
128165

129-
- [ ] 4.7 Write property test for fall sequence interruption prevention
166+
- [x] 4.7 Write property test for fall sequence interruption prevention
167+
130168
- **Property 11: Fall sequence prevents interruption**
131169
- **Validates: Requirements 4.5**
132170

133-
- [ ] 4.8 Implement completeFall() method
171+
- [x] 4.8 Implement completeFall() method
172+
134173
- Set isFalling flag to false
135174
- Reset fall animation system
136175
- _Requirements: 1.4, 2.6_
137176

138-
- [ ] 4.9 Write property test for state restoration
177+
- [x] 4.9 Write property test for state restoration
178+
139179
- **Property 4: State restoration after fall**
140180
- **Validates: Requirements 1.4, 2.6**
141181

142-
- [ ] 4.10 Modify Player.getCurrentFrame() for fall rendering
182+
- [x] 4.10 Modify Player.getCurrentFrame() for fall rendering
183+
143184
- Check if falling and return fall animation frame
144185
- Otherwise return normal animation frame
145186
- _Requirements: 2.1, 5.4, 5.5_
146187

147-
- [ ] 4.11 Write property test for rendering position consistency
188+
- [x] 4.11 Write property test for rendering position consistency
189+
148190
- **Property 13: Rendering position consistency**
149191
- **Validates: Requirements 5.4**
150192

151-
- [ ] 4.12 Write property test for exclusive fall rendering
193+
- [x] 4.12 Write property test for exclusive fall rendering
194+
152195
- **Property 14: Exclusive fall rendering**
153196
- **Validates: Requirements 5.5**
154197

155-
- [ ] 5. Extend PuddleManager to expose active puddles
156-
- [ ] 5.1 Add getActivePuddles() method to PuddleManager
198+
- [x] 5. Extend PuddleManager to expose active puddles
199+
200+
- [x] 5.1 Add getActivePuddles() method to PuddleManager
201+
157202
- Iterate through puddle pool
158203
- Collect active puddles into list
159204
- Return list for collision detection
160205
- _Requirements: 1.1, 3.1_
161206

162-
- [ ] 5.2 Write property test for puddle coordinates
207+
- [x] 5.2 Write property test for puddle coordinates
208+
163209
- **Property 8: Puddle coordinates recorded**
164210
- **Validates: Requirements 3.1**
165211

166-
- [ ] 5.3 Modify PuddleManager cleanup to notify collision system
212+
- [x] 5.3 Modify PuddleManager cleanup to notify collision system
213+
167214
- Call clearAllTriggeredStates() when clearing puddles
168215
- Call clearAllTriggeredStates() on state transition to NONE
169216
- Pass collision system reference to manager
170217
- _Requirements: 1.5, 3.4, 3.5, 4.4_
171218

172-
- [ ] 6. Add error handling and validation
173-
- [ ] 6.1 Add position validation in collision detection
219+
- [x] 6. Add error handling and validation
220+
221+
- [x] 6.1 Add position validation in collision detection
222+
174223
- Check for NaN and Infinity in player/puddle positions
175224
- Log warning and skip invalid positions
176225
- Return no collision for invalid data
177226
- _Error Handling: Collision Detection Errors_
178227

179-
- [ ] 6.2 Add null checks for puddle list
228+
- [x] 6.2 Add null checks for puddle list
229+
180230
- Check for null/empty puddle list before iteration
181231
- Return no collision result for null list
182232
- _Error Handling: Collision Detection Errors_
183233

184-
- [ ] 6.3 Add sprite sheet error handling
234+
- [x] 6.3 Add sprite sheet error handling
235+
185236
- Catch texture loading exceptions in FallAnimationSystem
186237
- Fall back to default sprite sheet on error
187238
- Log error for debugging
188239
- _Error Handling: Animation System Errors_
189240

190-
- [ ] 6.4 Add animation timeout protection
241+
- [x] 6.4 Add animation timeout protection
242+
191243
- Implement 5-second maximum duration for fall sequence
192244
- Force completion if timeout reached
193245
- Reset fall state to prevent stuck player
194246
- Log warning for debugging
195247
- _Error Handling: State Management Errors_
196248

197-
- [ ] 6.5 Add triggered set size limit
249+
- [x] 6.5 Add triggered set size limit
250+
198251
- Implement maximum size limit for triggered puddle set
199252
- Remove oldest entries if limit exceeded
200253
- Clear on puddle count changes
201254
- _Error Handling: State Management Errors_
202255

203-
- [ ] 7. Checkpoint - Ensure all tests pass
256+
- [x] 7. Checkpoint - Ensure all tests pass
257+
204258
- Ensure all tests pass, ask the user if questions arise.
205259

206-
- [ ] 8. Add multiplayer synchronization
207-
- [ ] 8.1 Create PlayerFallMessage network message
260+
- [x] 8. Add multiplayer synchronization
261+
262+
- [x] 8.1 Create PlayerFallMessage network message
263+
264+
208265
- Add message class with player ID and puddle ID
209266
- Register message type in network system
210267
- _Multiplayer Considerations_
211268

212-
- [ ] 8.2 Implement client-side fall event sending
269+
- [x] 8.2 Implement client-side fall event sending
270+
271+
213272
- Send PlayerFallMessage to server on fall trigger
214273
- Include puddle ID for validation
215274
- _Multiplayer Considerations_
216275

217-
- [ ] 8.3 Implement server-side fall validation
276+
- [x] 8.3 Implement server-side fall validation
277+
278+
218279
- Validate puddle exists and player position
219280
- Broadcast fall event to all clients
220281
- _Multiplayer Considerations_
221282

222-
- [ ] 8.4 Implement remote player fall animation
283+
- [x] 8.4 Implement remote player fall animation
284+
285+
223286
- Receive fall event for remote players
224287
- Trigger fall animation on remote player instances
225288
- _Multiplayer Considerations_
226289

227-
- [ ] 9. Add integration tests
228-
- [ ] 9.1 Write puddle-player integration test
290+
- [x] 9. Add integration tests
291+
292+
- [x] 9.1 Write puddle-player integration test
293+
229294
- Spawn puddles in test environment
230295
- Move player through puddles
231296
- Verify fall triggers and damage applies
232297
- Verify animation plays and completes
233298
- _Integration Testing_
234299

235-
- [ ] 9.2 Write animation-rendering integration test
300+
- [x] 9.2 Write animation-rendering integration test
301+
302+
236303
- Trigger fall sequence
237304
- Capture rendered frames at each time step
238305
- Verify correct sprite coordinates
239306
- Verify timing between frames
240307
- _Integration Testing_
241308

242-
- [ ] 9.3 Write cleanup integration test
309+
- [x] 9.3 Write cleanup integration test
310+
243311
- Create puddles and trigger falls
244312
- Transition puddle system to NONE
245313
- Verify all collision data cleared
246314
- Check for memory leaks
247315
- _Integration Testing_
248316

249-
- [ ] 10. Add performance tests
250-
- [ ] 10.1 Write collision detection performance test
317+
- [x] 10. Add performance tests
318+
319+
- [x] 10.1 Write collision detection performance test
320+
251321
- Test with maximum puddle count (8)
252322
- Measure collision check time per frame
253323
- Verify < 1ms per frame target
254324
- _Performance Testing_
255325

256-
- [ ] 10.2 Write animation system performance test
326+
- [x] 10.2 Write animation system performance test
327+
257328
- Test fall sequence with multiple players
258329
- Measure frame extraction and rendering time
259330
- Verify no frame rate impact
260331
- _Performance Testing_
261332

262-
- [ ] 10.3 Write memory usage test
333+
- [x] 10.3 Write memory usage test
334+
263335
- Monitor triggered puddle set size over time
264336
- Verify cleanup occurs properly
265337
- Verify no memory growth
File renamed without changes.

0 commit comments

Comments
 (0)