Monthly Archives: May 2012

TextWorld Coming Along

So the essential game loop of my initial TextWorld will be something like this:

Respond to Player Input by performing the task associated with the link that was clicked.

Run down the list of active mobiles, updating each one

Check if the player’s location has changed, and update the Location text accordingly

Check if the player’s status has changed, and update the Status text accordingly

Add action text based on the player’s input and mobile actions, and bring the action area to the bottom of the scrollbar

Wait for Input

I’m bringing back the timing factor. Each action the player takes will take a certain amount of time, potentially zero if the action doesn’t do anything but open up another menu. Or long enough that an active mobile would be able to interrupt them. There’ll be a list of mobiles to see who goes next based on the time it takes to complete their next action. If they interact with the player, the player is given the option of a response. Likewise for mobile to mobile interactions and player to mobile interactions.

Each of the Update stages will require complex coding, especially for getting the text right. That’ll be the hard part.

I think my first task will be to set up the world tree, the list of space objects and their interconnections, and load that.

Then I’ll have to make the player object, and put it into the space.

Third I’ll have to develop the functions that assemble what the player sees, based on the location of the player object.

Fourth I’ll have to deal with the interaction between the player and the text links, to allow the player to move between spaces and perform actions.

After that I can start making mobs, widgets, and actually making the whole thing a game. But first things first; the world tree.

I’ll need to make a function that loads the world tree, to begin with. Eventually I’d like to have it loaded from an XML file, but for now I’ll do it all in code.

Hmm… I forget so soon, I was going to use a list of spaces rather than a tree of linked spaces. Load all of the spaces into an array or a hashtable, then have the exits lead to particular space numbers, since I couldn’t use direct references.

For now I’m going to make the description for the room all myself, but later I want it to be procedurally generated based on the room contents.

Okay it’s almost time for DnD, time to go be nerdy in a different fashion. Glayven.

Tagged , , ,

Let’s Get These Kids Talking to Eachother

So now that I’ve gotten over that bump from earlier, I still need to actually get this thing working. Right now I’ve got a basic interface set up with feeder text, but in order to have it interface with the TextWorld simulation, I’ve got to handle the link TextEvents it sends.

I’m also somewhat worried that I will be unable to make links appear correctly; that they’ll switch to default style and be unchangable by the font tag.

*tests it* Oh that’s a relief! It’s not underlined, and it’s the right colour. I will be able to carry on.

Right. So, I’ll make an event handler for link events next.

*work work work*

Okay I did a lot of stuff there. I set up a whole system of event transfers between the main object and its two children, the interface and the textworld. The main object carries the information across.

I’ve run into a strange bug though. When I set the location text, it appears where the action text should be, and when I try to set the action text, it says it hasn’t been defined. … ahh, here’s the problem; I didn’t change the names when I copied the code for the location and action texts. It’s a wonder I didn’t have this problem earlier.

*tinker tinker* There we go, now it’s working properly. The basic interface is set up, the rest of the work should be getting the TextWorld object to do its thing. That’ll be for next time though; it’s late and I have a family thing tomorrow, and I need to get some sleep.

Tagged , , ,

HaXe+NME is Back On!

Finally got a reply on the NME forums; someone suggested I might be able to use the font tag to do what I wanted. I’m so used to CSS, it hadn’t occured to me that the font tag could be used that way. I’m going to give it a try right now.

*try try try* I hit a bit of an issue but I managed to fix it; I didn’t realize I was setting the colour of the text after writing to the text property, overwriting the colours changed by the font tag. It looks like HaXe+NME is back on!

Tagged ,

Big Problem with NME, Jumping Platforms Again

So, despite going on about my l33tness, there’s some things I can’t or shouldn’t do. It turns out I’ve run into a very severe roadblock with HaXe+NME. Well, HaXe is great, the problem is with NME or specifically nme.text.TextField because you see, it doesn’t mimic all the functionality of flash.text.TextField and specifically it doesn’t have the Stylesheet parameter or any other way to change the colour of individual sections of text within a particular textfield. In otherwords, NME simply won’t work for what I’m doing, and I’m back to square one.

Well, before I was thinking of doing it with JavaScript, and I realized that not everyone has JavaScript, or is JavaScript capable. But everyone can view a PHP page! So, this’ll be the forth platform I’ve jumped to on this project. It’s starting to get a bit ridiculous, but such is life. If PHP doesn’t work out I’ll fall back to JavaScript; it’s an important part of the internet and an important part of advanced HTML5 content, so if you’re blocking it by default you’re going to miss out on a lot anyways.

*work work work* I’m just trying to figure out this neat Aptana IDE I downloaded. It can be an extension of Eclipse, but I downloaded the standalone. It’s interesting. I think I’ve got it just about figured out. I’ve gotta say though, it’s weird when I’m trying to figure out a program and all of the screenshots in the manual are from a mac and I’m running it on a PC. XD

*work work work* Okay I’m feeling comfortable with Aptana now, and the PHP makes sense after reviewing the PHP tutorial at w3schools. Love that site.

Notable problem; PHP has no Objects. I’m used to OOP. I could probably make it all work by using a database to store the data I would normally put in objects.

Frankly I’m still indecisive about everything else. Like Flash. I’m great for coding with AS3; I don’t need to lay about for hours reviewing the syntax and all that. Yeah, it limits the places my textgame can go, but there’s also the fact that they may add the StyleSheet to NME. I already requested it on their forum, and asked for advice in their programming area. No idea if I’ll get any hits there, but it’s something.

Right now I’ve got nothing up, and this is supposed to be my first ‘Give Me Money Plz!’ thing, where I make something you want and you give me money to make more. So, I’m not makin’ any money untill I get something playable. I need to stop screwing around and just MAKE the darn thing.

So, that’s that. Next time, back to Flash, untill NME gets what I need. Then I can translate it all to HaXe like I did with the scrollbars.

Not sure if I’ll keep using the scrollbars; they have issues. We’ll see.

Hungry now, and almost midnight. Break time.

Tagged , , , , , ,

There are Four TextBoxes!

Last time on ElectricSquirrel Z! I converted the scrollbar class from Flash to HaXe, which I can do because I am an elite hacker! Or an l33t haxxor, I guess. Well that might be an exaggeration, but considering how balls crazy this scrollbar system is, I think I have the right to be proud of converting it.

Next step is making four of them in preparation for the display.

*work work work* Well it’s taken a lot but I’ve got a second one up there. Rather than using hard coded positions I thought I’d try percentages, so that things would scale if the resolution was changed. But, I had a lot of issues getting it right.

Still not quite right, though. I’m not terribly satisfied with these scrollbars. Now that I’m actually using them to scroll content, I realize they don’t respond to keyboard input. I can probably add that myself later, but it’s a bit disappointing. The scroll bar itself changes width based on the shape of the area scrolled, also. That’s kind of awkward. I don’t know how easy it’ll be to change that.

Anyways it looks satisfactory for now, so I’ll add the other two.

*work work* Okey dokey that was pretty easy.

Next I want to put some feeder text in there and test how the formatting and event raising works, so I can be sure how to recieve and translate events between the TextWorld system and the interface.

I’ll do that next time, though. I’ve gotten some stuff done, and the weather is getting interesting. I left the windows open at home, so if it starts to rain I want to be there to close everything.

Tagged , ,

New TextWorld Work

It’s been quite a while since I’ve been able to do any work on my projects, and not for lack of trying! I’ve either been caught up in the Unitarian site (which is done and up at http://unitarian.sarnia.com/ ) or preoccupied with something else. Games have been distracting; SWTOR and Anno2070 have been big contenders for my attention. I finally had a big area of time to work yesterday but between the difficulties with Mystery Bunnygirl X and a big argument that left me unable to think of anything else, I didn’t get a thing done.

I’m still reeling from some of that today, but hopefully I’ll be able to get something done.

*work work* Hum… nme.Lib isn’t in the API documentation. Oh wait, here it is! It’s just not given its own section. I thought it was a package, but it’s just a class.

*work work work* I was just thinking, why don’t I make the graphical interface, so I can be sure of what I’ll have to work with when the user clicks on something?

And I started doing that. Then I realized that since I switched to HaXe, I’ll have to re-do the scrolling text area thing I did for Flash!

Well, HaXeNME and Flash work together pretty well, so it shouldn’t be difficult to modify the existing code to HaXe. But, well, just wanted to say that.

*work work work*

Now the internet is down and the sun has reached a position where it’s all up in my screen. Plus I have really bad heartburn, so I’m going to head home before continuing.

*work work work work work*

*work work work work work*

Well that was a heck of a lot of work, but I’ve got the scrollbar working in HaXe now. Quite the illustration on what’s different between the languages!

Anyways now that I’ve got that done, it’s getting close to midnight and I’m pretty drained. It was nice to accomplish something tangible for a change.

Tagged , , ,

TextWorld Progress

Cheese and crackers!

Before I started working earlier tonight, I cleaned up the desktop on my laptop. I’ve been doing stuff all night and now when I turn it on again and see the mostly empty desktop, it’s like a stark white barren plane!

Anyways I’ve settled down from my anxiety and I’m going to take another crack at TextWorld tonight.

*work work work read read read work work work* Alright, I’ve determined that HaXe has a way of refering to functions with variables. It’s just that you have to define the arguments and return type of the function reference when you declare it. As such, all of the action functions will have to take the same parameters.

*work work*

Okay so let’s see… When you click on some highlighted text, how does it determine what goes in the context menu? I was thinking about having the context menus be a property of a thing, but what if some of the options don’t make sense in the context you’re clicking on the thing in?

I’m thinking it’ll run a generate context menu function instead. It’ll look at the situation and give you options of what to do with the thing.

Ohhh… I just had an idea.

What if instead of using context menus, when you click on something in the location text, it puts the description of the thing in the action text, along with options of what you could do. And if you click those and they need more choices, more options could be added to the action text!

It might go something like this:

You are within a deep forest. You see a ball.

Click on ball.

It looks like a blue rubber ball, about twelve centimeters in diameter.
Would you like to do something with the ball?

Click on do something with the ball.

Get the Ball? Touch the Ball? Strike the Ball?

Click on get the ball.

You pick up the ball, and hold it in your hands.

That’s more organic than having dialogs popping up all over, I think. ^.^

Alright. Let’s go over the game loop.

The game has begun, and the world has loaded. The player thing is in the starting space.

Assemble the location text, by checking the player’s position and sight range, and the connecting regions.

Assemble the status text, checking the player’s status and senses and revealing them.

Assemble the action text, appending new entries and if neccesary, removing old entries from the top of the pile.

Wait for player to click a link.

Respond to a link by running the action assigned to it.

Repeat.

That’s basically it, I think. The rest is developing the data classes and breaking down those major tasks into individual steps.

Hmm… The List class doesn’t do direct access. I’ll have to use an Array instead.

Okay, so the first thing I’m going to do is make a class that generates a world. In order to do that I need to flesh out the data classes thing, space, exit, and mobile.

I’ll give a thing properties for length, width, and height, which can be compared to, in order to determine if a given thing is bigger or smaller than the player.

Hmm… The more I do the more there is to do. I’m starting to seriously reconsider my plans for this. While I’d like to do some world simulation, the goal of this project turned away from simulating worlds and towards making money by creating a sort of interactive fiction.

I think maybe I should branch off and make the IF project completely different from the TextWorld project, and make it a much simpler format.

I think I need to take a break and think about that.

Tagged , ,

NME TextWorld

So I haven’t worked on my TextWorld project for a while, but after a week of doing web development for a local unitarian congregation, I dropped the beat on the A-Life and decided to pick up the Text again.

From what I learned in the A-Life project, NME seems like the ideal target for my Text Game too. I can pump it out for Flash, HTML5, and a bunch of other platforms. Of course, that’s just the front end. First I’ve gotta make the backend.

I brought over the data classes I made before and put them into a new NME project. Now that I’m using NME I don’t have to keep the interface and logic seperate, though I’m wondering if I should.

The plan before was to have the TextWorld object reveal certain properties which would contain the text for the four regions of the game board. Then I started thinking about how to do the context menus. I could probably reveal a list of strings with the context menu htmlformatted triggers inside. Then the interface would format those into floating boxes of links. When the links are pressed, they release a text event, which the interface passes back to the textworld, to find out what to do.

I still haven’t perfected the actions system. I’m thinking I’ll make a class that’s nothing but action functions. If you wanted to get a pie that was sitting on the floor, you’d click on the pie link in the room text, that would tell the textworld you clicked on the pie, and the textworld would generate a context menu for the pie. The links would be tied to either further context menus or actions. If you click the get action, the get function will take the getter and the object as arguments and attempt to move the pie to the player’s inventory.

*work work work* Hang on, what’s this? There’s no function class in HaXe? Hmm… Looks like there is a way to do it, using dynamic functions, but the syntax is different. Hmm… I’m not sure what to do with this. I suppose instead of using a direct function reference, I could call the function from a switch based on input. Kind of a funny way to do it.

Anyways all of this is spiking my anxiety, so I’m going to take a break. I swear, the more I work on this the more I think I should just drop all the pretenses and make a basic TextGame, and build up from that.

Tagged , , ,

Figuring Out HaxePunk

Well, I’m trying to learn HaxePunk, which is a HaXe port of FlashPunk, but both are lacking something important. Good overview. Even pouring over the documentation doesn’t give me a good idea of what everything is and how they fit together. I’m able to figure out some things via the tutorials, and so I’m going to try to piece together the workings of FlashPunk and HaxePunk. I’m also going to check out the source, and see if I can’t figure out something from that.

At any rate this gives me something to do while I try to brute force my way into the Diablo III Open Beta. I’m not sure if Blizzard is failing their stress test, or if they’re intentionally using less than their capacity to see what happens when stuff goes wrong.

So, HaxePunk. The basic thing for HaxePunk is the Engine class. When you make a HaxePunk project you make your main class extend the Engine class, and override the Engine class’s methods to add functionality. You give the constructor the details about screen size and frame rate, and it’s basically a sprite on the stage for you Flashers.

You override the init method of the Engine class and that runs once when the program starts. That initializes the game for you. Then there’s update, which updates the active world, and render, which draws everything to the screen, each every frame.

Then there’s HXP, which is a mix of constants and references to important data across the various classes. When you set which world is currently active, you set it through HXP.

The next most important class is World. Your game takes place in one or more World instances. You set a world to the HXP.world. A world contains entities, which are physical objects that do things in the game. Those entities have a graphics property which can be one of several different graphic type classes. An Entity also has an update method you can override, and various methods for collisions and things.

That much I was able to glean from the tutorials and such. But there’s other stuff in there.

The World class has layer variables. I would guess so that you could have multiple layers of background and foreground sprites, without having them collide. Or for doing paralax scrolling. That sort of thing.

The code in the libraries spaghettis a lot, especially due to the HXP class. I think I’ll need to actually try a lot of these elements out to see what they do. For that, I need to set up an experiment game.

*work work work* Well so far I’ve made an area with a tilemap of floor and barrier tiles LoZ style, and a little red box to be the ‘player’, and the camera follows the player, and the player moves in response to the arrow keys. I also put a pair of parallax scrolling textures in the background, and they’re very neat and hypnotic. It’s a couple of repeating textures using the “Backdrop” class; it’s a graphical class made for non-interactive looping background images.

Next I’ve got to set up some collision stuff.

*work work work work work* Alright! I managed to figure out the built-in movement-collision system. Now I need to take a break.

*takes a break* At this point I should probably mention that unlike my other blog entries, this one is being written over the course of several days. I think this is the fourth time I’ve opened it up and started writing. Usually I close it down when I’m done for the day and post it, but instead I’ve just been adding to it as I go.

I’ve got my little test game going now, but another thing I’m doing is commenting on all of the classes. I’ve got a little folder and I’m slowly filling it up with .txt files named after each of the HaxePunk classes. I’m going to try and figure out what each of them does, and piece together the full intent of the HaxePunk/FlashPunk system. I really have no idea why something like this isn’t already in the API or the documentation anywhere, but so far the code itself hasn’t been _too_ difficult to figure out, once I open the source.

One more thing I’ve been able to figure out is that the entire Masks namespace is full of collision masks. Masks is kind of a vague name, but all the masks are used for collision. They get popped into an Entity’s mask property and compared against for collision.

That leaves the last big mystery, the tweens.

*work work work* Okay before I dive into the tweens I decided to dive into the render loop. I wanted to know how the game works on that end. It seems that it has two bitmaps, and it draws to one in the background using copypixels, and then does a page flip to make a buffer. That’s how I was considering making one, so that’s great, saves me the work. The worry/concern/question I have though is this: Is it neccesary to have two drawing surfaces? I would imagine that Flash/NME handle clipping and page buffers in their own rendering. Maybe it is neccesary. I’m not sure.

Anyways it works, so that’s good enough for me right now.

Now let’s see if I can figure out what these tweens are. I know that in animation, a tween consists of the frames between key frames. In particular in Flash animation, tweens are automatically generated animations based on the differences between one vector image and another. They’re kind of infamous for being terrible, though they’re effective. I studied them a bit in college, and I think if you do them right they don’t have to look terrible, but I’m not much of an animator…

Anyways, near as I can tell there are two classes that subclass the Tweener class, world and entity. The Tweener class lets you apply tweens, which are defined in three different namespaces. So, I should be able to apply a tween to an entity or the world, to see what it does.

To have a clearer idea, I’m going to add another entity into the world.

*work work work* I added a test pattern object, I’m going to try putting tweens in there first to see what they do.

… I’ve just tried the Alarm tween. It didn’t seem to do anything, so I went into the code. I think it’s just a glorified timer. You can supply a callback function when the tween is done, so this one just gives you the callback after the timer is up.

Hmm… The AngleTween is definately SUPPOSED to do something, but I’m having trouble making it actually do something. I’m pretty tired now, though, so I’m going to try to sleep.

I’m going to post this as an entry today, around a week after I last updated it. I’ve been too busy on a different project and now I’m going to work on TextWorld for a while, so I want this up for when I decide to work on HaxePunk some more.

Tagged ,