第一章:代码王国的大冒险开始了
第一章:代码王国的大冒险开始了
The Magic Begins: Our Adventure in Code Kingdom
---
阳光从窗户洒进小明房间的时候,这一天看起来和往常没什么不同。闹钟在七点准时响起,妈妈的声音从楼下传来,催促着他起床吃早餐。书包已经收拾好了,校服整整齐齐地挂在椅子上。这一切都是那么平常,平常得让人有点提不起劲。
But the moment the sunlight streamed through Xiao Ming's window that morning, everything was about to change. The alarm clock rang at exactly seven o'clock, just like every other day. Mom's voice called from downstairs, urging him to come down for breakfast. His school bag was already packed, his uniform hanging neatly on the chair. Everything seemed so ordinary—so ordinary that Xiao Ming almost felt bored.
就在小明揉着眼睛坐起来的时候,他注意到了一个奇怪的东西。在他的枕头旁边,不知道什么时候多了一张闪闪发光的纸。这张纸不是普通的纸,它散发着淡淡的蓝色光芒,就像童话故事里仙女撒下的魔法粉。
Just as Xiao Ming rubbed his eyes and sat up, something caught his attention. Something strange. Right beside his pillow, there was a glowing piece of paper that hadn't been there before. This wasn't ordinary paper—it shimmered with a soft blue light, just like the magical dust that fairy tale princesses sprinkle around.
小明揉了揉眼睛,以为自己还没睡醒。他伸手去摸那张纸,指尖刚一接触到纸面——
Xiao Ming rubbed his eyes, thinking he was still half-asleep. He reached out to touch the paper, and the moment his fingers made contact—
"砰!" 一道耀眼的光芒充满了整个房间。
"POOF!" A brilliant flash of light filled the entire room.
等小明睁开眼睛的时候,他发现自己已经不在自己的房间里了。他站在一片广阔的草原上,头顶是湛蓝的天空,远处有闪闪发光的高塔,有漂浮在空中的城堡,还有一条条像彩虹一样五颜六色的道路,一直延伸到地平线的尽头。
When Xiao Ming opened his eyes, he found himself no longer in his bedroom. He was standing on a vast green meadow, with a crystal-clear blue sky above. In the distance, there were shimmering towers, castles floating in the air, and colorful roads stretching all the way to the horizon.
"欢迎来到代码王国,勇敢的小探险家!"
"Welcome to Code Kingdom, brave little explorer!"
小明转过身,看到一个圆滚滚的小机器人正朝他挥手。这个机器人只有篮球那么高,圆圆的身体上长着一个大大的屏幕脑袋,屏幕上显示着一张笑脸。它的两只小轮子在地上转来转去,发出"咕噜咕噜"的声音。
Xiao Ming spun around and saw a cute little robot waving at him. The robot was about the size of a basketball, with a round body and a big screen for a head. On the screen was a happy smiley face. Its two small wheels spun around on the ground, making "gurgle gurgle" sounds.
"我是小程,你的代码王国探险向导!"小机器人用清脆的声音说道,"我已经在这里等你好久了!"
"I'm Xiao Cheng, your Code Kingdom adventure guide!" the little robot said in a cheerful voice. "I've been waiting for you for a very long time!"
"代码王国?"小明惊讶地瞪大了眼睛,"我听说过童话王国、魔法王国,可从来没听说过代码王国啊!"
"Code Kingdom?" Xiao Ming gasped, his eyes wide with surprise. "I've heard of Fairy Tale Kingdoms and Magic Kingdoms, but I've never heard of a Code Kingdom before!"
小程的屏幕脑袋上下晃动,像是在点头。它转过身,开始在草原上滚动,小明连忙跟了上去。
Xiao Cheng's screen head bobbed up and down, as if nodding. It turned around and started rolling across the meadow, and Xiao Ming hurried to follow.
"代码王国是一个非常特别的地方,"小程一边走一边解释,"这里的一切都是由代码建造而成的。高塔是用代码盖起来的,城堡是用代码拼出来的,就连天上的云朵和地上的小草,都是由一行行神奇的数字指令组成的。"
"Code Kingdom is a very special place," Xiao Cheng explained as they walked. "Everything here was built with code. The towers were constructed with code, the castles were assembled with code, and even the clouds in the sky and the grass on the ground are all made up of magical lines of digital instructions."
"太神奇了!"小明忍不住惊叹。他看到远处的一座高塔正在"生长",一块块彩色的砖块从地面升起,自动组装成塔身。"那座塔是怎么盖起来的?"
"That's amazing!" Xiao Ming couldn't help but exclaim. In the distance, he saw a tower that seemed to be "growing," with colorful bricks rising from the ground and automatically assembling into the tower's structure. "How is that tower being built?"
"那座塔正在执行一个'建造程序',"小程解释道,"程序员编写了详细的指令,告诉电脑:'先放第一块砖,再放第二块砖,然后放第三块砖……'电脑按照这些指令,一步一步地完成建造工作。"
"That tower is executing a 'building program,'" Xiao Cheng explained. "The programmer wrote detailed instructions telling the computer: 'Put the first brick here, then the second brick, then the third brick...' The computer follows these instructions step by step to complete the building work."
小明听得入神。他想起了自己在学校学到的知识——原来电脑和程序的关系,就像人类和说明书的关系一样。电脑是听话但不懂事的"大孩子",你必须告诉它每一步要做什么,它才能完成工作。
Xiao Ming listened intently. He thought about what he had learned in school—that the relationship between a computer and a program is like the relationship between a person and an instruction manual. The computer is like a well-behaved but understanding-challenged "big child." You have to tell it every single step of what to do before it can get any work done.
他们走过彩虹桥,穿过糖果森林,来到了一座宁静的小村庄。村子里有十几座可爱的小房子,有木头的、石头的、砖块的,形状各异,风格不同。村子中央有一棵巨大的老橡树,树下聚集了不少村民。
They crossed a rainbow bridge, walked through a candy forest, and arrived at a peaceful little village. The village had about a dozen cute little houses—some made of wood, some of stone, some of bricks—with all kinds of different shapes and styles. In the center of the village stood a giant old oak tree, and beneath it gathered quite a few villagers.
"这里是代码王国的'初心村',"小程介绍道,"这里的村民都是刚来代码王国的新手,他们正在学习如何用代码建造自己的房子。"
"This is Code Kingdom's 'Beginner's Village,'" Xiao Cheng introduced. "The villagers here are all newcomers to Code Kingdom. They're learning how to build their own houses with code."
小明刚想问点什么,一个慌慌张张的声音突然传来——
Xiao Ming was about to ask something when a flustered voice suddenly called out—
"不好啦!不好啦!出大事啦!"
"Oh no! Oh no! Something terrible has happened!"
一只穿着蓝色背带裤的小松鼠从人群中冲了出来,它的两只小手不停地挥舞着,蓬松的大尾巴在身后甩来甩去。
A little squirrel in blue overalls rushed out from the crowd. Its two little hands waved frantically, and its fluffy big tail swished back and forth behind it.
"小橡果,怎么了?"小程问道。
"Little Acorn, what's wrong?" Xiao Cheng asked.
"我的房子……我的房子全乱了!"小橡果——那只小松鼠——几乎要哭出来了,"我本来想给我的小窝加一个新房间的,可是……可是现在整个房子都乱成一团了!"
"My house... my whole house is a mess!" Little Acorn—the little squirrel—looked like it was about to cry. "I just wanted to add a new room to my nest, but... but now the whole house is a tangled mess!"
小明跟着小程和小橡果来到了村子的东边。那里有一座看起来……嗯,怎么说呢……非常"有创意"的建筑。说它是房子吧,它有三层楼那么高;说它是塔吧,它又歪歪扭扭的;说它是积木城堡吧,可它的屋顶居然在地上,窗户却开在地下室。
Xiao Ming followed Xiao Cheng and Little Acorn to the east side of the village. There stood a building that looked... well, how should I put this... very "creative." Was it a house? It was three stories tall. Was it a tower? It was tilted and crooked. Was it a block castle? But its roof was on the ground while the windows were in the basement.
"这就是我的房子!"小橡果指着那座奇怪的建筑,眼泪汪汪地说,"我想加个房间,结果……结果就变成这样了!"
"This is my house!" Little Acorn pointed at the strange building, tears welling up in its eyes. "I wanted to add a room, and then... and then it turned into this!"
小明忍不住笑出了声,但看到小橡果伤心的样子,又赶紧捂住了嘴巴。他仔细观察着那座"奇妙建筑",发现里面其实还是有章可循的——有门有窗,有楼梯有房间,只是它们的排列方式实在是让人摸不着头脑。
Xiao Ming couldn't help but laugh out loud, but seeing Little Acorn's sad face, he quickly covered his mouth. He examined the "wonderful building" carefully and realized that there was actually some method to the madness—there were doors and windows, stairs and rooms, just arranged in a way that made no sense at all.
"小橡果,你是不是直接把新房间的代码加在旧代码的后面了?"小程的屏幕脑袋上出现了一个问号。
"Little Acorn, did you just add the new room's code at the end of the old code?" A question mark appeared on Xiao Cheng's screen head.
"对啊!"小橡果用力点头,"我把'建造新房间'的指令写在'建造旧房子'的指令后面了,这样不就能让新房间出现在旧房子上面吗?"
"Yes!" Little Acorn nodded vigorously. "I wrote the 'build new room' instructions after the 'build old house' instructions. That way, wouldn't the new room appear on top of the old house?"
小程叹了口气,它的屏幕上出现了一个无奈的表情。"这就是问题所在了。在代码世界里,建筑的顺序和位置非常重要。就像你们人类世界建房子一样,你要先打地基,再砌墙,最后才能盖屋顶。如果你先盖屋顶再砌墙,房子肯定会歪掉的!"
Xiao Cheng sighed, and a helpless expression appeared on its screen. "That's exactly the problem. In the world of code, the order and position of building things is extremely important. Just like building a house in your human world, you have to lay the foundation first, then build the walls, and only then put on the roof. If you put on the roof before building the walls, the house will definitely end up crooked!"
小明恍然大悟。他想起科学课上老师讲过的话:"程序是给电脑的一系列指令,这些指令必须按照正确的顺序排列,电脑才能正确执行。"
Xiao Ming suddenly understood. He remembered what his teacher had said in science class: "A program is a series of instructions for the computer, and these instructions mu