Skip to content

About

This is a web version of Attack-Disk that can be used in UBOAT game.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

9 Commits

Folders and files

Repository files navigation

WW2 Attack Disk (Web Simulator)

Dependency-free, touch-first web app that simulates a WW2 submarine attack disk as a tactile instrument on phone/tablet (also works with mouse on desktop).

The app runs fully client-side: no backend, no network APIs, no external libraries.

Features

  • Fullscreen responsive disk UI with stacked PNG layers.
  • Two sides in one page, with corner flip buttons:
    • Side 1 (switch_time.png) -> angle side.
    • Side 2 (switch_angle.png) -> time/aux side.
  • Pointer Events rotation (pointerdown/move/up/cancel) with pointer capture.
  • Ring selection by radial bands + custom grab zones for asymmetric/sector sprites.
  • Ring lock toggles:
    • Side 1 outer lock: ON by default.
    • Side 1 middle lock: OFF by default.
    • Side 2 outer lock: ON by default.
  • Snap on release (OFF by default, 1 deg or 5 deg).
  • Per-side reset.
  • LocalStorage persistence for angles and settings.
  • Optional PWA shell (manifest.json, service-worker.js) for install/offline basics.

Current Asset Mapping

All textures are loaded directly from resources/Sprite/.

Side 1

  • Outer: 1-PeilungRad_reworked.png
  • Middle: 2-KursRad_reworked.png
  • Inner: 3-LageRad_reworked_with_arrow.png
  • Marker ring: 5-Arrow_reworked.png
  • Cursor/sector ring: 4-Arrow_reworked.png

Side 2

  • Outer: 5-Back-LageRad_reworked.png
  • Middle: 6-Rueck-Strecke.png
  • Inner: 7-Rueck-Zeit.png
  • Cursor ring: Klammer_reworked_with_arrow.png

Side Switch Buttons

  • To side 2: switch_time.png
  • To side 1: switch_angle.png

Run Locally

  1. From project root:
python3 -m http.server 8000
  1. Open on desktop:

http://localhost:8000

  1. Open on phone/tablet (same LAN):

http://<your-computer-lan-ip>:8000

Use HTTP/HTTPS (not file://) so service worker and pointer behavior are consistent.

Controls

  • Drag directly on a ring (or its configured grab sector) to rotate.
  • Use lock checkboxes to freeze selected rings.
  • Reset resets only the currently visible side.
  • Enable Snap to quantize ring angle on release.
  • Tap corner switch button to change side.

Angle Outputs and Logic

UI labels are currently in Ukrainian.

Side 1 readouts

  • Пеленг = outer
  • Курс = outer - middle
  • Курс Цілі = inner - middle
  • Пеленг Цілі = cursor - outer + 180
  • Курс Перехоплення = marker - middle

All values are normalized to 0..360 for display.

AOB

  • AOB is derived from side 1 state and shown as signed value with side:
    • Port for negative
    • Starboard for positive
    • Ahead for zero

Formula:

AOB = normalizeSigned180(cursorAngle - innerAngle - 180)

where:

  • innerAngle = normalize360(inner - middle)
  • cursorAngle = normalize360(cursor - outer + 180)

Side 2 cursor scale output

Кут маркера is computed from relative dial rotation using fitted sine/log mapping:

  • relativeDialDeg = normalize360(side2.cursor - side2.outer)
  • sinScale = 10^(relativeDialDeg / 360 - 1)
  • scaleDeg = asin(clamp(sinScale, 0..1))

Side switching behavior

  • Side 1 -> Side 2:
    • Uses AOB, wraps to acute 0..90, converts via inverse mapping, and sets side 2 inner ring.
  • Side 2 -> Side 1:
    • Uses side 2 cursor scale as lead angle and updates side 1 marker ring (intercept course readout).

Project Structure

.
├── index.html
├── styles.css
├── app.js
├── manifest.json
├── service-worker.js
└── resources/
    └── Sprite/
        └── *.png

Tuning Notes

If you need pixel-perfect alignment for updated sprites:

  • Ring hit bands and custom grab zones: sideConfig in app.js
  • Intrinsic sprite dimensions and relative sizing: layerDimensions / layerAdjustments in app.js
  • Flip button placement: DEFAULT_FLIP_RADIUS_PCT, DEFAULT_FLIP_ANGLE_DEG in app.js and CSS vars in #disk-stage
  • Asymmetric pivots and transforms: specific layer rules in styles.css (#layer-inner, #layer-cursor, #layer-back-middle, #layer-back-inner, #layer-back-cursor)

Browser Support

  • Mobile: Safari, Chrome (touch/pen)
  • Desktop: Chrome, Firefox (mouse)

Notes

  • This project is intentionally dependency-free.
  • State is persisted in LocalStorage under attackDisk.* keys.

About

This is a web version of Attack-Disk that can be used in UBOAT game.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages