Tag Archives: haxe

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 ,

HaXePunk is Coming Under Control

Well, it’s taken a lot of finageling and futzing but I’ve managed to get HaxePunk to operate with FlashDevelop the way I wanted it to. Code completion works, lookups work, and pressing the test button tests the app. Huzzahulations!

Now to actually learn how to use HaXePunk and see how it goes. The framerate isn’t great on my dinosaur laptop to begin with, when it’s not doing anything besides reporting its status. I wonder what will happen when I make it DO things?

Well, first things first. I’m going to go through the FlashPunk tutorials, since HaxePunk is based on FlashPunk and for whatever reason they haven’t just copied the tutorials.

*work work work work work*

Wow I did a lot of work and didn’t have much to say. It’s getting late and cold though, so I think I’m going to head home. FlashPunk is coming along, though there’s still a bit to learn. If I get the pixels dancing by tomorrow night then I might give Ludum Dare a try this weekend. Wish me luck!

Tagged , ,

A Beginning for A-Life

Today I don’t feel like working with text, but I can’t relax and play, so I’ve got to work on something else. So, I’m going to start doing the other option of the two I started with, when I started the text game. I’m going to start doing some A-Life experiments.

So, I’m going to keep on using HaXe and target Flash, so I’ll basically be making a flash app in HaXe. It seems like a decent language, especially for Flash development, and I can re-use code from it pretty easily.

First I’m going to do some experiments with how I want to render this. I might use a library, there’s a bunch of them out there. This HaXePunk looks good; it’s a HaXe port of FlashPunk. There’s one of Flixel too but it doesn’t look as good.

Hmm, they both need something called NME, which is related to HaXe…

It looks like NME is an extension API for HaXe which makes it even easier to do multiplatform programming.

Let’s try this NME out… *downloads an example, compiles, builds, runs* Yeah that works. I love it when things work.

*read read* Oh I see, NME basically has an interface like Flash, but you can target to other platforms with the same code. So, you can code the interface with HaXe instead of doing a different interface for each platform. That’s cool.

I’m taking a long time messing around with Libraries, I haven’t even touched the A-Life experiments I was going to start. Maybe I won’t get to them today, we’ll see. I’ll have to eat soon.

*read read read* awe6 seems good too, though. I should check them out later. FlashPunk seems more familiar, for now. It’s interesting and noteworthy that the same game on Flash and JavaScript/HTML5 is much faster for me in Flash. I guess JS/HTML5 has a ways to go yet.

I haven’t done much besides decide which library I’m going to use, but now it’s time for meal and break. I’m sure there will be interesting things coming up!

Tagged , , , ,

Giving HaXe a Try

So, now that I’ve decided to give HaXe a go, I’m going to start out targeting Flash. I’m familiar with Flash and comfortable with it. I’ll keep anything platform-specific seperate from the workings of the game in general. Then, I can write interfaces on top of the inner workings.

One thing that’ll be difficult is handling the input. When someone clicks on coloured text, a context menu should pop up. So, I’ll have to have the interface send what the user clicks on, and the game underneath come up with data to populate the context menus.

*work work work* Huh, for some reason I can’t compile a project that is in a package. No matter if I do it from FlashDevelop or by command line. I wonder why? It says I’ve got an invalid name, but that seems to only matter when it’s the package.class format. It’s like, no you can’t put package. in there! That’s invalid! That’s the way FlashDevelop tries to do it by default, though, and it seems to be the right way, so it’s perplexing as to why it’s not working.

Oh, finally, in someplace unrelated to the Object Oriented documentation, it says that package names should start with lower case letters. *test* Ahh yeah that did it. Geez.

*reads the entire HaXe Language Reference* Okay I think I’m ready to actually program something with this.

Now I’m getting kind of frustrated by trying to reach out in so many directions and not actually producing something I can play, so I’m going to start by making something a lot simpler. I’ll make something more like a classic room-based text game. Each room will have a description, plus a list of things in the room, and a list of exits. The exits will have a transparency flag; if they’re transparent then the player can see the next room without going there. I’ll just make it one level deep so I don’t have to worry about line of sight across several rooms/exits.

*hours pass* Well hours passed where I was hanging with friends online and I forgot to post my progress, and since it’s effectively still the same day I’m going to continue with this same blog entry.

Right now I’m wondering what’s the difference between an array and a list in HaXe. It seems to suggest that the list type is a linked list, while the array is a classic array, but it’s not clear. A linked list would probably be best for abstract objects like the rooms.

*work work work* Okay I made a few data classes and some function prototypes. I’m too tired to do any more now though, so I’m going to call it a night. Maybe I’ll work some more tomorrow.

Tagged , ,

Maybe I should try HaXe

Am I jumping formats again? Apparently JavaScript doesn’t work in all browsers, and certainly, some people turn it off. So, what if I used server-side scripting, like PHP? Well, then you could only play when you’re logged into the internet. When I was doing it in Flash, you could download the .swf and play wherever you like.

There’s perks to everything, aren’t there?

Maybe it’s time I learned HaXe. I mean, the IDE I’ve been using for two years for my tile-matching game, FlashDevelop, is also a HaXe IDE. With HaXe I could write the program once and compile it for different platforms, and get the best of all the supported worlds, including Flash, JavaScript, PHP and C++. Plus HaXe is strictly-typed, which some of those languages aren’t, and I prefer strictly-typed languages. Well, that’s the slogan anyways. I don’t know if it’s really easy to make something multiplatform with HaXe.

*gives HaXe a try* Hmm… The documentation for the JavaScript HaXe libraries is kind of crap. There’s no explanation of what anything is. Look at this for example, http://haxe.org/api/js/lib that’s supposed to be the document class from JavaScript.

This language has been around at least five years, you’d think they’d have comments on all of their API elements by now. Looking at the PHP one now, only some of them have documentation past declaration. http://haxe.org/api/php/lib

I’m going to see what I can do with the HaXe PHP thing. But first I’ve got to refresh myself on PHP since it’s been a while.

“PHP stands for PHP: Hypertext Preprocessor” The Madness Begins. XD

*read read read, experiment experiment experiment*

Yeah it seems like if I use HaXe, as long as I write a different interface for every platform, I can do all my essential classes and keep them seperate. I can just have it reveal the things that need to be displayed in a series of public properties, and the interface will poll the world, or use a callback function or event or something.

Alright, given that I think it’s worth a try.

For now though, a band is setting up for First Friday, so I’m going to head out. ^.^

Tagged , , , ,