Skip to content

Instantly share code, notes, and snippets.

@ajweeks
Last active January 31, 2016 15:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ajweeks/01253962f233ab1eb5b0 to your computer and use it in GitHub Desktop.
Save ajweeks/01253962f233ab1eb5b0 to your computer and use it in GitHub Desktop.
Devember Third!

Devember Day 03

Thursdays, like Wednesdays, are easy for me to get an hour of programming done on because my school has these events called "Study nights" every Thursday. It's nothing more than just allowing students to work on assignments at school until 10pm. It actually does wonders for motivation, because almost everyone around you is working, and so you feel much more compelled to work as well.

Tonight I spent the first two hours or so working on 3D props for my final 3D assignment - a Japanese city scene. Then I switched to programming, and worked some more on the assignment I have due next week. Again, the code uses my school's game engine - which I won't be posting.

Yay for horribly inefficient sorting algorithms!

/** Sort the given array using Bubble sort */
void VectorHome1::Sort(std::vector<int> &numbersArrRef)
{
	boolean swapped = true;
	int j = 0; // keep track of how many values we have sorted correctly
	while (swapped) { // once we run through the loop without any swaps, everything is sorted
		swapped = false;
		j++;
		for (int i = 0; i < int(numbersArrRef.size() - j); i++) {
			if (numbersArrRef[i] > numbersArrRef[i + 1]) {
				int temp = numbersArrRef[i];
				numbersArrRef[i] = numbersArrRef[i + 1];
				numbersArrRef[i + 1] = temp;
				swapped = true;
			}
		}
	}
}

Also, after posting yesterday's devember log, I got some work done on TM495. I implemented a random sprite placer which can place tree trunks randomly spaced around the level. The algorithm could use a bit of improvement, so far it just ensures that two trunks aren't placed on top of one another and that all the trunks are inside the screen. More work on that will be done tomorrow!

Previous Entry | All Entries | Next Entry

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment