《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 Serial26 Chapters
I, The Lightning
In the world of Foronea, power rules, and for the 80% of those who don't have any power--The Mundane--life is hard. Really hard. Emmanuel Burroughs has had enough. Enough of being pushed around, and spat on. Enough of having his friends and family harassed just because some asshole decides he can. Enough of the nobles using The Mundane as little more than cattle. And he knows just what to do about it. Godking Samuel Lionheart, ruler of Terralane and most powerful of the four god-rulers of Foronea, allows every citizen one attempt at the 'Trial of Blessing', a grueling test of wit, strength, and overall competency. If the challenger wins, they receive a Blessing, a power that manifests a unique form based on the user's personality. The better they do, the stronger the Blessing. Emmanuel's plan is simple; get an S rank on the Trial, and get a Blessing strong enough to overthrow those at the top, fixing the problem with his own hands. But when Godking Samuel makes Emmanuel his Chosen, with a Blessing miles beyond his expectations, Emmanuel finds that being the capital h Hero isn't all he thought it would be. And before he saves anyone, he'll need to figure out how to stop his own power from ripping himself apart. ----------------------------------------------- Hello! Author here! Updates Every Friday! Chapters are anywhere between 2k and 8k words long. So, some warnings; -This novel contains a rather high amount of swearing. Thats just how it is. I like swearing, its in the book. -This book is LitRPG, BUT it takes a LONG time to get there. This is a much slower burn than most other LitRPG, so please keep that in mind.
8 391 -
In Serial28 Chapters
Defy the Heavens?
Hey there, Dear comrades, I am just a common guy from a common background. How should I say this.. I died on earth, old age of an old illness. something that could have been prevented. How did I reincarnate? No idea. For almost ten years, I assumed I was just like any other kid. Maybe blessed by the heavens but I was a commoner all the same. However, stuff happens and here I am trying to meek out an existences for myself. You know how it is. Killing enemies with epic sword skills, purifying the souls of barbarians with fire, walking in mid air like I am superman. Haha, just being a typical american in not so typical fantasy world. What's the worse that can happen, right? What's so hard about defying the heavens? Didn't we used to defy our stomachs by ordering taco bell? Or how about defying our presidents by voting for their rivals next election date? Ha, these are soo much more complicated process than simply killing off the annoying people. Cutting down heavens when they stand in our way, and enjoying life to the fullest? I mean, this is the american dream!
8 141 -
In Serial16 Chapters
Real Time Reality
Erik was just an ordinary teenager until one faithful camping trip. He was thrusted into a world full of monsters with powers that could only come from comic books. Armed with the power derived from one of his favorited gaming genre, could he stop the hidden mastermind behind this game of life and death, all before the demon devoured his soul from within?
8 128 -
In Serial9 Chapters
Mana Tank Magus
Jonathan Orville has had a thoroughly enviable life, completely devoid of pain or suffering. Though his life is tragically cut short due to a sharp rock, he would never regret his perfectly positive life where nothing bad ever happened to him, ever.Even though he doesn't regret it at all, he still finds himself summoned to the netherworld for a new adventure as livestock for a needlessly attractive demoness who is totally probably in love with him.This is a story about using the power of positive thinking to overcome adversity. Demonic forest fires, consumption of souls, rivers of blood and rampant carnage; none of these can get in the way of a dedicated effort to think positively.Newest chapters at: https://manatankmagus.wordpress.com/This location is likely to stay a bit behind. I am very lazy. :DDISCLAIMER: My primary purpose here is Comedy rather than badass skills and righteous adventures (although there's some of that too). The main character can be a little bumbling at times and has a much higher opinion of himself than justified. If you really dislike that kind of thing, this is probably not for you.
8 175 -
In Serial26 Chapters
A Man and His Greatsword
Michael Adkins is a unique 28-year-old man. Born with above average strength and emerald green eyes, he always wanted to live in a fantasy world. He was very much into fantasy light novels, manga, and anime, especially a certain one that involves a black armored man with a large greatsword. Michael always dreamed of going on an adventure in a fantasy world. On a whim, Michael is summoned by the god of Alorah, one of the fantasy worlds he had always read about! Alorah's God, Eden, gives Michael a choice of three bonuses and a custom class to take with him into Alorah. This is the start of Michael's fantasy adventures. P.S. This is my first novel, I'm writing this since there were little novels I've found with a main character that wields a greatsword. Don't expect anything good. There will be a lot of mistakes, so please help me with that! P.P.S The later chapters will (hopefully) be much less cringy than the early ones. Please give it a shot!
8 58 -
In Serial23 Chapters
Fortnite: The Great Flood
Skye and her friends, as well as some new faces, return in the sequel to Fortnite: Quest Buddies!After her parents' deaths on a mission, Ocean Azure must go to The Fortilla to do some paperwork... but ends up becoming a secret agent instead! Along with Skye Nimbus and her agent friends, Ocean learns the history of the island, and discovers that secrets are hiding under the deep blue surface. The Fortnite: Quest Buddies Series:Book 1 - Fortnite: Quest BuddiesBook 2 - Fortnite: ALTER EGOBook 3 - Fortnite: The Great FloodBook 4 - Fortnite: Golden SkyesBook XX - Fortnite: The Agent Files
8 73
