A Thing’s Properties, Getters and Setters   Leave a comment

So it had been my intention to write up the values for a small world, and run it through the logic internally to figure out what classes and things I’d need. Well as I worked on it, it gradually became clear how difficult it would be to track which thing is where in any text format. So, I’ll take what I’ve already learned and start coding up the classes now, and I’ll just have to modify them if I missed something. I’ll probably have to anyways, eventually.

I had considered making the world editor right now, to make the files, but I think that should wait untill I have a solid idea of what goes where. For now, I’ll hardcode the worlds. It’ll be much easier to do in code, where I can make clear references instead of just saying “This thing is in that thing” and having to look it up myself. When I do make my world editor, it’ll have to clearly show the connections between different Things. What Space you’re inside, and what Things you’re connected to, including contents, inventory, and for exits, where you lead.

So that brings me to the next step, which is the step I was working on before. I’ve got to define the Thing class.

I’ve already got the properties set up, except for the contextMenu, which is commented out ’cause I don’t have a contextMenu class yet. I’m going to use getters and setters for all of the properties, ’cause a lot of them have important limits.

After a quick experiment, I see that FlashDevelop can generate default getters and setters for class properties. Way to go, FlashDevelop. You get a gold star.

Now let’s see, do I want to measure orientation in degrees or radians… degrees or radians… I think I’ll go with degrees. It’s what I’m most familiar with, and it’s nice and simple.

*write wirte write* Okey dokey. Now when you set the x orientation, it has to be between 0 and 360, and if it’s not, it’ll circle around. So, setting it to 370 will give you 10, and setting it to -10 will give you 350. I am so awesome. Now to copy that setter for the other rotation properties.

And durability is a percentage, bound between 0 and 100.

*work work work* It would be nice if I could use my setters as the arguments for the constructor function, instead of having to come up with a third name for the parameters.

Hmm… I guess with all the getters and setters I don’t need to have all these optional parameters in the constructor. I’ll just leave it at name.

Hmm, I’m pretty much out of time, and I’ve only finished off the properties. I was hoping to get some or all of the methods defined tonight, but I guess it’ll have to wait.

Posted March 22, 2012 by Arthur Payne in TextWorld

Tagged with , , ,

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.