Cấp độ: beginner25 phútminMiễn phíFreeJunior BuilderJunior Builder

HTML: Trang web đầu tiênHTML: Your first web page

Trang HTML giới thiệu bản thânA personal HTML intro page

Bạn sẽ học gìWhat you will learn

  • Hiểu cấu trúc HTML cơ bảnUnderstand basic HTML structure
  • Dùng tag h1-h6, p, ul, img, aUse tags h1-h6, p, ul, img, a
  • Tạo trang giới thiệu bản thânCreate a personal intro page

Bạn sẽ tạo gìWhat you will build

Trang HTML giới thiệu bản thânA personal HTML intro page

Nội dung bài họcLesson content

Clone là gì?What is a clone?

Clone là bản sao của một sprite. Thay vì thêm 50 sprite trái cây thủ công, bạn tạo 1 sprite rồi clone 50 lần. Mỗi clone hoạt động độc lập nhưng chia sẻ cùng code. Clone giúp game có nhiều vật thể mà không cần duplicate code.A clone is a copy of a sprite. Instead of manually adding 50 fruit sprites, you create 1 sprite and clone it 50 times. Each clone acts independently but shares the same code. Clones let games have many objects without duplicating code.

Tạo clone trong ScratchCreating clones in Scratch

Dùng khối "create clone of [myself]" để tạo bản sao của sprite hiện tại. Dùng "create clone of [sprite]" để clone sprite khác. Mỗi clone sẽ chạy khối "when I start as a clone" — đây là điểm bắt đầu của clone.Use "create clone of [myself]" to create a copy of the current sprite. Use "create clone of [sprite]" to clone another sprite. Each clone runs the "when I start as a clone" block — this is the clone's starting point.

scratch
                      
                        when flag clicked
forever
  create clone of [myself]
  wait 1 seconds

when I start as a clone
go to random position
glide 2 secs to y: -180
if <touching basket?> then
  change [điểm] by [1]
delete this clone
                      
                    

Xóa cloneDeleting clones

Mỗi clone cần được xóa khi không còn cần, nếu không game sẽ chậm. Dùng khối "delete this clone" khi clone chạm giỏ hoặc chạm đáy màn hình. Nếu không xóa, hàng nghìn clone sẽ tích lũy và làm game lag.Each clone needs to be deleted when no longer needed, otherwise the game will slow down. Use "delete this clone" when the clone touches the basket or the bottom of the screen. If not deleted, thousands of clones will accumulate and lag the game.

Game bắn bóng: ứng dụng cloneBubble shooter game: clone application

Trong game bắn bóng, mỗi viên đạn là 1 clone. Khi nhấn phím space, tạo clone đạn bay lên. Khi đạn chạm bóng → xóa đạn + xóa bóng + tăng điểm. Clone giúp bắn nhiều đạn cùng lúc mà không cần sprite riêng cho mỗi viên.In a bubble shooter game, each bullet is a clone. When you press space, create a bullet clone that flies up. When the bullet touches a bubble → delete bullet + delete bubble + increase score. Clones let you fire many bullets at once without separate sprites.

Bài tập thực hànhHands-on exercises

1Tạo game: mỗi 1 giây tạo 1 clone rơi từ trên xuống. Clone chạm giỏ → +1 điểm rồi xóa clone.Create a game: every 1 second create a clone that falls from top. Clone touches basket → +1 score then delete clone.

Gợi ýHint

Dùng "create clone of myself" trong forever + wait 1. Clone: glide xuống, if touching basket → +1, delete this clone.Use "create clone of myself" in forever + wait 1. Clone: glide down, if touching basket → +1, delete this clone.

Lời giảiSolution
scratch
                      
                        when flag clicked
forever
  create clone of [myself]
  wait 1 seconds

when I start as a clone
go to x: (pick random -200 to 200) y: 180
glide 2 secs to y: -180
if <touching basket?> then
  change [điểm] by [1]
delete this clone
                      
                    

2Thêm điều kiện: nếu clone chạm đáy mà không chạm giỏ → trừ 1 mạng. Hết 3 mạng → game over.Add condition: if clone touches bottom without touching basket → lose 1 life. 0 lives → game over.

Gợi ýHint

Tạo biến "mạng" = 3. Nếu y < -170 → change mạng by -1. Nếu mạng = 0 → stop all.Create variable "lives" = 3. If y < -170 → change lives by -1. If lives = 0 → stop all.

Lời giảiSolution
scratch
                      
                        when flag clicked
set [mạng] to [3]

when I start as a clone
go to x: (pick random -200 to 200) y: 180
glide 2 secs to y: -180
if <touching basket?> then
  change [điểm] by [1]
else
  change [mạng] by [-1]
  if <(mạng) = [0]> then
    say "Game Over!" for 2 seconds
    stop [all]
delete this clone
                      
                    

Kiểm traQuiz

Chọn đáp án đúng cho mỗi câu. Nhấn để xem giải thích.Choose the correct answer for each question. Click to see explanation.

Câu 1: Clone là gì?Q1: What is a clone?

Câu 2: Tại sao phải xóa clone?Q2: Why should you delete clones?

Câu 3: Khối nào bắt đầu code của clone?Q3: Which block starts a clone's code?

Code mẫuSample code

html
                <!DOCTYPE html>
<html lang="vi">
<head>
  <meta charset="UTF-8">
  <title>Trang của tôi / My Page</title>
</head>
<body>
  <h1>Xin chào! / Hello!</h1>
  <p>Tôi là / I am <strong>Hà Mi</strong>.</p>
  <ul>
    <li>Lập trình / Coding</li>
    <li>Toán học / Math</li>
  </ul>
</body>
</html>