Streak Club is a place for hosting and participating in creative streaks.
Today I messed around with a heatmap algorithm. I wanted to create something that would let the computer discover the best way to get a lot of individual game objects as close to a certain point as possible. The trick was that I plan on having a lot of game objects and I didn't want to run a pathfinding algorithm for each one individually. So instead I pick the point that they should move towards and then rate every space on the board based on how close it is to the destination.
I was stupid though and set it up as a depth first search. Basically how the algorithm works is to start with a spot and then recursively call itself on each of the surrounding spots. I figured the quick and dirty method would just be a brute force approach with a depth first algorithm. I knew that I was going to lose some efficiency because I would be calculating values for spaces that would later be replaced with better moves, but I figured for a first pass I didn't care.
Well I should have. The algorithm found the values for all the spaces, but to calculate a board that is 40x40 took over a second and involved 1,600,000 calculations. Depth first is definitely not the way to go. I re-wrote it using a stack so I can control the order that the spots are calculated and now I'm down to under 8000 calculations for the 40x40 board and it completes an order of magnitude faster.
So my new algorithm runs 200 times faster because I was 200 time less stupid when coding it.
If you want to play around with the end result you can do so here: http://codingadventure.net/index.php/projects/heat...
Instructions on the page.
Found out how to view my shader compile errors in Luxe today. Shader progress will greatly increase now that I'm not just guessing and checking where the errors in my GLSL programs are...
Wrote some quick shader that makes everything grayscale. No pictures, so you will have to imagine.
My journey with Luxe continues.
I got the parcels working and was able to import and display graphics now, so the placeholder graphics should disappear over the next day or two. I ran into some major headscratchers with importing textures and json files and having them be available to Luxe, but I figured them out after some frustration. My problems came with everything being loaded asynchronously. I thought that the Luxe ParcelLoader (which I thought was a preloader, but actually isn't) would hold the game until all the assets were finished loading but it doesn't. I had to add all my sprite and game initializations into a load_complete function and add if(sprite==null) return; to the top of my update() loop to prevent it from running before all the assets are loaded.
I wrote a pretty substantial blog post about it here.
Now that the cat is running in the game again I've cleared another major hurdle. Now once I get the remaining graphic assets in the game I'll be officially where I was at the end of last week when I switched the engine from HaxeFlixel. Actually, a little ahead because I have the collisions for the boxes and stuff working now and they weren't before. My last problem with the graphics is getting the sprite to display offset from the Shape that controls collisions. I'm sure it is a simple fix but I just haven't found it yet.
Great progress with Luxe and the Catabalt remake. I've got the base logic nearly done, collisions detecting correctly, my states set up and working, increasing difficulty and running at a steady 60fps in a browser in HTML5.
Luxe is performing like I hoped it would. Giving me plenty of options but then staying out of my way and letting me implement the way that I want to. The code this time around is much cleaner than my first attempt. Some of this is because I'm not hacking around the HaxeFlixel stuff I don't need for the game because of the engine change, but a good portion of it is because I rewrote all the code from scratch and I'm not iterating or making the mistakes I did last time.
I'd share a link to play it, but I'm still fighting with getting Joomla to embed HTML5 games correctly, so a GIF for now.
I'm starting to like Luxe. I still don't like it as much as HaxeFlixel, but I'm still fighting to learn it, so who knows. One thing that I do love about it so far is the way that it handles States.
Basically today I created a Finite State Machine to control the game states in Luxe. What is cool about how Luxe handles them is that I can switch between them easily, or I can enable them individually to have multiple states active at once. I'm going to use them to create modular behavior for entities that I can reuse. So for instance, I can create a SearchState where the entity will wander around trying to find the player and I can add that state to every entity in the game to give them all that ability.
The same states can be used to run the game logic too.
I wrote a whole long blog post about it here if you are interested.
So this is kind of cheating entering the same game for two weeks in a row, but all my development time this week has been taken up with streamlining my Ludum Dare Entry and incorporating the feedback that I've received here and elsewhere. Here is a short list of the differences:
Options menu - You can adjust the length of the debate and the thinking time to make things easier or harder (that was for you @Anja).
Word list - The word list is greatly cut down from 50,000 words to about 5,000. I am a native English speaker and have a fairly extensive vocabulary and I had never seen half of the words before. Younger audiences or individuals who don't speak English as their first language can enjoy the absurdity of the debate more if they know what the words mean (Thanks for pointing this out @Stephan) Plus, I enjoy it more with the change also.
Game speed - I eliminated some of the prompts and the messages that didn't add anything to the game but did slow it down. I also reduced the default number of rounds to 6 from 10 (although you can move it back up again if you want in the options menu). Each debate takes less than half the time that it used to.
You can play the new version here.
I'm working on my entry for Ludum Dare 32 (theme: An unconventional weapon). My entry is The Great Debate. Beat down your opponenets with the power of your words!
The game is a puzzle game disguised as a debate simulator. Each round you get a list of four words to pick from. They are all worth a different amount of points based on some criteria, but to find out what that criteria is you are going to have to experiment and watch how both your words and your opponents words are scoring. Better figure it out quickly because there are only 10 rounds in the debate until the winner is determined.
Note this is after one day. I still have all day tomorrow to clean up the little things, add more puzzles (each debate has the same solution now), add additional characters, and all that fun stuff. Plus, the MadLibs inspired jokes,which are kind of the entire point of this thing.
You can try it out HERE,
I made a ton of progress on my quick game for this week called MetaRPG. It is an affectionate parody of RPGs like Final Fantasy and Dragon Warrior where you will walk along the plotline to the right. As you walk you gain experience and currency units but lose HP/MP. You can rest and restore at towns as well as trace currency units for equipment levels which lets you travel further along the plotline. I'm hoping that it is more fun than it sounds as I describe it.
I created all the basic layout stuff and added everything to the scene. I also coded the flag that keeps track of the farthest location you have reached along the plotline. The thinking is that moving forward in on the plotline is slow when you are advancing the plot (either because you get lost in mazes, or deal with cutscenes, or mazes with cutscenes) but faster when you are revisiting previously explored areas.
I'm having trouble explaining this concept...
I'm officially at the point where I can release Black Box beta for public consumption. This was primarily an entry for the One Game a Week streak. I made it in about 4 days over the course of about 5 hours.
Black Box is a direct copy of a board game produced by Parker Brothers in the late 70s. It is a puzzle game with the goal of discovering the location of atoms hidden within the Black Box by firing lasers in from the sides of the board. These lasers either travel straight through, bounce off of one or more atoms before coming out, reflect off one or two atoms and come out the position that it entered, or hit an atom directly. By looking at the result of these lasers you can determine where the atoms are located. The less lasers
The game is fully playable as it is. I need to add a menu, a How To Play screen, then add more polish, color changes, and different difficulty levels. If I'm feeling really ambitious I might add a high scores table or something. Maybe some relaxing music and sound effects at some point.
You can play it here.
Happy lasering!
EDIT - I finished it off. There is a "How to Play" as well as three different difficulties. I cleaned up some of the interface stuff (you can't click on the same space more than once now, for instance). There is one extremely rare case that the lasers give the wrong result and occasionally the random color generator comes up with a color extremely close to the background color so it is hard to see. I don't think I'm going back to fix it though. On to the next!
I entered the Weekly Game Streak which is causing me to put on hold some of the larger projects. So I started programming a game which is a copy of the board game Black Box. The goal is to locate the placement of Atoms within a hidden area (the Black Box) by shooting lasers in the sides and seeing where they come out. The game is mainly two players but it has the option if playing solitaire play if you don't mind looking up your guesses on a bunch of tables. It is a pretty simple game and one that should be easily achievable in a week.
I've got most of the game coding in place. This is what it currently looks like,
Sorry this is a duplicate of the Art Streak, but I wanted to get something over here too...
I coded some of the gameplay flow today. Simple gamestate changes that determine how the game plays. I also mostly coded an event system that will let me easily queue up a bunch of visual effects that will automatically play and then pass along control to the next state when they are finished.
Mostly behind the scenes stuff. I should have something visual the next update.
Today I coded the battle stuff so troops can actually whack each other.
I also started some of the visual stuff, but until that is much farther along I'm afraid there isn't anything really to demo...
So today I massively gutted the game to make it conform to MCV standards. It meant breaking up my FlxSprites because they contain all the model data also. I also did a ton of optimization and the new code is smaller and streamlined and much easier to write and modify. Unfortunately I just started putting the view together, so my end result is less than what I finished with yesterday.
I also changed the way that levels are loaded into the game. The old way was extremely manual and the new way can be completely done from in Tiled and is much faster.
I guess the moral of the story is sometimes you have to go backwards before you can go forwards.
I found my bug that was causing the Flash port of my Mass Battle game not work properly. At one point I was casting a generic Entity into a specific data type. There is a chance that this cast could fail. Neko handles this failure gracefully and resolves the object to a null, which works fine with my code. Flash just crashes. Granted, this is my fault for an unsafe cast, but it was a pain to track down.
I also learned that when I updated my FlashPlayer recently it didn't update the debugger, so I wasn't getting the error. That lead me to believe I was stuck in an infinite loop and lead me down the wrong path for a while.
If you want to move around some stuff and see it working you can hit the Flash demo today: http://codingadventure.net/index.php/games/mass-ba...
I simultaneously hit a major milestone and problem in my most recent game. The basic plan is to make a turn based strategy game similar to Shining Force and Fire Emblem. I've been working on the movement for a couple of days and finally got it working how I want it to.
The Good
The very, very bad:
I'm writing it in Haxe using HaxeFlixel. The problem is that when I target Flash it hangs. Even with only one troop. There is something about the different way that Haxe compiles to Flash versus the Neko emulator that causes my algorithm to hang. I love Haxe, but these types of errors are really difficult to track down.
Today I married the data from the Tiled TMX file with the movement code I already wrote. I also started some basic graphical stuff to get some immediate feedback on any changes I make.
Today I solved a problem with getting the Haxeflixel framework to read my TMX files. I was running into all sorts of problems. If I copied and pasted the comma delimited number string into my code everything worked fine, but if I read it in from an XML file it died. I was tracking down escape characters and digging through the XML parsing code trying to solve the problem when I stumbled on a much simpler solution. Just encode the data as Base64 instead of Comma Delimited and everything works flawlessly.
So in other words, today I wasted an hour and a half.
I've been messing around with grid based for a game similar to Shining Force or any other grid based tactical games. I wanted to be able to pick a spot on the grid and a movement amount and have the computer calculate all the spots that are available to move from there. I could use math to figure it out but because I'm lazy and like recursion I decided to use a modified flood fill (http://en.wikipedia.org/wiki/Flood_fill).
I created a flat grid and dropped a movement value of 8 somewhere in the middle and let my flood fill do the rest. Here's my result:
ArrayState.hx:110: ********************
ArrayState.hx:110: ********************
ArrayState.hx:110: **********0*********
ArrayState.hx:110: *********010********
ArrayState.hx:110: ********01210*******
ArrayState.hx:110: *******0123210******
ArrayState.hx:110: ******012343210*****
ArrayState.hx:110: *****01234543210****
ArrayState.hx:110: ****0123456543210***
ArrayState.hx:110: ***012345676543210**
ArrayState.hx:110: **01234567876543210*
ArrayState.hx:110: ***012345676543210**
ArrayState.hx:110: ****0123456543210***
ArrayState.hx:110: *****01234543210****
ArrayState.hx:110: ******012343210*****
ArrayState.hx:110: *******0123210******
ArrayState.hx:110: ********01210*******
ArrayState.hx:110: *********010********
ArrayState.hx:110: **********0*********
ArrayState.hx:110: ********************
* - are unreachable
# - how many movement is still available from each space.
Sorry about the funny formatting, but the Streak Club font isn't fixed width...
You can't see it here but this will flow around open spaces and takes into account different terrain which might cost extra movement to cross. Not bad for less than 10 mintues worth of work! I actually coded the recursive function correctly on the first try without catching myself in any infinite loops!
EDIT - Look at that. The Streak Club font is fixed width. Just not when I'm editing it. Live and learn.
EDIT 2 - No it isn't. It's close though!
EDIT 3 - Now it does. Thanks @Harley.
Post a comment