@hytopia.com/examples 1.0.17 → 1.0.18

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.
@@ -93,6 +93,20 @@
93
93
  <div class="hud-crosshair-vertical"></div>
94
94
  </div>
95
95
 
96
+ <!-- Mobile Control Buttons -->
97
+ <button class="hud-mobile-button" id="hud-attack-btn">
98
+ <img src="{{CDN_ASSETS_URL}}/icons/skills/combat.png" alt="Attack" class="hud-mobile-button-icon">
99
+ </button>
100
+ <button class="hud-mobile-button" id="hud-dodge-btn">
101
+ <img src="{{CDN_ASSETS_URL}}/icons/skills/agility.png" alt="Dodge" class="hud-mobile-button-icon">
102
+ </button>
103
+ <button class="hud-mobile-button" id="hud-jump-btn">
104
+ <img src="{{CDN_ASSETS_URL}}/icons/buttons/jump.png" alt="Jump" class="hud-mobile-button-icon">
105
+ </button>
106
+ <button class="hud-mobile-button" id="hud-interact-btn">
107
+ <img src="{{CDN_ASSETS_URL}}/icons/buttons/e-mobile.png" alt="Interact" class="hud-mobile-button-icon">
108
+ </button>
109
+
96
110
  <!-- Hotbar -->
97
111
  <div class="hud-hotbar-container">
98
112
  <div class="hud-hotbar-grid">
@@ -224,6 +238,17 @@
224
238
 
225
239
  // Setup death overlay respawn button
226
240
  document.getElementById('hud-death-respawn-btn').addEventListener('click', handleRespawn);
241
+
242
+ // Setup mobile buttons
243
+ document.getElementById('hud-attack-btn').addEventListener('touchstart', handleAttackTap);
244
+ document.getElementById('hud-attack-btn').addEventListener('touchend', stopAutoAttack);
245
+ document.getElementById('hud-attack-btn').addEventListener('touchcancel', stopAutoAttack);
246
+ document.getElementById('hud-dodge-btn').addEventListener('touchstart', () => hytopia.pressInput('q', true));
247
+ document.getElementById('hud-dodge-btn').addEventListener('touchend', () => hytopia.pressInput('q', false));
248
+ document.getElementById('hud-jump-btn').addEventListener('touchstart', () => hytopia.pressInput('sp', true));
249
+ document.getElementById('hud-jump-btn').addEventListener('touchend', () => hytopia.pressInput('sp', false));
250
+ document.getElementById('hud-interact-btn').addEventListener('touchstart', () => hytopia.pressInput('e', true));
251
+ document.getElementById('hud-interact-btn').addEventListener('touchend', () => hytopia.pressInput('e', false));
227
252
  }
228
253
 
229
254
  function updateHudQuestCount(activeCount, completedCount) {
@@ -482,6 +507,49 @@
482
507
  }
483
508
  }
484
509
 
510
+ // Auto-attack system
511
+ let autoAttackInterval = null;
512
+ let lastTapTime = 0;
513
+
514
+
515
+ function handleAttackTap() {
516
+ const currentTime = Date.now();
517
+
518
+ // Double tap detected (within 300ms)
519
+ if (currentTime - lastTapTime < 300 && lastTapTime > 0) {
520
+ stopAutoAttack();
521
+ hytopia.pressInput('mr', true);
522
+ setTimeout(() => hytopia.pressInput('mr', false), 100);
523
+ lastTapTime = 0;
524
+ return;
525
+ }
526
+
527
+ // Single tap - start auto attack
528
+ lastTapTime = currentTime;
529
+ startAutoAttack();
530
+ }
531
+
532
+ function startAutoAttack() {
533
+ if (autoAttackInterval) return;
534
+
535
+ // Immediate first attack
536
+ hytopia.pressInput('ml', true);
537
+ setTimeout(() => hytopia.pressInput('ml', false), 100);
538
+
539
+ // Repeat every 500ms
540
+ autoAttackInterval = setInterval(() => {
541
+ hytopia.pressInput('ml', true);
542
+ setTimeout(() => hytopia.pressInput('ml', false), 100);
543
+ }, 500);
544
+ }
545
+
546
+ function stopAutoAttack() {
547
+ if (autoAttackInterval) {
548
+ clearInterval(autoAttackInterval);
549
+ autoAttackInterval = null;
550
+ }
551
+ }
552
+
485
553
  // Initialize HUD
486
554
  initializeHUD();
487
555
 
@@ -1407,181 +1475,312 @@
1407
1475
  }
1408
1476
  }
1409
1477
 
1478
+ /* ============================================
1479
+ MOBILE CONTROL BUTTONS
1480
+ ============================================ */
1481
+
1482
+ .hud-mobile-button {
1483
+ width: 50px;
1484
+ height: 50px;
1485
+ background: linear-gradient(145deg, var(--hud-primary), var(--hud-secondary));
1486
+ border: 2px solid var(--hud-border);
1487
+ border-radius: 50%;
1488
+ display: none;
1489
+ align-items: center;
1490
+ justify-content: center;
1491
+ padding: 0;
1492
+ position: absolute;
1493
+ overflow: hidden;
1494
+ transition: all var(--hud-transition);
1495
+ box-shadow: var(--hud-box-shadow), var(--hud-inset-shadow);
1496
+ pointer-events: auto;
1497
+
1498
+ /* Mobile optimizations */
1499
+ -webkit-tap-highlight-color: transparent;
1500
+ -webkit-touch-callout: none;
1501
+ user-select: none;
1502
+ outline: none;
1503
+ }
1504
+
1505
+ /* Individual button positioning */
1506
+ #hud-attack-btn {
1507
+ bottom: 50px;
1508
+ right: 70px;
1509
+ height: 70px;
1510
+ width: 70px;
1511
+ }
1512
+
1513
+ #hud-dodge-btn {
1514
+ bottom: 50px;
1515
+ right: 155px;
1516
+ }
1517
+
1518
+ #hud-jump-btn {
1519
+ bottom: 130px;
1520
+ right: 50px;
1521
+ }
1522
+
1523
+ #hud-interact-btn {
1524
+ bottom: 120px;
1525
+ right: 130px;
1526
+ }
1527
+
1528
+ .hud-mobile-button:active {
1529
+ transform: scale(0.95);
1530
+ box-shadow: var(--hud-box-shadow);
1531
+ }
1532
+
1533
+ .hud-mobile-button-icon {
1534
+ width: 100%;
1535
+ height: 100%;
1536
+ border-radius: 50%;
1537
+ object-fit: contain;
1538
+ opacity: 0.85;
1539
+ transition: opacity var(--hud-transition);
1540
+ filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.8));
1541
+ }
1542
+
1543
+ .hud-mobile-button:active .hud-mobile-button-icon {
1544
+ opacity: 1;
1545
+ }
1546
+
1547
+
1548
+
1410
1549
  /* ============================================
1411
1550
  MOBILE RESPONSIVE
1412
1551
  ============================================ */
1413
1552
 
1414
- @media (max-width: 768px) {
1415
- :root {
1416
- --hud-hotbar-size: 40px;
1417
- --hud-bar-height: 16px;
1418
- --hud-bar-width: 180px;
1419
- --hud-hotbar-gap: 6px;
1420
- --hud-status-gap: 3px;
1421
- --hud-clock-size: 12px;
1422
- }
1553
+ body.mobile {
1554
+ --hud-hotbar-size: 44px;
1555
+ --hud-bar-height: 16px;
1556
+ --hud-bar-width: 160px;
1557
+ --hud-hotbar-gap: 5px;
1558
+ --hud-status-gap: 10px;
1559
+ --hud-clock-size: 10px;
1560
+ --hud-actions-gap: 10px;
1561
+ }
1423
1562
 
1424
- .hud-hotbar-container {
1425
- bottom: 16px;
1426
- }
1563
+ /* Show mobile buttons only on mobile */
1564
+ body.mobile .hud-mobile-button {
1565
+ display: flex;
1566
+ }
1427
1567
 
1428
- .hud-hotbar-grid {
1429
- padding: 8px;
1430
- border-radius: 8px;
1431
- }
1568
+ body.mobile .hud-hotbar-container {
1569
+ bottom: 8px;
1570
+ }
1432
1571
 
1433
- .hud-status-container {
1434
- bottom: 70px;
1435
- }
1572
+ body.mobile .hud-hotbar-grid {
1573
+ padding: 8px;
1574
+ border-radius: 8px;
1575
+ gap: 4px;
1576
+ }
1436
1577
 
1437
- .hud-clock-container {
1438
- top: 16px;
1439
- right: 16px;
1440
- }
1578
+ body.mobile .hud-status-container {
1579
+ bottom: 82px;
1580
+ gap: 16px;
1581
+ }
1441
1582
 
1442
- .hud-clock {
1443
- padding: 8px;
1444
- }
1583
+ body.mobile .hud-clock-container {
1584
+ top: 16px;
1585
+ right: 16px;
1586
+ }
1445
1587
 
1446
- .hud-hotbar-slot-content {
1447
- font-size: 12px;
1448
- }
1588
+ body.mobile .hud-clock {
1589
+ padding: 8px 10px;
1590
+ border-radius: 8px;
1591
+ }
1449
1592
 
1450
- .hud-hotbar-slot-icon {
1451
- width: 28px;
1452
- height: 28px;
1453
- }
1593
+ body.mobile .hud-hotbar-slot {
1594
+ border-radius: 8px;
1595
+ border-width: 2px;
1596
+ }
1454
1597
 
1455
- .hud-hotbar-slot-quantity {
1456
- font-size: 8px;
1457
- padding: 1px 3px;
1458
- }
1598
+ body.mobile .hud-hotbar-slot-content {
1599
+ font-size: 12px;
1600
+ }
1459
1601
 
1460
- .hud-health-text,
1461
- .hud-exp-text {
1462
- font-size: 10px;
1463
- }
1602
+ body.mobile .hud-hotbar-slot-icon {
1603
+ width: 32px;
1604
+ height: 32px;
1605
+ }
1464
1606
 
1465
- .hud-exp-gain {
1466
- font-size: 12px;
1467
- left: calc(var(--hud-bar-width) + var(--hud-status-gap) + var(--hud-bar-width) / 2);
1468
- }
1607
+ body.mobile .hud-hotbar-slot-quantity {
1608
+ font-size: 8px;
1609
+ padding: 1px 3px;
1610
+ bottom: 2px;
1611
+ right: 2px;
1612
+ }
1469
1613
 
1470
- .hud-action-buttons {
1471
- top: 60px;
1472
- right: 16px;
1473
- }
1614
+ body.mobile .hud-health-bar,
1615
+ body.mobile .hud-exp-bar {
1616
+ border-radius: 8px;
1617
+ }
1474
1618
 
1475
- .hud-action-button-icon {
1476
- width: 24px;
1477
- height: 24px;
1478
- }
1619
+ body.mobile .hud-health-text,
1620
+ body.mobile .hud-exp-text {
1621
+ font-size: 10px;
1622
+ }
1479
1623
 
1480
- .hud-action-tooltip {
1481
- display: none;
1482
- }
1624
+ body.mobile .hud-exp-gain {
1625
+ font-size: 12px;
1626
+ left: calc(var(--hud-bar-width) + var(--hud-status-gap) + var(--hud-bar-width) / 2);
1627
+ }
1483
1628
 
1484
- .hud-action-key-indicator {
1485
- width: 16px;
1486
- height: 16px;
1487
- top: -6px;
1488
- right: -6px;
1489
- font-size: 8px;
1490
- }
1629
+ body.mobile .hud-action-buttons {
1630
+ top: 55px;
1631
+ right: 16px;
1632
+ gap: 10px;
1633
+ }
1491
1634
 
1492
- .hud-quest-count-indicator {
1493
- min-width: 14px;
1494
- height: 14px;
1495
- top: -6px;
1496
- left: -6px;
1497
- font-size: 8px;
1498
- }
1635
+ body.mobile .hud-action-button {
1636
+ width: 44px;
1637
+ height: 44px;
1638
+ border-radius: 8px;
1639
+ border-width: 2px;
1640
+ }
1499
1641
 
1500
- .hud-help-icon {
1501
- font-size: 18px;
1502
- }
1642
+ body.mobile .hud-action-button-icon {
1643
+ width: 44px;
1644
+ height: 44px;
1645
+ }
1503
1646
 
1504
- /* Notification Mobile Adjustments */
1505
- .hud-notification-container {
1506
- top: 60px;
1507
- right: 66px;
1508
- gap: 8px;
1509
- }
1647
+ body.mobile .hud-action-tooltip {
1648
+ display: none;
1649
+ }
1510
1650
 
1511
- .hud-notification {
1512
- min-width: 160px;
1513
- max-width: 240px;
1514
- padding: 10px 12px;
1515
- font-size: 11px;
1516
- }
1651
+ body.mobile .hud-action-key-indicator {
1652
+ width: 16px;
1653
+ height: 16px;
1654
+ top: -6px;
1655
+ right: -6px;
1656
+ font-size: 8px;
1657
+ border-radius: 6px;
1658
+ }
1517
1659
 
1518
- .hud-notification-content {
1519
- gap: 8px;
1520
- }
1660
+ body.mobile .hud-quest-count-indicator {
1661
+ width: 16px;
1662
+ height: 16px;
1663
+ top: -6px;
1664
+ left: -6px;
1665
+ font-size: 9px;
1666
+ }
1521
1667
 
1522
- .hud-notification-text {
1523
- font-size: 11px;
1524
- }
1668
+ body.mobile .hud-help-notification-indicator {
1669
+ width: 12px;
1670
+ height: 12px;
1671
+ top: -5px;
1672
+ left: -5px;
1673
+ }
1525
1674
 
1526
- .hud-crosshair-horizontal {
1527
- width: 8px;
1528
- left: -4px;
1529
- }
1675
+ body.mobile .hud-help-icon {
1676
+ font-size: 20px;
1677
+ }
1530
1678
 
1531
- .hud-crosshair-vertical {
1532
- height: 8px;
1533
- top: -4px;
1534
- }
1679
+ /* Notification Mobile Adjustments */
1680
+ body.mobile .hud-notification-container {
1681
+ top: 55px;
1682
+ right: 70px;
1683
+ gap: 8px;
1684
+ }
1535
1685
 
1536
- /* Area Banner Mobile */
1537
- .hud-area-banner-text {
1538
- font-size: clamp(1.8rem, 10vw, 3rem);
1539
- letter-spacing: 0.05em;
1540
- margin: 0 0 4px 0;
1541
- }
1686
+ body.mobile .hud-notification {
1687
+ min-width: 160px;
1688
+ max-width: 240px;
1689
+ padding: 10px 12px;
1690
+ font-size: 10px;
1691
+ border-radius: 8px;
1692
+ }
1542
1693
 
1543
- @keyframes underlineExpand {
1544
- to {
1545
- width: min(300px, 85vw);
1546
- opacity: 1;
1547
- }
1548
- }
1694
+ body.mobile .hud-notification-content {
1695
+ gap: 8px;
1696
+ }
1549
1697
 
1550
- /* Death Overlay Mobile */
1551
- .hud-death-content {
1552
- margin: 0 16px;
1553
- max-width: 90vw;
1554
- }
1698
+ body.mobile .hud-notification-icon {
1699
+ width: 14px;
1700
+ height: 14px;
1701
+ font-size: 10px;
1702
+ }
1555
1703
 
1556
- .hud-death-title {
1557
- font-size: clamp(1.8rem, 10vw, 3.5rem);
1558
- margin: 0 0 4px 0;
1559
- letter-spacing: 0.05em;
1560
- }
1704
+ body.mobile .hud-notification-text {
1705
+ font-size: 10px;
1706
+ }
1561
1707
 
1562
- .hud-death-subtitle {
1563
- font-size: clamp(0.8rem, 4vw, 1rem);
1564
- margin: 0 0 10px 0;
1565
- }
1708
+ body.mobile .hud-crosshair-horizontal {
1709
+ width: 10px;
1710
+ height: 2px;
1711
+ left: -5px;
1712
+ top: -1px;
1713
+ }
1566
1714
 
1567
- .hud-death-underline {
1568
- margin: 0 auto 20px auto;
1569
- }
1715
+ body.mobile .hud-crosshair-vertical {
1716
+ width: 2px;
1717
+ height: 10px;
1718
+ top: -5px;
1719
+ left: -1px;
1720
+ }
1570
1721
 
1571
- @keyframes deathUnderlineExpand {
1572
- to {
1573
- width: min(200px, 80vw);
1574
- opacity: 1;
1575
- }
1722
+ /* Area Banner Mobile */
1723
+ body.mobile .hud-area-banner-text {
1724
+ font-size: clamp(1.8rem, 9vw, 3rem);
1725
+ letter-spacing: 0.05em;
1726
+ margin: 0 0 4px 0;
1727
+ }
1728
+
1729
+ body.mobile .hud-area-banner-underline {
1730
+ height: 4px;
1731
+ }
1732
+
1733
+ body.mobile .hud-area-banner.show .hud-area-banner-underline {
1734
+ animation: underlineExpandMobile 1.2s ease-out 0.8s forwards;
1735
+ }
1736
+
1737
+ @keyframes underlineExpandMobile {
1738
+ to {
1739
+ width: min(300px, 80vw);
1740
+ opacity: 1;
1576
1741
  }
1742
+ }
1743
+
1744
+ /* Death Overlay Mobile */
1745
+ body.mobile .hud-death-content {
1746
+ margin: 0 16px;
1747
+ max-width: 90vw;
1748
+ }
1749
+
1750
+ body.mobile .hud-death-title {
1751
+ font-size: clamp(1.8rem, 9vw, 3.5rem);
1752
+ margin: 0 0 4px 0;
1753
+ letter-spacing: 0.05em;
1754
+ }
1755
+
1756
+ body.mobile .hud-death-subtitle {
1757
+ font-size: clamp(0.8rem, 4vw, 1rem);
1758
+ margin: 0 0 10px 0;
1759
+ }
1577
1760
 
1578
- .hud-death-respawn-btn {
1579
- font-size: 12px;
1580
- padding: 10px 20px;
1581
- min-width: 100px;
1761
+ body.mobile .hud-death-underline {
1762
+ margin: 0 auto 18px auto;
1763
+ height: 3px;
1764
+ }
1765
+
1766
+ body.mobile .hud-death-overlay.show .hud-death-underline {
1767
+ animation: deathUnderlineExpandMobile 1.2s ease-out 0.8s forwards;
1768
+ }
1769
+
1770
+ @keyframes deathUnderlineExpandMobile {
1771
+ to {
1772
+ width: min(220px, 75vw);
1773
+ opacity: 1;
1582
1774
  }
1583
1775
  }
1584
1776
 
1777
+ body.mobile .hud-death-respawn-btn {
1778
+ font-size: 12px;
1779
+ padding: 10px 20px;
1780
+ min-width: 100px;
1781
+ border-radius: 8px;
1782
+ }
1783
+
1585
1784
  /* ============================================
1586
1785
  HIGH DPI DISPLAYS
1587
1786
  ============================================ */