openfree commited on
Commit
3b56534
·
verified ·
1 Parent(s): acb3061

Upload index.html with huggingface_hub

Browse files
Files changed (1) hide show
  1. index.html +241 -18
index.html CHANGED
@@ -1,19 +1,242 @@
1
- <!doctype html>
2
  <html>
3
- <head>
4
- <meta charset="utf-8" />
5
- <meta name="viewport" content="width=device-width" />
6
- <title>My static Space</title>
7
- <link rel="stylesheet" href="style.css" />
8
- </head>
9
- <body>
10
- <div class="card">
11
- <h1>Welcome to your static Space!</h1>
12
- <p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p>
13
- <p>
14
- Also don't forget to check the
15
- <a href="https://huggingface.co/docs/hub/spaces" target="_blank">Spaces documentation</a>.
16
- </p>
17
- </div>
18
- </body>
19
- </html>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
  <html>
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <title>Alchemy Card Game</title>
6
+ <style>
7
+ * { margin: 0; padding: 0; box-sizing: border-box; }
8
+ body {
9
+ background: #0a0a2a;
10
+ overflow: hidden;
11
+ }
12
+ #game-container {
13
+ width: 100vw;
14
+ height: 100vh;
15
+ display: flex;
16
+ justify-content: center;
17
+ align-items: center;
18
+ }
19
+ canvas {
20
+ background: #1a1a3a;
21
+ box-shadow: 0 0 30px rgba(0,0,0,0.5);
22
+ }
23
+ </style>
24
+ </head>
25
+ <body>
26
+ <div id="game-container">
27
+ <canvas id="gameCanvas"></canvas>
28
+ </div>
29
+
30
+ <script>
31
+ class Card {
32
+ constructor(element, rarity) {
33
+ this.element = element;
34
+ this.rarity = rarity;
35
+ this.x = 0;
36
+ this.y = 0;
37
+ this.targetX = 0;
38
+ this.targetY = 0;
39
+ this.width = 100;
40
+ this.height = 150;
41
+ this.selected = false;
42
+ this.isMoving = false;
43
+ this.speed = 0.1;
44
+ }
45
+
46
+ move() {
47
+ if (this.x !== this.targetX || this.y !== this.targetY) {
48
+ this.isMoving = true;
49
+ this.x += (this.targetX - this.x) * this.speed;
50
+ this.y += (this.targetY - this.y) * this.speed;
51
+
52
+ if (Math.abs(this.x - this.targetX) < 0.1 && Math.abs(this.y - this.targetY) < 0.1) {
53
+ this.x = this.targetX;
54
+ this.y = this.targetY;
55
+ this.isMoving = false;
56
+ }
57
+ }
58
+ }
59
+
60
+ draw(ctx) {
61
+ ctx.save();
62
+
63
+ // Card shadow
64
+ ctx.shadowColor = 'rgba(0,0,0,0.5)';
65
+ ctx.shadowBlur = 10;
66
+ ctx.shadowOffsetX = 5;
67
+ ctx.shadowOffsetY = 5;
68
+
69
+ // Card background
70
+ const gradient = ctx.createLinearGradient(this.x, this.y, this.x + this.width, this.y + this.height);
71
+ gradient.addColorStop(0, this.element.color);
72
+ gradient.addColorStop(1, this.adjustColor(this.element.color, -30));
73
+
74
+ ctx.fillStyle = gradient;
75
+ ctx.strokeStyle = this.selected ? '#ffff00' : this.rarity.color;
76
+ ctx.lineWidth = this.selected ? 3 : 2;
77
+
78
+ // Card shape with rounded corners
79
+ this.roundRect(ctx, this.x, this.y, this.width, this.height, 10);
80
+ ctx.fill();
81
+ ctx.stroke();
82
+
83
+ // Remove shadow for text
84
+ ctx.shadowColor = 'transparent';
85
+
86
+ // Element symbol
87
+ ctx.font = '40px Arial';
88
+ ctx.textAlign = 'center';
89
+ ctx.fillStyle = '#ffffff';
90
+ ctx.fillText(this.element.symbol, this.x + this.width/2, this.y + this.height/2);
91
+
92
+ // Card details
93
+ ctx.font = '14px Arial';
94
+ ctx.fillStyle = '#ffffff';
95
+ ctx.fillText(this.element.name, this.x + this.width/2, this.y + this.height - 40);
96
+ ctx.fillText(this.rarity.name, this.x + this.width/2, this.y + this.height - 20);
97
+
98
+ ctx.restore();
99
+ }
100
+
101
+ roundRect(ctx, x, y, width, height, radius) {
102
+ ctx.beginPath();
103
+ ctx.moveTo(x + radius, y);
104
+ ctx.arcTo(x + width, y, x + width, y + height, radius);
105
+ ctx.arcTo(x + width, y + height, x, y + height, radius);
106
+ ctx.arcTo(x, y + height, x, y, radius);
107
+ ctx.arcTo(x, y, x + width, y, radius);
108
+ ctx.closePath();
109
+ }
110
+
111
+ adjustColor(color, amount) {
112
+ return '#' + color.replace(/^#/, '').replace(/../g, color =>
113
+ ('0' + Math.min(255, Math.max(0, parseInt(color, 16) + amount))
114
+ .toString(16)).substr(-2));
115
+ }
116
+ }
117
+
118
+ class Game {
119
+ constructor() {
120
+ this.canvas = document.getElementById('gameCanvas');
121
+ this.ctx = this.canvas.getContext('2d');
122
+ this.canvas.width = 1200;
123
+ this.canvas.height = 800;
124
+
125
+ this.cards = [];
126
+ this.selectedCards = [];
127
+
128
+ this.elements = {
129
+ FIRE: {name: 'Fire', color: '#ff4400', symbol: '🔥'},
130
+ WATER: {name: 'Water', color: '#0088ff', symbol: '💧'},
131
+ EARTH: {name: 'Earth', color: '#884400', symbol: '🌎'},
132
+ AIR: {name: 'Air', color: '#aaaaff', symbol: '💨'},
133
+ METAL: {name: 'Metal', color: '#cccccc', symbol: '⚒️'},
134
+ MERCURY: {name: 'Mercury', color: '#88ccff', symbol: '☿'},
135
+ SULFUR: {name: 'Sulfur', color: '#ffff00', symbol: '🟡'},
136
+ SALT: {name: 'Salt', color: '#ffffff', symbol: '🧂'}
137
+ };
138
+
139
+ this.rarities = {
140
+ COMMON: {name: 'Common', color: '#ffffff', multiplier: 1},
141
+ RARE: {name: 'Rare', color: '#0088ff', multiplier: 1.5},
142
+ EPIC: {name: 'Epic', color: '#aa00ff', multiplier: 2},
143
+ LEGENDARY: {name: 'Legendary', color: '#ffaa00', multiplier: 3}
144
+ };
145
+
146
+ this.initializeCards();
147
+ this.bindEvents();
148
+ this.gameLoop();
149
+ }
150
+
151
+ initializeCards() {
152
+ let index = 0;
153
+ for (let element in this.elements) {
154
+ for (let rarity in this.rarities) {
155
+ const card = new Card(this.elements[element], this.rarities[rarity]);
156
+ card.x = 50 + (index % 8) * 120;
157
+ card.y = 50 + Math.floor(index / 8) * 170;
158
+ card.targetX = card.x;
159
+ card.targetY = card.y;
160
+ this.cards.push(card);
161
+ index++;
162
+ }
163
+ }
164
+ }
165
+
166
+ bindEvents() {
167
+ this.canvas.addEventListener('click', (e) => {
168
+ const rect = this.canvas.getBoundingClientRect();
169
+ const mouseX = e.clientX - rect.left;
170
+ const mouseY = e.clientY - rect.top;
171
+ this.handleCardClick(mouseX, mouseY);
172
+ });
173
+ }
174
+
175
+ handleCardClick(mouseX, mouseY) {
176
+ this.cards.forEach(card => {
177
+ if (mouseX > card.x && mouseX < card.x + card.width &&
178
+ mouseY > card.y && mouseY < card.y + card.height) {
179
+ if (!card.selected && !card.isMoving) {
180
+ this.selectCard(card);
181
+ }
182
+ }
183
+ });
184
+ }
185
+
186
+ selectCard(card) {
187
+ if (this.selectedCards.length < 3) {
188
+ card.selected = true;
189
+ this.selectedCards.push(card);
190
+
191
+ // Move card to bottom center
192
+ const centerX = this.canvas.width / 2;
193
+ const bottomY = this.canvas.height - 200;
194
+ const spacing = 120;
195
+
196
+ const startX = centerX - ((this.selectedCards.length - 1) * spacing / 2);
197
+ this.selectedCards.forEach((selectedCard, index) => {
198
+ selectedCard.targetX = startX + (index * spacing);
199
+ selectedCard.targetY = bottomY;
200
+ });
201
+
202
+ if (this.selectedCards.length === 3) {
203
+ setTimeout(() => this.combineCards(), 1000);
204
+ }
205
+ }
206
+ }
207
+
208
+ combineCards() {
209
+ // Add combination animation here
210
+ this.selectedCards.forEach(card => {
211
+ card.selected = false;
212
+ card.targetX = card.x;
213
+ card.targetY = card.y;
214
+ });
215
+ this.selectedCards = [];
216
+ }
217
+
218
+ update() {
219
+ this.cards.forEach(card => card.move());
220
+ }
221
+
222
+ draw() {
223
+ this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height);
224
+
225
+ // Draw non-selected cards first
226
+ this.cards.filter(card => !card.selected).forEach(card => card.draw(this.ctx));
227
+
228
+ // Draw selected cards on top
229
+ this.cards.filter(card => card.selected).forEach(card => card.draw(this.ctx));
230
+ }
231
+
232
+ gameLoop() {
233
+ this.update();
234
+ this.draw();
235
+ requestAnimationFrame(() => this.gameLoop());
236
+ }
237
+ }
238
+
239
+ window.onload = () => new Game();
240
+ </script>
241
+ </body>
242
+ </html>