anvaka / anvaka/time

how to speak time

Open
#14 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
650
Forks
92
PR merge metrics
No merged PRs in 30d

Description



几点了 - 汉语时间游戏

body {
font-family: 'Arial', sans-serif;
background-color: #FFD166;
margin: 0;
padding: 20px;
display: flex;
flex-direction: column;
align-items: center;
min-height: 100vh;
}

.header {
color: #EF476F;
text-align: center;
margin-bottom: 30px;
}

h1 {
font-size: 3em;
margin-bottom: 10px;
text-shadow: 2px 2px 4px rgba(0,0,0,0.1);
}

.clock-container {
background-color: #06D6A0;
padding: 30px;
border-radius: 20px;
box-shadow: 0 10px 20px rgba(0,0,0,0.2);
margin-bottom: 30px;
}

.clock {
width: 300px;
height: 300px;
border-radius: 50%;
position: relative;
background-color: white;
border: 15px solid #118AB2;
}

.number {
position: absolute;
width: 100%;
height: 100%;
text-align: center;
font-size: 24px;
font-weight: bold;
z-index: 2;
}

.hand {
position: absolute;
bottom: 50%;
left: 50%;
transform-origin: bottom;
background-color: black;
border-radius: 5px;
z-index: 5;
}

.hour-hand {
width: 8px;
height: 80px;
margin-left: -4px;
}

.minute-hand {
width: 4px;
height: 120px;
margin-left: -2px;
}

.center-circle {
position: absolute;
top: 50%;
left: 50%;
width: 20px;
height: 20px;
background-color: black;
border-radius: 50%;
margin-left: -10px;
margin-top: -10px;
z-index: 10;
}

.instructions {
background-color: #EF476F;
color: white;
padding: 20px;
border-radius: 15px;
max-width: 500px;
text-align: center;
font-size: 1.2em;
box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

.click-text {
margin-top: 20px;
font-size: 1.5em;
color: #118AB2;
font-weight: bold;
}

.time-type-selector {
margin-bottom: 20px;
display: flex;
flex-wrap: wrap;
justify-content: center;
gap: 10px;
}

.time-type-btn {
padding: 8px 15px;
background-color: #118AB2;
color: white;
border: none;
border-radius: 20px;
cursor: pointer;
font-size: 14px;
}

.time-type-btn.active {
background-color: #EF476F;
font-weight: bold;
}


几点了?





全部类型
整点
半点
一刻/三刻
五分钟倍数







1

2

3

4

5

6

7

8

9

10

11

12








点击钟面生成新时间



这是一个练习说时间的游戏。点击钟面会随机生成一个时间,请用汉语说出这个时间。


可以练习:整点(三点)、半点(三点半)、一刻(三点一刻)、三刻(差一刻四点)、五分钟倍数(三点二十)





const clock = document.getElementById('clock');
const hourHand = document.getElementById('hour-hand');
const minuteHand = document.getElementById('minute-hand');
const timeTypeBtns = document.querySelectorAll('.time-type-btn');

let currentTimeType = 'all';

// 设置时间类型
timeTypeBtns.forEach(btn => {
btn.addEventListener('click', function() {
timeTypeBtns.forEach(b => b.classList.remove('active'));
this.classList.add('active');
currentTimeType = this.dataset.type;
setRandomTime();
});
});

function setRandomTime() {
let hours, minutes;

// 根据选择的时间类型生成不同的时间
switch(currentTimeType) {
case 'hour': // 整点
hours = Math.floor(Math.random() * 12);
minutes = 0;
break;

case 'half': // 半点
hours = Math.floor(Math.random() * 12);
minutes = 30;
break;

case 'quarter': // 一刻或三刻
hours = Math.floor(Math.random() * 12);
minutes = Math.random() > 0.5 ? 15 : 45;
break;

case 'five': // 五分钟倍数
hours = Math.floor(Math.random() * 12);
minutes = Math.floor(Math.random() * 12) * 5;
break;

default: // 全部类型随机
const types = [
[0, 15, 30, 45], // 整点、一刻、半点、三刻
Array.from({length: 12}, (_, i) => i * 5) // 所有五分钟倍数
].flat();
hours = Math.floor(Math.random() * 12);
minutes = types[Math.floor(Math.random() * types.length)];
}

const hourDegrees = (hours * 30) + (minutes * 0.5);
const minuteDegrees = minutes * 6;

hourHand.style.transform = `rotate(${hourDegrees}deg)`;
minuteHand.style.transform = `rotate(${minuteDegrees}deg)`;
}

// 初始随机时间
setRandomTime();

// 点击时钟生成新时间
clock.addEventListener('click', setRandomTime);

Contributor guide

No contributing guide indexed for this repository

Research direction

The issue embeds a complete HTML, CSS, and JavaScript time-speaking game, but names no repository file, test, or specific change to make. Start by locating where this page belongs in the repository and clarifying the expected feature or integration; completion cannot be defined from the issue alone.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend, web-dev
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.