Skip to content

Added Animation of a breathing border around the spawn Cell - #1962

Closed
Boostry123 wants to merge 1 commit into
openfrontio:mainfrom
Boostry123:Breathing-spawn
Closed

Boostry123 wants to merge 1 commit into
openfrontio:mainfrom
Boostry123:Breathing-spawn

Conversation

@Boostry123

Copy link
Copy Markdown
Contributor

Description:

Lost control of the previous PR (#1951) because of faulty commits , PRing again

Noticed many people are struggling to see where they choose to spawn or forget where they chose , what leads to confusion.
solved it with this animation around the spawning player cell.

483088331-938f7dc8-97cb-40d0-8222-9f8ddbc2b21f

483088982-22e157a5-301d-4d41-8f2c-21a9dd09a1f6

Please complete the following:

  • I have added screenshots for all UI updates
  • I process any text displayed to the user through translateText() and I've added it to the en.json file
  • I have added relevant tests to the test directory
  • I confirm I have thoroughly tested these changes and take full responsibility for any bugs introduced

Please put your Discord username so you can be contacted if a bug or regression is found:

boostry

@coderabbitai

coderabbitai Bot commented Aug 28, 2025 •

Copy link
Copy Markdown
Contributor

Walkthrough

Adds a per-tick breathing border animation around the focused player in TerritoryLayer, using a new internal timer. On each tick, it computes a pulsating radius, clears the highlight canvas, and draws a circular ring at the player’s name position via a new private helper.

Changes

Cohort / File(s) Summary
Territory highlight animation
src/client/graphics/layers/TerritoryLayer.ts
- Add borderAnimTime state and increment each tick
- Compute sine-based radius (≈3–8) for pulse
- Clear highlight border area and draw ring when a focused player exists
- Use theme.spawnHighlightColor for stroke
- Add private drawBreathingRing(cx, cy, radius, color) helper using highlight canvas context

Sequence Diagram(s)

sequenceDiagram
    participant GameLoop
    participant TerritoryLayer
    participant HighlightCanvas as Highlight Canvas Ctx

    GameLoop->>TerritoryLayer: tick()
    TerritoryLayer->>TerritoryLayer: increment borderAnimTime
    TerritoryLayer->>TerritoryLayer: has focused player?
    alt focused player present
        TerritoryLayer->>TerritoryLayer: compute radius = f(sin(borderAnimTime))
        TerritoryLayer->>HighlightCanvas: clear previous highlight
        TerritoryLayer->>HighlightCanvas: drawBreathingRing(cx, cy, radius, color)
        note right of HighlightCanvas: Pulsing ring rendered
    else no focus
        TerritoryLayer->>HighlightCanvas: no-op (no ring)
    end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

A ring that breathes in pixel light,
Soft pulse around the player bright.
The canvas clears, then glows once more,
A silent wave from game-time’s shore.
Tick by tick, the circle sings—
Focus found, it gently rings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbit in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbit in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbit gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbit read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbit help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbit ignore or @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbit summary or @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbit or @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (2)
src/client/graphics/layers/TerritoryLayer.ts (2)

26-26: Rename for clarity: this is a phase, not time.

borderAnimTime is a tick-based phase accumulator, not wall-clock time. Rename to ringPhase to avoid confusion. References below in the animation block should update accordingly.

-  private borderAnimTime = 0;
+  private ringPhase = 0;

598-612: Isolate canvas state and add slight alpha for a softer ring.

Save/restore avoids leaking stroke styles/width to other drawings. A small alpha looks better over the spawn mask.

   private drawBreathingRing(
     cx: number,
     cy: number,
     radius: number,
     color: Colord,
   ) {
     const ctx = this.highlightContext;
     if (!ctx) return;
-    ctx.beginPath();
-    ctx.arc(cx, cy, radius, 0, Math.PI * 2);
-    ctx.strokeStyle = color.toRgbString();
-    ctx.lineWidth = 2;
-    ctx.stroke();
+    ctx.save();
+    ctx.beginPath();
+    ctx.arc(cx, cy, radius, 0, Math.PI * 2);
+    ctx.strokeStyle = color.alpha(0.9).toRgbString();
+    ctx.lineWidth = 2;
+    ctx.stroke();
+    ctx.restore();
   }
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 81d9954 and 235651a.

📒 Files selected for processing (1)
  • src/client/graphics/layers/TerritoryLayer.ts (3 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-06-22T21:51:14.990Z
Learnt from: devalnor
PR: openfrontio/OpenFrontIO#1248
File: src/client/graphics/layers/TerritoryInfoLayer.ts:20-20
Timestamp: 2025-06-22T21:51:14.990Z
Learning: In TerritoryInfoLayer.ts, the highlightedTerritory field uses both null and undefined intentionally: undefined represents initial state or inactive layer (Ctrl released), while null represents active layer with no territory being highlighted at cursor position. This distinction is important for proper state change detection.

Applied to files:

  • src/client/graphics/layers/TerritoryLayer.ts
🧬 Code graph analysis (1)
src/client/graphics/layers/TerritoryLayer.ts (1)
src/core/game/GameView.ts (1)
  • focusedPlayer (689-692)
🔇 Additional comments (1)
src/client/graphics/layers/TerritoryLayer.ts (1)

199-227: Code around lines 180–240 requested for inspection. Once available, we’ll confirm where and how often highlightContext.clearRect runs and whether the inner clear indeed wipes out spawn highlights.

@scottanderson scottanderson left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please close this PR and reopen the other one. Opening a second PR for the same issue goes against the project's policy, because it splits up the feedback.

@github-project-automation github-project-automation Bot moved this from Triage to Development in OpenFront Release Management Aug 29, 2025
@Boostry123 Boostry123 closed this Aug 29, 2025
@github-project-automation github-project-automation Bot moved this from Development to Complete in OpenFront Release Management Aug 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Complete

Development

Successfully merging this pull request may close these issues.

2 participants