![]() ![]() The first thing we need is a pair of new variables to store the x and y position of the star. We're going to place a star somewhere in the window, and once the user runs into it, it will appear somewhere else, Hence the name, Chase the Star. ![]() Since both start at zero, then the highest x value we can accept is 79, not 80. x increases as you go right, and y increases as you go down. Now, you'll find you can't run off the edge of the screen! If you're scratching your head a little, just remember that (0, 0) is the top-left corner. The console is usually 80 characters wide and 25 characters high, so we can check the player's position to ensure she never goes out of bounds: Towards the end of yesterday's article, you might remember that we had a problem when the user runs off the screen. A break statement must be placed at the end of all case and default sections. This works pretty much like an else: it is used when none of the case values apply. Optionally, we can also include a default statement. Then, we put a case statement for each value that interests us. In the brackets next to switch, we put the variable whose value we are interested in. When you have a bunch of if statements checking the value of the same thing (in this case keyInfo.Key), it is more convenient to use a switch statement instead, as follows:ĬonsoleKeyInfo keyInfo = Console. In yesterday's code, we had a bunch of if statements that check whether the arrow keys or the ESC key was pressed. We're going to learn about switch statements, randomness, and add a touch of colour to the game. In today's article we'll implement some basic gameplay in our console-window-based game, Chase the Star. ![]() So if you missed it, read it first! :) We're going to continue from the code at the end of that article. This article continues where yesterday's article, C#: ASCII Art Game (Part 1), left off. Hard to tell in the dark from this distance.Hello, and welcome to this second article about creating an ASCII-art game. Niley had a gun, a semiauto that might hold eighteen bullets if he'd modified the clip. Three more shots hit the bushes where I had been. He had a high-powered rifle and was searching the darkness.Ī bullet hit the tree next to my head, and I rolled back into the underbrush. Wilkes stood not eight feet from me, to my right. She opened a mouth full of fangs and snapped them near his face. Roxanne appeared on the other side of the tree, just there, like magic. Or couldn't complain that they got cheated out of a stolen object. Then they'd be too embarrassed to go to the police about it. I'd promise them something, but it wouldn't be real. I'd been using my powers to get myself in good with wealthy people who weren't so careful about the law. So many horrible memories, and you usually end up working with the police for no money. You know how hard it is to make a living as a clairvoyant. I was both happy to see her still fighting and sorry that she hadn't passed out. I thought at first she was unconscious, but her hands flexed and strained against the ropes. She was tied naked to stakes driven into the ground. The palest thing in the clearing was Charlotte Zeeman's skin. But there was nothing but darkness and a silver wash of moonlight. In the movies there would be an altar and maybe a fire or two, at least a torch. If you kill us, all you can do is watch Charlotte die. Niley yelled, You cannot cross the circle, Anita. I was liquid and barely contained within my skin. It was like my skin expanded outward, touching every tree and bush. I'd never been so aware of the scent and sounds of a summer night. The marks with Richard were open and roaring. A moment of concentration told me where they were. Jason and Jamil were supposed to be on the other side of the clearing. Nathaniel and I lay on the ground at the line of trees, watching. If he ever finds out I tricked him, he'll kill me and have Linus feed my soul to that thing. They're going to kill Charlotte to try and find something that isn't even here, you asshole. I could feel it growing, swelling, like a dank, unseen fog. But they were miles away, and the spell was almost complete. I felt Richard and the others moving through the trees like a solid wind. They'd chosen the top of a hill that had once been meadow, but some time today they'd bush-hogged all the grass and meadow flowers so that the hill was bare and broken under the moonlight. I wasn't sure how badly he was hit, but I'd hit something. I pulled off one careful shot and he went down. I sidled up to a tree, leaned my arm against it, and sighted on his shape in the bright darkness. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |