Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 09 Mar 2010
Offline Last Active Jul 12 2014 05:59 PM

Topics I've Started

[Game] Mustache Ride

25 June 2014 - 10:14 PM

Hey guys :) I've finally finished and released my first 'real' game.


It's a web game on Kongregate, but I'm working on a mobile version, too <3


You can play it here.

It's a score-attack infinite flyer type game. It's actually really fun to try and get the high scores and stuff. During development I would get addicted to playing and just want to play it instead of work on it. I really created a game that I would personally love. Even after the 2 months it took me to make it, and all the testing and playing I've done, I still play it every day. It's a lot of fun!


Hope you guys will check it out <3 I'm personally very proud of it. If you have a Kong account please feel free to rate the game and compete on the leaderboards!


If you wanna learn more about the game before playing, I made a dev blog and IndieDB page for it.

[SOLVED] Cutting up rectangles -- RNG giving predictable results?

20 September 2013 - 04:15 AM

(tl;dr: I was doing some BSP division of a parallelogram and getting undesired results, and since this was my first time really utilizing recursion in a meaningful way, I thought the problem was in my implementation... turns out it was just my RNG was giving the undesired results only when the program was run at normal speed, rather than stepped through. Declaring the System.Random object with program scope, rather than within the function using it, solved this... yay X_X)


I am attempting to cut a rectangle into two parts of random size at random direction (either horizontally or vertically). Then take each of those child rectangles and cut them... and keep doing this until the rectangles are "too small to cut."


I have a rectangle class that holds the minimum x and y in the rectangle, as well as its width and height (so all four corners can be calculated with this).


The plan is the create an array of something like x & y coordinates and "fill" each of the final children into it, to create "areas" to be used in random dungeon generation. Right now I'm just trying to get the array to fill up with numbers that will display as rectangles.


I'm pretty sure the rectangles are dividing properly, the problem is getting the final rectangles into the array. I've been storing all the rectangles in a list, and then checking through each rectangle in the list. If it has no children, it will then search through every 'node' in the array, and if it falls within the rectangle, it will assign it that rectangle's index number from the list (so that each rectangle now is uniquely numbered and "graphed" in the array).


I don't think I'm properly extracting the smallest of the children from the array... either that or my rectangles are not actually being created properly.


I've gone through step-by-step, and checked all the variables at the end. There are so many rectangles I'm not sure really what to look for. The final display also seems to always be cut horizontally or vertically, even though stepping through, there are cuts of both directions aplenty.


I've been at this for a couple days now, and this is the best I could come up with:

    class Program
        public static int DUNGEONSIZE = 8;
        public static int MINSIZE = 5;

        static void Main(string[] args)
            int borders = DUNGEONSIZE * MINSIZE; // create the dungeon's width and height
            int[,] dungeonSections = new int[borders, borders]; // create an array to store leafs
            int[,] dungeonMap = new int[borders, borders]; // create an array to store map (floor, wall, hall, etc.)
            List<Leaf> leafset = new List<Leaf>();

            Leaf trouble = new Leaf();

            MakeLeaf(trouble, 0, 0, borders, borders);

            Split(trouble, leafset);

            for (int i = 0; i < leafset.Count; i++)
                if (leafset[i].firstChild == null && leafset[i].secondChild == null) /* if the leaf has no children,
                                                                                      * label every point inside of it
                                                                                      * with its index. */
                    for (int ii = 0; ii < borders; ii++)
                        for (int jj = 0; jj < borders; jj++)
                            if (ii >= leafset[i].minx &&
                                jj >= leafset[i].miny &&
                                ii <= (leafset[i].minx + leafset[i].width) &&
                                jj <= (leafset[i].miny + leafset[i].height))
                                dungeonMap[ii, jj] = i;

            for (int i = 0; i < 41; i++)

            for (int i = 0; i < borders; i++)
                for (int j = 0; j < borders; j++)
                    char x = (char)dungeonMap[i, j];




        //Split will take a leaf and continue to split it until no more splits can be made. It stores the children in a list.
        public static void Split(Leaf leaf, List<Leaf> list)
            if (leaf.firstChild != null) { return; } // abort if already split
            if (leaf.height <= (MINSIZE * 2) || leaf.width <= (MINSIZE * 2)) { return; } // abort if too small

            Random rnd = new Random();
            bool horiz = (rnd.Next(2) > 0) ? true : false; //decide if split is horiz or vert

            leaf.firstChild = new Leaf(); // initialize leaf children
            leaf.secondChild = new Leaf();

            if (horiz) // split into children
                int cut = rnd.Next(leaf.width / 3, leaf.width - leaf.width / 3);
                if (cut < MINSIZE) { cut = MINSIZE; }
                if (cut > leaf.width - MINSIZE) { cut = leaf.width - MINSIZE; }
                MakeLeaf(leaf.firstChild, leaf.minx, leaf.miny, cut, leaf.height);
                MakeLeaf(leaf.secondChild, leaf.minx + cut, leaf.miny, leaf.width - cut, leaf.height);
                int cut = rnd.Next(leaf.height / 3, leaf.height - leaf.height / 3);
                if (cut < MINSIZE) { cut = MINSIZE; }
                if (cut > leaf.height - MINSIZE) { cut = leaf.height - MINSIZE; }
                MakeLeaf(leaf.firstChild, leaf.minx, leaf.miny, leaf.width, cut);
                MakeLeaf(leaf.secondChild, leaf.minx, leaf.miny + cut, leaf.width, leaf.height - cut);

            list.Add(leaf.firstChild); // adds the children to the list

            Console.WriteLine("Children Made!!");

            Split(leaf.firstChild, list); // attempt to split children, if possible
            Split(leaf.secondChild, list);

        //MakeLeaf will set a leaf's variables.
        public static void MakeLeaf(Leaf leaf, int minx, int miny, int width, int height)
            leaf.minx = minx;
            leaf.miny = miny;
            leaf.width = width;
            leaf.height = height;


    class Leaf
        public int minx;
        public int miny;
        public int width;
        public int height;
        public Leaf firstChild;
        public Leaf secondChild;

Sorry if it's confusing... I am a noob.


I really don't know how to 'debug' this and figure out what is going wrong ._. I can't tell where exactly it is messing up. Going step-by-step, once I get to the for-for-for loop with the list and array, I don't even know what I'm looking for anymore.




You get some weird chars if you use the char as is... I've been adding 65 to it to get roman letters. At least I'm always making a 40x40 square now. But it's always giving me either only horizontal splits or vertical splits in the visual representation.


I think it has something to do with the check for them being 'too small' (when it decides to split). I had it do the same check before saving the children to the list, so that it only saves the children who will fail the check... then I stopped the program at the array distribution and all the leafs in the list had a height of 40.


But I'm not sure what's wrong with it... I've tried changing it to other things and it either crashes or gives a similar result? I just want it so that it will refuse to split anything with a width or height less than 2(minsize).




Okay, so I finally decided to pull out the big guns... I got couple sheets of paper out and mapped out the square it creates, as well as writting down every single leafs's four variables in a tree... marking the "too small to cut" ones on my graph.


Normally I woudl skip to certain parts of the code and check the variables... or step through to see if it was creating stuff right, then exit the program when it was working properly.


Well, I went step by step through the ENTIRE THING this time. It cut up the square perfectly into nice random areas, looked really good on my graph that I drew. Then I watched it go through the three embedded for loops to assign the leafs' index number to their contained coordinates. After it did leaf 4 and leaf 7 properly, skipping all the proper leafs, I skipped to the drawing part. I checked the array dungeonMap and compared it with my coordinates and graph I wrote. Everything was perfect! I started to think.... there's no way the drawing part is wrong... I watched it draw character by character... I realized it was doing it right.


I let the program run its course and lo and behold, it drew the right thing.


I was baffled. When I watched parts of the program, they responded perfectly and did what they were supposd to. When I watched the ENTIRE PROGRAM step-by-step, it worked perfectly and even gave the desired results.


But when I just run the build without pausing or anything, it doesn't give the desired results...


My head felt like it was going to explode.


Then I remember reading in the C# documentation on msdn about System.Random... and it said something about how if the numbers are generated too quickly/close to one another (since it's using the system clock), you can get predictable results.


So I thought... maybe when the program is running at "full speed," it's only generating all true or all false (different depending on run time of the program) for the "horiz" boolean in the Split function.


Every time I step through the program slowly, it creates everything perfeclty and provides desired results. It only gives the stupid results when I run the build normally.


This would also explain why even when I only stored 'baby' leafs in the list (that's what I call ones that can no longer be split) it was still only storing ones with 40 for width or height (because it was only cutting in one direciton, and eventually they'd all have the opposite edge be less than MINSIZE*2)...


I'm going to go try to research how to counter this (like I said, I'm a noob!) and add something to see if I can make it more random and see if it works. If anyone knows a solution, feel free to post it here, since this topic is already here and all. After I try it, I'll see if it works, and let everyone know.


Sorry to be such a pain!


EDIT3: I had it write the value of horiz to the console after every time it decided it... it was either always true or always false. I have a feeling this is the problem. MSDN's documentation for System.Random class is not helping... it just says to avoid this, only use one Random, which I'm already doing. EDIT4: Oh, now that I think about it, I guess I'm technically creating new Randoms every iteration/recursion....


EDIT5: Solved!! That was indeed the problem. I just declared the Random rnd outside of the function and now it works perfectly. Lesson learned, if you're going to be using a lot of RNG, try to make sure you're only creating one System.Random.


Wow. This took me days to figure out because I was looking it all the wrong places.


Well, I'll leave this here for anyone who might be able to learn from it.

throwing me for loops.

03 August 2013 - 11:12 PM

So, I'm trying to code this thing to make a square get divided up into little squares, and number each unit of measurement (one character) after dividing it. Right now it's essentially numbering the whole square as 1, then creating a dividing line and numbering everything after that as 2, then another dividing line and rewriting everything after that as 3... so now there are 3 columns... then it's supposed to go back through each column and rewrite parts of them until eventually you get something like this


1 2 3

4 5 6

7 8 9


or you could expand it to do any number you wanted (any size square).


This is the code:

#include "stdafx.h"
#include "iostream"

int _tmain(int argc, _TCHAR* argv[])
	using namespace std;

	int totalDivisions = 3;

	int mapSize = totalDivisions * totalDivisions;
		int mapDivider[180][180]; // This creates the array where the leaflets are stored.
		bool horiz = false;
		//Loop through and decide where the 'leaves' divide, assigning every node in a leaf the same number 1-= through (tD*tD)
		//give every node a "1"
		for(int a = 0; a < mapSize; a++)
			for(int b = 0; b < mapSize; b++)
				mapDivider[a][b] = 1;
			//divides across one axis, giving each horizontal area a number starting with 2 and climbing.
			int lastDivide = 0;
			for(int i = 2; i <= totalDivisions; i++)
				//choose a division line
				lastDivide += (mapSize/totalDivisions);
				//assign a number to everything above that division line. Overwrite the previous number.
				for(int x = 0; x < mapSize; x++)
					for(int y = lastDivide; y < mapSize; y++)
						mapDivider[x][y] = i;
			//Now that leaf across one axis has a number 1 through tD, divide each leaf tD number of times.
			lastDivide = 0; //resets last division point
			for (int bigleaf = 1; bigleaf <= totalDivisions; bigleaf++) //Which leaf you are currently dividing into tD number of sections
				for(int eachDivide = 0; eachDivide < (totalDivisions - 1); eachDivide++) //Divide each leaf into tD minileafs.
					//choose a new dividsion line.
					lastDivide += mapSize/totalDivisions;
					//Go through every node to the end, changing only if it has matches the current set.
					//Reassign every number above the lastDivide line, rewriting previous numbers.
					for(int x = lastDivide; x < mapSize; x++) // go through every x on the map, starting at the divider
						for(int y = 0; y < mapSize; y++) //change every number above the divider...
							if(mapDivider[x][y] == bigleaf + (eachDivide * totalDivisions)) //only if it's in the leaf we're working with.
								mapDivider[x][y] += totalDivisions; // add tD it each time >_>;
		for(int i = 0; i < mapSize; i++)
			for(int j = 0; j < mapSize; j++)
				cout << mapDivider[i][j] << " ";
			cout << endl;

I hope that displays well... I copied it from VSC++2010 and it looks like the tabbing is HUGE.


Anyway, the DESIRED output is

1 1 1 2 2 2 3 3 3
1 1 1 2 2 2 3 3 3
1 1 1 2 2 2 3 3 3
4 4 4 5 5 5 6 6 6 
4 4 4 5 5 5 6 6 6 
4 4 4 5 5 5 6 6 6
7 7 7 8 8 8 9 9 9
7 7 7 8 8 8 9 9 9
7 7 7 8 8 8 9 9 9

BUT, I am getting this instead:

1 1 1 2 2 2 3 3 3
1 1 1 2 2 2 3 3 3
1 1 1 2 2 2 3 3 3
4 4 4 2 2 2 3 3 3
4 4 4 2 2 2 3 3 3
4 4 4 2 2 2 3 3 3
7 7 7 2 2 2 3 3 3
7 7 7 2 2 2 3 3 3
7 7 7 2 2 2 3 3 3

I've tried a few things... once I neded up with just three columns of 7, 8, and 9. I was expecting it to do that though.


I don't understand why it's not going to the 2 and 3 leaves and dividing those the way it did the 1st column.


The reason I'm doing it this way, btw, is because this is going to expand into something more where the dividing lines are random, so you get n hallways of random length, and in each hallway, n rooms of random depth. But all rooms within a hallway should have the same width, and all hallways should have the same total depth.


So I will essentially just make lastDivide random (within a range that is close to mapSize/totalDivisions, without making any hallway too small).

The Legend of Red Dragon Ranch (Now with Kickstarter!)

08 February 2013 - 07:50 AM


Kickstarter is now live! Please support this project!


Hey everyone happy.png You may remember me from posting on the beginner board somewhat regularly (if only for a short time) a little while back... Anyway, thanks to everyone's help, I found the direction and motivation to teach myself game design and programming, improved my abilities, practiced a lot, and now I've partnered up with a friend and a colleague to start a pretty ambitious game development project. It started as my attempt at my first really "big" game project... Something I would have to devote weeks or months of planning, and then who knows how long to create. I wanted to take a big idea I had and just MAKE IT HAPPEN.


I really felt I was ready. As I talked with my friends, they really enjoyed the idea, and my composer friend offered to work on the music for the game. Whenever I would mention the project (even something dumb like making my facebook status "spent 4 hours getting one bug out today :,c") I would find people begging me to finish so they could play the game. I've found a lot of support for the project and it's given me a lot of motivation. The project has grown and grown and it's getting so big I now have three dedicated members of the development team, and we're starting a humble kickstarter soon (it's in the review queue right now) in hopes of getting some funds to make this game everything we'd like it to be.


Since this was really the place where I got the original confidence to teach myself to code, develop, and design, I thought I'd come back and share a "gamedev.net bigger board success story" or something, hahaha smile.png I started out programming it "from scratch" in C++ but later realized that everything in the design could be done all the same in a 2D engine and made my prototype in GameMaker:Studio, which is pretty new and pretty great. Since I'm still a bit of a novice programmer (this is my first 'big' game after all), it has really helped me organize my game and keep my focus on the design without having to worry about so many other issues.


Anyway, now that you know the backstory, let me introduce to you the game project, The Legend of Red Dragon Ranch:






It's a monster-training game that focuses on user play-style and care of the monster. It originally was just a curious idea in my head (I even asked some questions about pet games here when it was still a baby idea and I wasn't actually planning on creating it any time soon). Visit the link above to learn more. The "devblog" is not all that fleshed-out, but definitely tells a lot about the game if you read through the few posts that do exist.

Creating functions in GameMaker:Studio? And pseudo-enums?

20 December 2012 - 06:22 PM

So, I am throwing together a prototype for my pet game, and I figured I'd try GameMaker:Studio to make it faster, but it seems like GML is very... limited and confusing.

Anyway, I only need to pass a couple hurdles and I should be able to create a functioning prototype that I can use to test the concepts of the game and get others' input and stuff.

So, the first thing I wanted to do was create some functions that will take care of various calculations and stuff. And I'm already stuck lol. Well, none of the documentation on GML seems to be very explicit on how things are done. I logged into the GameMaker Community and it won't let me make a new post and I searched there and here and couldn't figure out exactly how they worked.

It seems like you make a Script, but I don't know how to define the arguments for it. It seems like the arguments are defined by variables you call argument0, argument1, etc. throughout the Script you make. So I guess the arguments for your "function" are based on how many argumentX variables you write into the Script...

Then the example in the documentation looks like this:

//clamp_x(xmin, xmax)
//maintain x within the given bounds

if x > argument0 { x = argument0; }
else { if x < argument1 { x = argument1 } }

... It looks like the "notes" remind you of what arguments the function can take based on how many argumentX variables are in the code. But then the comments also state that it's supposed to keep x within the bounds... but I feel like argument0 should be what they're calling "xmin" and argument1 is what they're calling "xmax" ... but wouldn't they be the opposite, based on what the function apparently does...?

I'm assuming the documentation just uses a flawed example? That argument0 would be the ceiling and argument1 would be the floor of where you're trying to keep x inside.

So if I want to write a function, do I just put any number of argumentN variables in the Script, and then make comments at the top to remind me how many I had and what kind of parameters this function should be taking?

This seems needlessly complicated X_X; I wish the documentation actually explained how it works. It pretty much just says "Scripts can be used like functions." and then gives that example from above with no further explanation...

Also, since I can't really create an enum with GML or make states with one, let's say I wanted the user to be able to choose one of 20 pets or something, and then this choice will persist for the rest of the game, even between Rooms. I've created a global variable for this, but is it possible to use strings and check for the strings to use it kinda like an enum? Like, let's say they picked Pikachu (I'm not making a Pokémon game; it's just an example) then I could set global.petSpecies to "PIKACHU" and from there on out, on each room, I will need to display their pet. So I will create a function that will, through a tedious set of if statements, check all of the monster names, and then an if global.petSpecies == PIKACHU statement can tell the pet object that displays to change its sprite to the Pikachu set... does that seem like it will make sense? I honestly can't think of a better way to do it using GML :\

I'm using the free version of GameMaker:Studio so I can't create my own extensions using C++, nor can I use extensions others have made... I can only use the tools that GM:S comes with.

EDIT: And what all kinds of arguments can a Script function take? Like, could I pass a variable (rather than a value) or a pointer (are there even pointers in GML...?) to a variable? I'm assuming no, but who knows. The documentation does not explain how this works at all.