Tag Archives: haxe

Collision Detection Insufficient

Delight of delights, I finally have a modern laptop. I’ve already gone ahead and moved most of my stuff onto here, and I have already got my previous work compiling and running. Great! That’s how I like things; working. I like myself working too, so I’m happy to be back at the cafe with my IDEs open.

Last time I worked on my programming, I added in the Animals to my little sandbox. They don’t DO anything yet, but they’re there. Little blue triangles.

I’m going to use a state-based sort of AI. Each critter will have a bunch of different behaviors wrapped in functions, and depending on what state they’re in, they’ll use different functions. It depends on their needs. These first ones will focus on eating, so they’ll have a hungry state, and a rest state. I’ll probably throw in a play state later.

So first off, I’m making the hungry state. When an animal is hungry, it’ll start using its senses to search for food. To simulate senses in this 2D world, I’m going to have the animals generate invisible shapes and see if those shapes collide with things. There’ll be a sight shape, which will be sort of like a cut-pie in the direction the creature is looking, and a scent shape, which will be a big circle. These guys will be pretty dumb to start. If they see food, they’ll move straight at it. If they smell food, they’ll move in it’s general direction. If they don’t see or smell food, they’ll keep wandering untill they do.

Using shapes like this for collision testing might be a bad idea. It’s easiest to test collisions with a square. Using a complex shape makes things a lot more processor intensive.

Hmm… On further investigation, it looks like HaxePunk entities can only have rectangular collision areas. Shoot.

*loads up the Entity code* Hmm… the collision detection is surprisingly simple. I could probably extend it myself to make shaped collision detection. I’m not sure if that’s a terribly good idea or not though. The more I work with HaxePunk, the more it feels like I’m pushing beyond it’s intended purpose.

Maybe I should do some research on how other people have solved this problem before. Or maybe I shouldn’t. It’s a tough call. They say that you shouldn’t worry about optimization at first, just make something that works, and then refine it afterwards. I could make a shaped collision system. Of course, I could also do the senses by other means than colliding with objects.

Yeah I think I’ll do research for a bit, see if I can dig up any ideas.

Hmm… Well, one thing I’ve learned is that apparently there’s a pollitical blog named Collision Detection. How about that?

Another interesting thing is that when you google Collision Detection, you mostly get linked to articles from the turn of the century.

Oh, here’s one from last year. Looks interesting. The math involved may require me to do further research, though. I’m lucky I’m able to figure out advanced math like this, even though I didn’t learn it in school. I wish I had, though.

http://www.wildbunny.co.uk/blog/2011/04/20/collision-detection-for-dummies/

This article assumes the reader has a basic grasp of mathematics and geometry he says. Matricies are not basic! EVER!

Well, it seems like it’s a good article anyways. I’m not done with it, but I need a break. Learning makes my anxiety peak.

Tagged , , ,

FlashDevelop Troubles

Well I’m finally back to work after a long absense. It’s finally time to deal with the problem I had immediately before said absense; suddenly FlashDevelop stopped connecting to the debugger when it ran my project. Not sure what’s up with that.

So far, I’ve tried reinstalling the Flash Debug Player but that didn’t work.

Now I’m trying to use the debugger in other projects, but it’s getting even weirder. When I compiled and ran a different program, it didn’t even try to use the debugger. I edited it to use a flash trace but it didn’t work. So, it’s not just my other project, but this is even worse. At least in the main one, it’s visibly trying and failing to connect the debugger. This isn’t even saying anything is wrong. I double checked that it was in Debug mode since the first one I tried was in release mode, but it doesn’t make a difference.

Okay I tried an AS3 project and the debugger worked fine. Very puzzling.

My Haxe project still isn’t connecting to the debugger.

Alright I’ve tried a few more and it’s definately happening with all my Haxe projects.

Alright I’m going to try and install the mozilla style flash debugger as well and see if that does anything.

Oh, well this is interesting. Now the debugger is working, but the program isn’t, and it’s not giving any errors or compile errors. I just get the flash player with a white screen for all of my previously working programs.

And again it’s happening to all Haxe projects but not AS3 projects. They go fine.

Alright I’m going to take a break for the night and ask for help on the FlashDevelop forum.

Tagged , ,

The Sandbox

Okay work time is time for work.

Gonna make the background into a bunch of 16×16 squares instead of 32×32, and give them simple colours…

Huh, interesting, I had thought that shrinking them wouldn’t make a big difference since the graphics are simpler and it’s just re-using two bitmap stamps over and over, but the FPS with nothing in the scene has dropped by five. Well, that’s partly ’cause my laptop isn’t very good, but I also realized that the grid is also being used for collision tests, so there is more overhead than I had thought at first.

I’ll leave it like this for now, though there shouldn’t be many collisions with the tilemap outside of the border, so maybe I’ll switch it with something else later.

Now, I’m going to add in arrow key control for the viewpoint, since I can only see part of the scene right now.

*work work work* Okay, now I can move my viewpoint about the scene as I please.

Now for the logic of life, I think.

The plants will spawn at a very small size and slowly be scaled up as their food value increases, simulating photosynthesis. At this stage, they’ll be static things. I’ll sprinkle them in randomly, and they’ll grow slowly over time.

The animals will just be herbivores for now. I’m not sure if I should code in senses at this stage; should they be omnicient and automatically head towards the best plant, or use senses to try to find a plant that is big enough to eat while wandering around pseudo-randomly?

Now that I think about it, I don’t really know much about how microbes do their stuff. Do they have senses? Do they just squiggle around pseudo-randomly untill they blunder into success or failure? Let’s look it up…

*looks it up*

Huh, well it looks like microbes are like bears; they can smell you from SO FAR AWAY!!!! Or at least, relative to scale. They have incredibly powerful senses and can detect something like a sugar molecule from pretty far away, if I’m understanding this article right. http://biosingularity.com/2006/06/04/how-bacteria-sense-their-environments/

So for my simulation it might actually make sense to have the little animals be omnicient at this stage. Of course, I’m not coding this to simulate microbes, so maybe I should just knuckle down and do the senses now.

For now I’m thinking that they’ll drop an invisible ‘area of effect’ entity that will pass its collisions back to the parent. If it detects a food source, it’ll head towards it and chow down. Otherwise it’ll wiggle around pseudo-randomly. Eventually I’d like to use different AoEs for sight, sound, and smell. Hopefully it won’t bog down the simulation too much, but figuring out stuff like that is part of why I’m doing this.

It’s noon now, so I think I’m done for the day. Next time I’ll have to try and code the plants.

Tagged , , ,

Plants and Animals

So here I am, at the cafe again. It’s been a while; this last month has been terrible for me overall.

I’ve decided to push the textworld project to the back burner. I kept changing my goals on that project and ultimately realized I wasn’t working towards any of them anymore. Instead I’m going to focus on my artificial life experiments for a while, in preparation for my return to college this fall.

As before, I intend to do these a-life experiments using HaXe and HaxePunk, but those various libraries were updated even while I was using them, so I’m going to have to start by updating all my libraries.

*work work work* Well that took an hour. Ahh well life goes on, and now my libraries are all updatified.

Hmm… Now that I’ve opened all the references, I’m feeling really anxious and somewhat disturbed. I think I’ll have to take it slowly and refresh myself on the workings of HaxePunk.

*work work work* Okay after some difficulty I am successfully back where I left off before, and prepared to make a HaxePunk app thingy.

The first thing I’ll do is the most basic sort of a-life. I’ll make little green circles to be ‘plants’ and have them grow slowly, and little blue triangles to be ‘herbivores’ that will seek out the plants for food. I’ll make the herbivores reproduce asexually for now, when they have enough food, and die if they starve. I might have them die of old age later.

First things first. Gotta set up the ‘world’. This’ll be a bordered box for the critters to live in.

Anxiety is peaking really hard right now. Really want to run home and hide, but such is life. I’m staying.

Made a world, working on Plant and Animal entities to populate it…

Okay I’ve got some of the basics set up. But, I still need to make a bounded space in the World, right now I think it goes on forever.

*work work work* Alright I’ve put in a temporary field for my sandbox, it’s basically the box I made for my last HaxePunk experiment, with the zelda style tiles. I’ll probably switch it out with just a black outline later, and make it bigger. For now, I’m out of time. I have work to do today, and it’s finally almost 9:30.

Tagged , , ,

Back to Work

Back to work after a while.

The task list I added previously is helping a lot. I was able to quickly get back to work with only the briefest refresher. I just polished up the generateLocationText function to wrap the text in a font tag to give it a nice format.

Next I’m going to work on the input method for the textworld class that recieves the textEvents from the interface and handles them.

*work work work* Okey dokey, it recieves input and handles it. I’ve got it sending flash traces whenever I click on one of the menu links.

Next I’ve got to make some exit objects and link them to spaces, so that I’ll be able to move my player around the little world I’ve created so far.

I haven’t figured out just how I’ll link a text line with a specific object. I’ve been thinking of using hash tables for each of the item types and including the hash in the text though. Already have a hash table for the spaces so that the exits can find them before making a more solid reference.

Alright, I’ve already got some exits I made before and forgot about.

I’m also considering making it so that in order to create game objects, I have to use methods in the TextWorld object, which will add them to the proper lists when they’re created.

Hmm… It occurs to me that having a single switch statement for all of the possible input just isn’t sensible. I’d have to put in a case for every possible object. I’ll have to use it as a sort of code.

Hmm…

exit51, menuOption, action3

Maybe something like that. For the actions, when you click on an object in the Location text, it’ll put your options for interacting with that object in the action text area. The actions might have to be big compound things, since it needs to include what type of action it is, as well as what the action is happening to.

Well, I’ve made some progress but it looks like it’s starting to rain, and there might be something more serious rolling in. So, I’m going to pack up and head home. I wish I had a better idea where I was headed with this program, I’m usually a lot more clear on how everything will work.

Tagged , , ,

Lots of Lists

I’ve been working for a while but hadn’t written anything in my open text editor for the blog. Didn’t have anything to say, I guess. Now I do.

I’m not sure how I want to handle the list of a space’s contents. I was going to have it be a list of things, but then I realized that thing children would loose their special properties; it would store them all as things, even mobiles, exits, and other spaces.

There’s two ways I could handle this. The first way would be a list with the Dynamic type, which can have members of any type but isn’t perfect across different platforms in HaXe. Or I could have seperate lists for each of the possible child types. That would mean a list of all the contained things, a list of all the contained mobiles, a list of all the contained spaces and a list of all the contained exits. The downside would be that I would have to handle all the lists seperately. That might be good though too. I think I’ll do it that way.

Alright that’s pretty much it. Not much to say this time, I did a bunch of stuff but I’m so sleepy it’s hard to say what. I will say that I added a couple of text files to the project to help keep things organized. One describes the game’s intended logic, and one is a list of tasks for me to do, so I know what I’m working on and what to do next.

Now it’s time for sleep, probably.

Tagged , , ,

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 , , , , , ,