Need some advice on exercise 43

So I was pretty much blazing through the book and doing really well until I hit Ex 43. I’ve been at it for 2 weeks now trying to turn that skeleton of classes into a working game. I haven’t yet looked at the solution and I don’t think I will until I find a way of solving it myself.

Some things I’m trying:
I figured that the scenes proceed linearly so is the map even necessary? Why not get each scene to call the next one once a set action has happened?

I’m writing comments in English describing what I want each object to do and then trying to get it to do it.

I’m wondering is it normal to struggle so much with this exercise? Considering going back a couple of exercises and re-doing them.

Just look at the code, you’ve tried and couldn’t do it, I don’t see why you are punishing yourself. Two weeks is good length of time to spend on it. I personally found it very difficult and yes I looked at the code.

It depends, but explain to me how you wrote the code. Did you sit down and crank out the whole code without running it? Or, did you build it up a tiny bit at a time like I did?

For example, if you coded up every room and tried to get it to work, then that won’t work. Instead, you make one room work with no content. Then the next room work, no content. Then add content to one room. Then a bit more to the other room. Etc.

The reason I suspect you might have done it this way is usually when someone says they couldn’t get it to work, it’s because they didn’t build it up in tiny chunks that keep working the whole time. Instead they try to write a lot of code and make that work.

What you might want to do is just ditch all that code and start over. Sounds like that’s a total failure but chances are if you start over, building it in little pieces that keep working the whole time, using what you already learned, then you’ll solve it.

A final comment: You say “it isn’t working” but you don’t really have a link to code and aren’t describing what’s not working about it. Drop in a link to the code and a list of problems you’re having.

Dear zed and tcratius,

Thanks for your help! I took your advice and basically started the exercise from scratch. It worked. Looking at it with a fresh set of eyes made it easier to design.

To answer your question I wasn’t trying to build it all at once but what I ended up doing was trying to write a text input parsing engine and ended up falling into a bit of a rabbit hole.

I didn’t reach the exact same solution you did but at least I got the code working as described in the brief.

Thanks again!

I’d say of the two comments, Zeds was more useful, and wow, you figured it out. That’s awesome!

Bingo! I’m a firm believer in setting fire to old buildings. I do this thing where I hack on a solution and go down a terrible path, and rather than try to recover, just delete it. You don’t really lose anything because you learned a whole bunch so your second time around Jack should do a cleaner and smoother.

1 Like