Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/**
* This approach will create a simple HTML page with embedded CSS for the wild styling and a bit of JavaScript to handle the game logic of Wordle.
* We'll use vanilla JavaScript and HTML for simplicity, no external libraries or frameworks are necessary.
* The CSS will include bold color gradients, vibrant fonts, and other "crazy" styles.
*/
export default async function main(req: Request): Response {
const htmlContent = `
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Crazy Wordle Game</title>
<style>
body {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
background: linear-gradient(135deg, #ff9a9e 0%, #fad0c4 99%, #fad0c4 100%);
font-family: 'Comic Sans MS', cursive, sans-serif;
text-align: center;
}
.game-container {
display: grid;
gap: 10px;
}
.row {
display: flex;
gap: 5px;
}
.cell {
width: 50px;
height: 50px;
display: flex;
justify-content: center;
align-items: center;
font-size: 24px;
border-radius: 10px;
background: linear-gradient(45deg, #ee9ca7, #ffdde1);
animation: cell-animation 2s infinite;
}
@keyframes cell-animation {
0% { transform: scale(1); }
50% { transform: scale(1.1); }
100% { transform: scale(1); }
}
.correct { background: linear-gradient(45deg, #a3e635, #16a34a); }
.present { background: linear-gradient(45deg, #fbbf24, #f59e0b); }
.absent { background: linear-gradient(45deg, #9ca3af, #6b7280); }
</style>
</head>
<body>
<div class="game-container" id="game">
</div>
<script>
const word = 'CRAZY';
let currentRow = 0;
let gameContainer = document.getElementById('game');
function createGrid() {
for (let i = 0; i < 6; i++) {
let row = document.createElement('div');
row.className = 'row';
for (let j = 0; j < 5; j++) {
let cell = document.createElement('div');
cell.className = 'cell';
row.appendChild(cell);
}
gameContainer.appendChild(row);
}
}
function handleKeyPress(e) {
let row = gameContainer.children[currentRow];
let cells = Array.from(row.children);
if (e.key === 'Enter') {
if (cells.filter(cell => cell.textContent !== '').length === 5) {
checkWord(cells);
currentRow++;
}
} else if (e.key === 'Backspace') {
let cell = cells.reverse().find(cell => cell.textContent !== '');
if (cell) cell.textContent = '';
} else if (/^[A-Za-z]$/.test(e.key)) {
let cell = cells.find(cell => cell.textContent === '');
if (cell) cell.textContent = e.key.toUpperCase();
}
}
function checkWord(cells) {
let guess = cells.map(cell => cell.textContent).join('');
for (let i = 0; i < 5; i++) {
if (guess[i] === word[i]) {
cells[i].classList.add('correct');
} else if (word.includes(guess[i])) {
cells[i].classList.add('present');
} else {
cells[i].classList.add('absent');
janpaul123-valle_tmp_642242117750307901497006663363.web.val.run
July 15, 2024