by tlaero » Sun, 10May02 12:08
Okay, time for some technical talk. You’re welcome to try the game without understanding any of this stuff. This is for Phreaky and others who are interested how these Virtual Date games work.
Phreaky, if you look at the HTML, you’ll notice that it’s significantly simpler now. Hopefully, it’s also easier to understand than it was in the past. The magic that simplifies the code is two extra files in the “Amy” directory. You should take a look at styles.css and functions.js.
Styles.css:
This is the stylesheet used by all of the HTML. By moving it into a single file, you can update the look of the game by changing just that one file. Want the background to be blue instead of black? Want the “this is what I say” links to be red instead of yellow? This is where you do it. More importantly, this is where you set the image sizes. In your game, you made most of the pictures 600x500, but the actual images are bigger. The “img” tag in the stylesheet sets the default image size for you. If in your next game, you use a different image size, you can change it there. I also did alternate sizes for the other image sizes in the game, but I don’t think I have any examples that use them yet. Ideally, you’d make all of your images the same size, and make them the size the game needs, but the styles.css file covers you anyway.
Functions.js:
This is where the main javascrïpt functions live. They’re broken up into two groups: functions that change the variables and functions that disable the navigation. As with the stylesheet, by having them in one file, you can make any changes in one place and have them take effect everywhere. (As an aside, Erana, I remember your complaint to Chaotic about the navigation disabling functions. If you look at functions.js, I think you’ll find that I addressed your concerns.) You shouldn’t need to change functions.js, but if you have any questions about how any of the functions work, don’t hesitate to ask.
We still use cookies, but now we do things based on the cookie’s value. This allows us to do a lot of neat things. The two main functions you’ll use are “varPlus1” and “varMinus1.” These let you add and subtract one from a variable. In Amy Redux, I’ve got three main variables, amtHappy, amtAroused, and amtAngry. When the player does something that makes Amy happy, I add one to amtHappy. If he does something that makes her mad, I add one to amtAngry. There are places where he apologizes and I take one away from amtAngry, etc. To have sex with Amy, the player needs to get her happy and aroused without making her too angry.
Take a look at _begin.html. This is where I initialize all of the variables in the game. Note the various “max” variables. For instance, I set “maxAngry” to 4 at the start. Then when the user does something bad, I add to amtAngry and check if it’s still less than the Max. If not, the player loses.
By making a maxAngry at the start and doing everything based on that, you can change your mind on how angry she can get and change it in one place. This also allows you to do “difficulty levels” in your game. Imagine if the player started by clicking “Easy” “Medium” or “Hard” and, as a result, you changed the “max” variables. Maybe on Easy she just needs 1 happy and 1 aroused to have sex with you, but on Hard, she needs 4 each. If this isn’t making sense, ask. I’ll give you examples.
I took out the bit where it asks your name, and then Amy only says your name once. I’ve never liked that concept. People invariable type silly names and then giggle when she calls them the silly name they typed. I’d rather the player be assigned a name and she use that. Besides, in the future we’ll add sounds to the game and things will go much better if she can cry out a predefined name then. Still, if you really want the name thing back, let me know and I’ll find a clean way to do it.
Also take a look at _dumpvars.html. When you’re writing the game, it sometimes helps to get the current values of all of the variables. What I do while writing this is enable navigation, skip the Start.html, and, whenever something is weird, type in “_dumpvars.html” in the url bar. That shows me the current values. Then I back up and continue.
I don’t know how to describe the “check” html pages. How about if you look at them and then ask questions about anything you don’t understand? By using values, those check pages let you do just about anything.
I tell you. Having walked a mile in your shoes, I appreciate the work you’re doing even more. This stuff takes a lot of time. Doing everything by hand was too much work, so I’ve been writing a GUI tool that makes creating these games a lot easier. It’s not ready to distribute yet, but I’ve been using it to do Amy Redux. Hopefully I’ll be able to send out a workable version in the next week or two.
tlaero