Due to unforeseen circumstances, I got a little sidetracked from doing OOP and am now coming back to it.
Exercise 43 is really the first exercise I feel like I can’t get past. I gave it a try, went back a couple exercises and did those all over again, but to no avail.
I understand the core concepts of OOP. It’s just actually using them - writing them out in code - that gets me.
I’m certainly going to keep at it until I get past this exercise, but any other recommendations for smoothing out the path? I’m not spitting out giant blocks of code and hoping there aren’t any bugs - I am only trying one scene at a time, and once I get that running I’ll go onto the next one.
Hi, can you describe the process of trying one scene at a time and how you understand the concepts of OOP?
Also making a master copy of ex43 hugely helps!
You should follow the instructions here in the image I am attaching then have the original code in one room, and the copy you are writing from memory in another room. Put it all down on paper.
Also I believe you are not enrolled in the Learn Code the Hard Way course? Zed has very useful seminars on coding techniques.
Being part of a group that learns to code with the personal feedback from Zed helped me hugely.
There you go:
Enrolled? I don’t think so. I’m currently going through his book. Is he offering online seminars, or something I’m not aware of?
I’ve been hesitant to do this in the current exercise since in Exercise 43 Zed says not to look at his code until you have your own. He did mention “cheating,” and taking a peek at his script, and I did that and I generally understand how it runs (with some minor confusion here and there). I annotated it with comments and whatnot. I just can’t really translate my general understanding of OOP into actual code.
Well yes he has an experimental course where people go through the books and get direct help from him. On top of it there are weekly seminars on lots of topics. Message him privately here on the forum for the details.
Hi @nmaloof94, I don’t think I say do not look at my code until you have your own. Can you screenshot that because that’s definitely not what I recommend now and should not be in the book.
I believe what I say is that you should not do your own version, until you have copied and understand my version. And, that you should do my version in small pieces rather than trying to type the whole thing in at once.
So, screenshot me where I say that so I can correct it, and then go do this:
- Copy my code and get it working. REMEMBER TO DO THIS IN SMALL CHUNKS AND RUN YOUR CODE A WHOLE LOT OVER AND OVER OBSESSIVELY AS YOU CODE.
- Try the mastercopy practice that @io_io posted so you understand the code through trying to memorize it. Remember that you are really trying to memorize the structure and concept of the code, and then from that you can generate the actual code. This exercise is not about memorizing character by character.
- Then try doing your own game, but start with my shell. Strip out all my rooms and do your own rooms. Then see if you can make the engine better or maybe add a little feature. Some people added a combat system to fight a monster.
That’s all. Finally, the biggest mistake people make with this is thinking that they should be able to glance at the code and go “oh yeah I totally know what’s going on”. I don’t do that and no professional I know can do that. Every time I sit down with code I take it a part a little at a time, do a lot of debug prints, diagram it, and try to trace what functions/objects are calling what functions/objects and what data they are passing to them. YOU CANNOT UNDERSTAND CODE BY READING IT LIKE A RESEARCH PAPER. You have to run the code, and trace how it runs, noting what object talks to other objects, to understand it.
And take your time. This isn’t a 30 minute thing, this is a 1 week thing at least. Always remember that everything you need to understand the code is there. There is no magic in code, as the computer needs everything to run the code. You just have to print out things you haven’t printed yet, and determine what’s really going on to understand it, and that only comes when you run it.
Sure, I’ll include a screenshot here.
I may have misunderstood, but either way, I’m glad I have a better understanding of the instructions now.
And alright, yes - I’ll do that. I’ve been able to map out the program and annotate all of the script with comments, so now I’ll go through the CASMIR process, print and memorize the structure and eventually translate that into code.
Awesome! I sent him a message. Thanks!
Great, I’m going to change this then and tell people to use the new process. I found it works better.
Yes, I find this to be much more doable.
Glad I saw this - looks like the book still advises trying to come up with the code before looking over Zed’s code.
OK, this is interesting. I also understood ex 43 as telling me to write my own game, then look at Zed’s.
I got a little ways into it, including my own implementation of randomizing the outcome when you choose an escape pod. Except my way, you get a 50% chance of good outcome, instead of 1 in 5 (20%) shot.