《Programming Wizards!》Gyroplane
Advertisement
“A friend of mine returned from an expedition yesterday.” The students attentively listened, for stories from beyond Rorohiko were rare. “They flew over a forest in a gyroplane.” He looked around. “Does anyone know what a gyroplane is?” He pointed to a student with his hand raised.
“A vehicle capable of flying in any direction or hovering in place using its propellers.”
“Yes, what is your name?”
“Roy.”
“Roy, do you know how we can keep its propellers turning?”
He thought for a moment, then shrugged. “I’m not sure what you mean.”
“How can we run code repeatedly?”
He thought some more. “Wouldn’t you have to keep executing the code again and again?”
“Yes, do you know how to write that in code?”
“No, unless you’re about to teach us how to do it at runtime.”
Vick smiled, he knew this class was different. “Yes. Today, you will learn how.”
while (true) { Console.WriteLine(“Looped!”); }
“Above me,” he pointed to the screen, “is a ‘while loop.’” He executed the code. ‘Looped!’ it said. Then, on the line under it: ‘Looped!’ Then, on the line under that: ‘Looped!’ Then, over and over and over. “It will continue to execute as long as its condition is true. What we’ve created is an infinite loop.”
int i = 0; while (i < 5) { i = i + 1; Console.WriteLine(“Loop #” + i); }
He ran the code, and after displaying five lines, ‘Loop #1,’ ‘Loop #2…’ the program completed its execution. “The condition is checked before the execution of the loop. The loop is only executed if the condition is true. What we’ve made is essentially a ‘for loop.’”
Advertisement
for (int i = 0; i < 5; i = i + 1) { Console.WriteLine(“Loop #” + (i + 1)); }
He ran the code again, and it displayed the same five lines. “Instead of declaring an integer beforehand, and incrementing it in the loop, we can declare it, condition it, and increment it in a single line. That’s the power of a for loop. Note how we add one to the variable ‘i’ before concatenating it. This is because, in a for loop, the increment occurs after the loop’s execution. Whereas, before we incremented ‘i’ at the start of the loop.”
do { Console.WriteLine(“Looped!”); } while (true);
“The last loop is similar to a while loop,” he raised a finger, “with one important distinction. It executes at least once. Meaning, it executes once, then evaluates the condition to figure out if it should execute again. This is a ‘do while loop.’ Or simply, ‘do loop.’” He looked over the class, looking each student in the eye. “If you are to become apprentices, you must be wary with your use of loops.” His voice was uncomfortably firm, almost grim. “We will entrust you with precious resources, if you accidentally make an infinite loop where resources are expunged, there will be grave consequences.” He diverted his attention back to the computer. “Now, what does this have to do with gyroplanes? Well, their propellers need constant energy to spin.”
bool isOn = true; while (isOn) { Console.WriteLine(“Spin!”); }
‘Spin!’ said the screen over and over. “Yes, it is an infinite loop. However, another process would be occurring between each loop. That process would detect if a button was pressed which toggles the boolean. When that button is pressed, the loop will evaluate its condition as false, stopping it.”
Advertisement
for (float speed = 1f; speed < 20f; speed += 2f) { Console.WriteLine(“Spinning at speed: ” + speed); }
“The ‘f’ letter at the end of the numbers is to indicate it as a float in this language, not to be confused for an integer. The speed of the propeller can be controlled with each execution of the loop. Begins at one, only executes if it’s below twenty, increments by two every loop.” He walked closer to the class and stood taller. “Because of our great wizards, we were able to construct hardware that made it impossible for a propeller to spin too fast. So, even if we made an error where the speed became an enormous number, the propeller would simply rotate at its max speed dictated by its hardware. Just as integers and floats have a min and max range, so does the speed of a propeller. Zero being its min, and around four-hundred being its max.”
“What does ‘speed += 2f’ mean?” asked Willard.
“That’s shorthand for incrementing by two, and then setting that value to the variable.”
After class, the three huddled to converse. “Hey,” said Willard. “Does anyone know what a forest is? I heard Mister Vick use that word.”
“I’m not sure,” said Andrew, and Gus shrugged.
“It’s a massive cluster of trees,” said Roy, from down the hall, and walked towards them.
“Like, five or so?” asked Willard.
“No,” said Roy and stretched his arms to his sides. “A thousand kilometers, maybe more.”
Everyones’ jaw dropped. “What?” said Gus.
“A thousand kilometers? That’s impressive,” said Andrew.
Advertisement
-
The Nine Tails of Alchemy Series
Living life in a virtual world was never part of my plan. My dreams of the future were of university, of being a world renown researcher and pharmacist. Being one of the many unfortunates forced into a virtual reality capsule to live out my days as a popsicle, was not part of that dream. But not all dreams can be achieved, and sometimes, it’s the dreams we never knew we had that come true. I dreamed of walking a path of science, and now in a world known only to the mind, I walk a path trodden by the greatest scientists of all. In these frozen dreams, I walk the path of a disciple of natural philosophy. The First Tail - Slowly uploading edited chapters. The Second Tail - Only self edited, third party edits will be done once completed. https://discord.gg/DthbGATp6E Copyright © 2021 Taniko K Williams, all rights reserved.
8 1204 -
WriTE Halloween Contest
Hi Everyone! Writers to the End, the largest group on Royal Road Legends is happy to announce the start of the WriTE Halloween Contest! Write a short story, submit it, and try to win! Everyone can take part and anyone can win so go, check the rules and write… To The End. Submitted stories will be displayed on the 30th of October from noon GMT. Note: Please submit the stories to WriTE, not RRl, to ensure everyone begins voting at the same time. Readers can rate the stories from October 30 to November 6. Some stories may contain mature content so we advise the readers to read the author notes before every story.
8 51 -
What?! The world outside the village is full of villains.
Saulo Delanova is a young Amish. He doesn't use electricity, travels by horse and carriage, and eats what he sows in a community with a traditional lifestyle, rural and voluntarily separated from modern society. A community that for foreign eyes is frozen in time. When he decides to experience the modernity that he heard so much about the cities outside of his region, a theft forces him to stop on his way to the capital city. The situation would be manageable if it weren't for a detail. In his community they live under the principles of nonviolence! In a world where each being is born with an identifying color, can summon a weapon and fight with the power of the elements -or what is known as trinity or three characteristics of a user-, villains abound because of this power that each person can easily use. Ignorant of the life in the country's most important city, Saul will have to face culture shock to adapt to this outside world unknown to him, and to the people and events that will make him fall into the bowels of the world of temptations. Cover illustration by Demizu Posuka, illustrator of Yakusoku no Neverland (The Promised Neverland).
8 166 -
Skyspurned
The sky cities are the last and greatest refuge of mankind, enormous floating slabs of rock and soil magically suspended thousands of feet above the Surface where Aether leaches into the atmosphere through great Rifts in the Earth's broken core, inflicting many with the curse of Aether sickness and giving power untold to the chosen few. For the Apt elites, who have discovered their Aptitude in manipulating the Aether around them, the world is a beautiful place, the open skies their only limit, and the abandoned Surface beneath their feet a trove of spoils awaiting new owners. For many that make up the rest of the Knackless masses, the world remains as it always was, but for those cursed few Spurned by even the touch of Aether, sometimes the best one can hope for is to be ignored.
8 151 -
Rage: Crisis / Consequence / ???
Its been ten years since Seth was given his powers, ten years since his town was driven mad by that very same power, and ten years since its source was shunted into his head. A species of energy beings, a people filled with regret for what their entrance onto this world caused. Regret for the deaths that town perpetuated, the devastation they brought, the blow they served to the once proud heroes of this world. Heroes Seth now hopes to join, hopes to heal and atone to for what transpired. But their wounds run deep, their ire sharp, and their acceptance thin. And to top it all off... Seth's power is run far deeper than he knows, and sees his world in a light all its own. This series is my first foray into authoring, with two parts out of at best four if the readership stands. But part three will still book end nicely otherwise. And I'm not stopping till then. It is action heavy with varied and ramping up fight scenes through out. (Book 1 is heavy / Book 2 a little lighter) It is bloody in places, mildly gory in others, and heavily gory in simulated places. Nothing truly horrifying, I think, but be warned. It has trauma. PTSD is a major part of the story, but I will never trust that I got it completely right, so your mileage may vary on how believable or impactful it is. Lastly it has language. Swearing ebbs and flows as the story progresses and attitudes harden or soften. Sometimes bleeding through into the narration... somehow.
8 68 -
Project Goddess || Percy Jackson x Reader
One day on Olympus, the gods agreed to test their powers and see what they could do. Which resulted in them creating a whole new goddess named (Y/n). (Y/n) must train and learn how to survive as an immortal goddess. But when the Fates arrive and tell the gods they have altered time in an negative way when creating (Y/n), they must send her to Camp Half Blood and live a life as a demigod without anything knowing she is a goddess. At Camp Half Blood she meets a certain demigod named Percy Jackson.[A/N] I wrote this when I was twelve, so I deeply apologize uhh this whole story is a mess[percy jackson x f!reader]
8 78