From: "Sebastjan H." Date: 2012-09-30T17:10:54+09:00 Subject: Re: still learning by doing - connecting rooms in a game Sebastjan H. wrote in post #1078040: > Sebastjan H. wrote in post #1077994: >> I've try to follow the above guidelines. I've read about the inheritance >> and the templates as well. I'm going to use the templates and the >> controlling object would be my runner. >> >> So far I made the super class Room and modified the subclass >> ChildBedroom. >> It plays out ok and the room returns the value of the next room to be >> explored. I still haven't figured out how exactly I am going to do that >> in the runner, but I haven't played with that much yet. >> >> I haven't learned about the testing yet, so for now to test it, I am >> just running the ChildBedroom.rb where I've put the childreen_room >> instantiation at the end. >> >> Can anyone have a look if I am on the right track with the relationships >> between the two classes? >> >> > http://bazaar.launchpad.net/~sebastjan-hribar/zombies/trunk/revision/8?start_revid=8 >> > I've also just added the amended runner.rb. I used the same logic as in > another learning game from the book learn the hard way. Now I get the > conversion error, because what is returned by the room.state can't be > passed into the loop again dut to type error. This is the last version of the code for the runner object: ------------------------------------------------------ ROOMS = {"side_hallway" => side_hallway, "child_bedroom" => child_bedroom} def runner(map, start, zombie, player) next_one = start while true room = ROOMS[next_one] puts "\n-----------" next_one = room.enter_room(zombie, player) end end runner(ROOMS, "child_bedroom", zombie, player) ------------------------------------------------------ The map isn't complete yet, it's just for the testing purposes:) I think I have the basic mechanics in place so I can focus on the rest of the content. I now it's probably not the optimum design, but at least I hope there aren't any major errors. Any feedback is most welcome. regards seba -- Posted via http://www.ruby-forum.com/.