today im doing some coding on a text based game from scratch. this is an old school choose your own adventure style text based game called choose your own demise. if you want to learn the basics of c# stop on in! so far so good. come and check it out! dont forget to hop into the live chat and ask some questions or just hang out!
Want to send me something? Technivorous 902 n Hughes Blunt Sd 57522
Alright, and we are back. I am TechNibbers. Today we're doing some coding. I decided to
alter the trajectory of our little path here, and today we are going to be
making a choose-your-own-adventure game called Choose Your Own Demise,
and definitely looking for your guys's input on things. So feel free to jump over into the
live chat. Now remember, you'll only be able to chat if you are a subscriber. If you're not a
subscriber, you won't be able to join in on the chat. So make sure you hit that subscribe button.
There's no time delay. You don't have to wait a certain amount of time. You can pretty much
start chatting as soon as you subscribe. So one second here while I finish getting
things set up, and then I'll go over what I did here to create a new project. So
bear with me guys. See if a few more people jump in here. Like I said, if you have any suggestions
for the game, feel free to pop them out in the live chat. I do have some pretty decent ideas
myself. There are a few things we're going to have to set up before we jump into the actual
gaming itself, but it's going to be kind of a build-and-play-as-you-go sort of scenario where
one more here. I'm almost done. We're making it as we go along obviously. All right, so
let's see. So over here you can see I have the configure your new project. I have chosen a
console application. I'm using C sharp, and it is going to operate on Linux, Mac OS, Windows,
and in any sort of console here. So basically what we have done is named our file, and that is it.
We are using C sharp today, and it is going to be net core 3.1 because it is supported long-term.
So let's save the changes to that project. That was the project I was working on earlier. If you
were in here watching the live stream, you might have seen some of that. It's just a little console
app that I play around with now. We're going to go ahead and leave Hello World there for
just a moment. Right now we need to go ahead and go in here and create another class while I'm
thinking about it. So we're going to right click on this and click add new item, and it should
allow us to do a C sharp class. And this class we're going to call inventory. Go ahead and add
that right now. We don't have one of those, so let's do public static inventory. Okay, so we need
a constructor here. I'm not going to pass anything in. I just want to be able to access it and make
it equals new. All right, so we'll get to that in just a minute. Let's write our first line. This is
going to be our introduction. It is not going to be Hello World. There's going to be a lot of
typing. So like I said, suggestions, throw them out there. It's dark. You have awakened with a
nasty headache. You can't see a thing. Okay, so this is foreshadowing, pretext, whatever you want
to call it. Basically, we're starting to write our story. We're going to tell you how you've come to
this place that you're waking up in as we work our way through the story. So I'm not really worried
about grammar and things like that. More playability and the fun of the game itself. Next thing we need
to do is let's go ahead and add one more class and we're actually going to call this level one.
Simple enough. And in here, obviously, level one. All right, don't need anything to instantiate right
away. Let's go into our inventory. Basically, what this is going to be is a bunch of public
booleans. The first one is going and they're each for an item, whether or not we have it.
Lighter. That's a good one for in the dark. What else could we use to light up the dark?
Public pool lantern. All right, hold that thought, folks. I'll be back in one second.
All right, sorry about that. Obviously, I got bills to pay, but my son was getting a little
angry there, so I had to check on him and make sure he was doing all right. He is good
and he is falling back asleep. He's just kind of fidgeting a little bit. So
let's see here. So now I have a lighter and a lantern. Both of these
off the bat are going to be set to false because I don't have them. And public pool
flashlight. This one we do have. Let's say we have a flashlight. So let's go back to
level one. You can't see a thing. You feel something in your pocket. There we go. All right,
so let's encourage the player to check their pocket. So the first thing we need to do
is after we've written that line, we're going to do this. We need to public static level one
one equals new. Okay, so here we are. We have this guy and it's dark. You've awakened with
a nasty headache and you can't see things. So the first thing we want to do is level one
begin. Now we don't have that class in level one yet. So what are that method in level one.
So let's go over here and do private void begin. So once that's done, we are going to go to a
read. So let's do let's do this this way. Not in capitals, of course.
I'm just checking on something real quick. There we go. Okay. All right. So private void
input string. And we're going to do a run this method on console. So whatever's typed in,
it's going to check. So let's say type input string million times.
String is equals string. Okay. There's a little bit your pocket appears to be a flashlight you
remove from your pocket, it feels heavy, it must have batteries inside. Okay, so if you type pocket,
it'll print that. And then we're just going to use the same method a couple of times. And then
we'll use something else. So if else equals equals flashlight, we'll start with just
flashlight. So we don't need to turn it on and off yet. I think we might make that a possibility
later, but just flashlight. So I've streamed flashlight, then we are going to we're gonna
make a loop here. Here. We call them keywords. So let's stick with that. No keyword found. Okay,
so basically, it's written nothing, this is where we're going to continue our story,
we'll break out of this, and we'll go into a different method.
Let's test this out and see how it's working so far, though.
Again, inaccessible due to its protection level. So that is because I must have it set.
Yes, private, we need to set this to public to make it accessible from the static method we're
using. So let's try this again. Program choose your demise. Go. It's dark, you awaken with a
nasty headache and you can't see a thing you feel something in your pocket. You can interact with
the world by using keywords try saying pocket large lump in your pocket appears to be a
flashlight, you remove it from your pocket, it feels heavy, it must have batteries inside.
We need to break that up into some new lines that's easy enough to do.
Flashlight. Alright, so we've turned on the flashlight and now nothing is appearing here
and that's because we haven't put anything in. So let's do this. Let's
we're actually going to get rid of this whole setup here.
We're going to do is go to another method. So lights on. So we have this method here.
comes into view. Just actually here. I want to do ceiling doors. How did you get here?
So yo, if you have any suggestions to make this spookier, creepier, better,
let me know in the comments. You gotta be a subscriber to comment.
What's up, Todd? I'm kind of just concentrating on this trying to read the comments. There's
not much popping up yet. So I'm not looking at it too much, but hope you're having a good time.
I before E except after C. Except in words like neighbor and way.
Okay, so whatever. I don't know how to spell ceiling. This is okay. So then I'm gonna go
into another check input like this except lights on until the read line. And we're just rocking
out here. Okay, so obviously, we're gonna want to take in another string. So str this time,
so I got to redo all that. Let's if string equals look, and then the same way we did up here,
we're gonna call the same thing again. So we'll do a else if else. So we don't need this for the
else. Okay, and from here, we'll go to a different one. Because you actually changed it. And you're
seeing something else. Actually, no, we'll leave that there. And then we'll add another else.
So it tells you to look, but it doesn't tell you to examine. I want to encourage people to
use other words, we are going to sneak other ones in here. And it's going to be part of the part of
the game trying to figure it out. So if you say crack, crack, we'll do something there in a minute.
Else. Alright, so we have to be able to follow the logic of this through. So let's make sure
that we can. We know we can get to here, let there be light, the room comes into view,
your eyes adjust, blah, blah, blah. So use the command, you can look, you can grab.
So far, grab doesn't do anything, we will change that.
Right now, if you look, it doesn't do anything. But if you try a different word for look,
examine, you'll find the crack in the wall. So the thing about this is with nothing turning on and
off, we can simply just type, hit crack here, and it will skip all the rest of this. But
seeing as how technically the first time the end time user won't have played this before,
it won't really matter, because they won't know that. So room comes into view, and your eyes
adjust to shine a light all around you. There are four white walls, a floor, a ceiling,
and no doors or windows anywhere. How did you get here is a very ambiguous statement there.
Alright, so one of the things that we did do was use an item from our inventory,
without actually altering the inventory itself at all. So what I want to do now is make sure
that I have done that. So in my inventory, flashlight is true, that means that we do
have a flashlight. But I want to make sure that that is the case. So since I don't strictly need
to do this since we don't have to find the flashlight, I'm still going to check just
because I'm going to show you how to use the inf.flashlight. And we need to go ahead and get
our static inventory case here too. So if we don't have a flashlight, we'll start over. We do have
a flashlight, so this really doesn't matter, but I just wanted to show you how to use this. If you
do something, if you didn't have it, exclamation point there. Alright, so let's run this again.
Okay, breakout. Now, let's see. Alright, so once we do that,
console, clear. Nah, this is getting too long again, so I need to break this up.
Okay, and then we're going to do the same except here we're going to do BO, input, console,
to doubt. Alright, so this will be our first death. Don't want to go right right out of the bat.
Like I said, if you have any ideas, throw them out there. Alright, so we're going to have a
giant minotaur pop out down at the end of this hallway and just freaking devour you. Console,
right line, as you reach the end of the beast. Alright, so there it is. That means you have
lost the game, and here we will not actually read a line. We're going to put that in
just because it's a good stopping point for us. Here instead, we'll go on to the next,
maybe we'll do level two because this is starting to get a little bit long.
No, I think we need to pick something up before we leave level one, so we'll go into something
where we pick up an item and then we will leave level one. So, console, let's see what happens.
See if we can get all the way through our choose your own demise adventure here,
and my goal this time is going to be to go right and get that ending there.
I should have cleared that first, so obviously we're going to check our pocket. We're going to
turn on that flashlight. We're getting an exception. Oh, you couldn't see me typing
that anyway. That's okay. This exception is being caused because I did not instantiate this.
That should actually do it, although I probably need to do it in here too,
which means I'm probably gonna have to save data back and forth.
That's not a problem. Classes talk to each other all the time. It's kind of the point.
I have to get some more coca-cola here in a minute. Okay, let's try this again. So,
pocket, fix that. It's driving me nuts. Sorry. All right, now we'll try it again. Sorry,
it was annoying me. That's much better. You find yourself in a dim without hallway. You want to
turn off your flashlight and save the batteries. Hallway goes to the both left and right. Pick your
path. You reach the end of the hallway and around the corner, you run smack into a large foul
smelling beast. Its long teeth dripping drool as he eyes you up and down. Try to put up a fight.
With his giant muscular arms, he tears you apart. You have chosen your own demise. All right, so
that is the first death in Choose Your Own Demise. We will continue on here in a little bit. I am
gonna take a little break, so don't go too far. We'll start another stream up in about 20-30
minutes and we will continue where we left off.