《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
-
In Serial102 Chapters
My Life is Not a Manga, or maybe...
Xavier had a happy, humdrum life: normal friendships, a normal girlfriend, a somewhat oddball family. Until, that is, he literally stumbled through the fourth wall and discovered he was the protagonist of a manga. Now he's scrambling to maintain any semblance of control over his own life in the face of something he never imagined he would need to contend with: the power of the Genre. Hello, E.O. Tenkey here; thank you for your interest in "Not A Manga"! This was my first serial novel, and I hope you enjoy Xavier's predicament! Familiarity with manga not required (though it can't hurt)! I look forward to exploring the bounds of the Genre with you. (First volume is rated PG-13 for comic mayhem and light profanity—these are high school students, after all. Second volume is rated PG-13 to R for some violence and similar levels of profanity. Tags may or may not contain spoilers.)
8 220 -
In Serial39 Chapters
Haven in a Dangerous World (Old)
Devin McMullen. Female. 18. Single dad. Dead mom. Good in fights and little else. No friends. Or, at least, that's what she's always been. Now, she's not sure exactly what she is. She's never been one for reading fiction, or anything for that matter, but this feels like something straight out of a fantasy. Her newly acquired instincts, however, scream dungeon core. Whatever that is. Unlike most dungeon cores, though, she's missing something very important. A dungeon. Stuck out in the open, above ground where she's definitely not supposed to be, with not a cave in sight, or any other land form besides miles and miles of ice and snow, Devin's not sure if she can survive. Update: Big caveate, though, just so you know. Started with this one idea and ran with it as far as I could. Characters and plot suffer from it, but I'm proud that I wrote as much as I did. I will rewrite this at some point and make it so it actually has plot. Check out my wordpress © [koallary] and [Haven in a Dangerous World], [2017]. Unauthorized use and/or duplication of this material without express and written permission from this site’s author and/or owner is strictly prohibited. Excerpts and links may be used, provided that full and clear credit is given to [koallary] and [Haven in a Dangerous World] with appropriate and specific direction to the original content.
8 147 -
In Serial16 Chapters
The Elementalist
The world was thrown into chaos as humans all over the planet were taken to participate in the Trials. A contest to separate the strong from the weak. Each human was given the chance to prove their will and grow in order to survive. Little did everyone know that before this all happened certain individuals were taken to test out the system. Tide was one of those individuals and sadly failed to survive. Instead of dying he was just brought back into the main event when everyone else began. Having a second chance to do better Tide prepares himself for what is to come. Ps. cover image isn't mine. I am just using it as a place holder for now.
8 156 -
In Serial19 Chapters
Interview With the Hattoris
Yuko Hiragi is an aspiring journalist. She goes about her internship with hopes of scoring a big scoop so that she can be set with a nice job after she graduates college. When she gets an opportunity to interview the corrupt and powerful Jensen Skagg, her dreams of fame become dashed when he is murdered before her eyes by a mysterious assassin. She is soon thrust into the dark world of murder and intrigue as she is hosted by the ancient and powerful Hattori family.
8 128 -
In Serial7 Chapters
UNDERVERSE BOOK 1: Shadows of the night.
George Winters has always craved for power, it was his first memory and the only one he truly cherished. So when he finally sees the opportunity to have all the power he ever dreamed of through James Versity, the firstborn son of one of the most successful businessmen in the world he jumps at the opportunity. But just how far will one man go for power? And how many will he drag down with him?
8 208 -
In Serial16 Chapters
The Test of Time
This is a Brett + Eddy fanfiction, a Breddy if you will. Please read the note at the beginning so you know what you're getting into!
8 78
