Skip to content

Instantly share code, notes, and snippets.

View ajweeks's full-sized avatar

AJ Weeks ajweeks

View GitHub Profile
private void updatePower() {
for (int y = 0; y < grid.height; y++) {
for (int x = 0; x < grid.width; x++) {
Tile curTile = getTileAt(x, y);
Tile north = getTileAt(x, y - 1);
Tile south = getTileAt(x, y + 1);
Tile east = getTileAt(x + 1, y);
Tile west = getTileAt(x - 1, y);
# Largest Product in a Grid
s = "08 02 22 97 38 15 00 40 00 75 04 05 07 78 52 12 50 77 91 08 49 49 99 40 17 81 18 57 60 87 17 40 98 43 69 48" \
" 04 56 62 00 81 49 31 73 55 79 14 29 93 71 40 67 53 88 30 03 49 13 36 65 52 70 95 23 04 60 11 42 69 24 68 56" \
" 01 32 56 71 37 02 36 91 22 31 16 71 51 67 63 89 41 92 36 54 22 40 40 28 66 33 13 80 24 47 32 60 99 03 45 02" \
" 44 75 33 53 78 36 84 20 35 17 12 50 32 98 81 28 64 23 67 10 26 38 40 67 59 54 70 66 18 38 64 70 67 26 20 68" \
" 02 62 12 20 95 63 94 39 63 08 40 91 66 49 94 21 24 55 58 05 66 73 99 26 97 17 78 78 96 83 14 88 34 89 63 72" \
" 21 36 23 09 75 00 76 44 20 45 35 14 00 61 33 97 34 31 33 95 78 17 53 28 22 75 31 67 15 94 03 80 04 62 16 14" \
" 09 53 56 92 16 39 05 42 96 35 31 47 55 58 88 24 00 17 54 24 36 29 85 57 86 56 00 48 35 71 89 07 05 44 44 37" \
" 44 60 21 58 51 54 17 58 19 80 81 68 05 94 47 69 28 73 92 13 86 52 17 77 04 89 55 40 04 52 08 83 97 35 99 16" \
" 07 97 57 32 16 26 26 79 33 27 98 66 88 36 68 87 57 62 2
@ajweeks
ajweeks / Slider.cpp
Created December 20, 2015 18:23
Classes2Home1 Slider class
#include "stdafx.h"
#include "Slider.h"
#define GAME_ENGINE (GameEngine::GetSingleton())
Slider::Slider(const DOUBLE2& posRef, int minValue, int maxValue)
: Slider(posRef, minValue, maxValue, String("value"))
{
}
@ajweeks
ajweeks / dvmbr_02.md
Last active January 31, 2016 15:53
Second of Devember

Devember Day 02

Today, being a Wednesday, I have no problem whatsoever with both remembering and setting aside time to write code, since I have a programming class for 3 hours. I will some snippets of the code I wrote today along with this post, and some screenshots. However, I'm using my school's private game engine, and I can not post that code online.

So far we've only covered quite simple topics in class, this week we are learning about vectors. (C++ std::vectors to be specific). I did learn one interesting technique for calculating a equilateral triangle's third point, given the first two. Most of the rest of the code I wrote was very rudimentary vector manipulations, so I won't include it. (Min, max, number of occurrences, copying, reversing, etc.)

:::C++
void VectorLab1::FillEquilateralTriangle(const DOUBLE2 &p1Ref, const DOUBLE2 &p2Ref)
{

std::vector points;

@ajweeks
ajweeks / dvmbr_03.md
Last active January 31, 2016 15:53
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)
@ajweeks
ajweeks / dvmbr_04.md
Last active January 31, 2016 15:54
Devember Day Four

Devember Day 04

Happy Friday! I got a solid 2.5 hours of coding done today, just more work on my school assignment, which is finally finished. We had to make a dice rolling simulator and display the results, as well as a Koch snowflake renderer. I've made Koch snowflakes before, but this time I tried using a different method. You can see the main recursive method here:

void VectorAdd3::AddKochPoints(DOUBLE2 startPoint, DOUBLE2 endPoint, std::vector<DOUBLE2> &kochArrRef)
{
	DOUBLE2 diff = endPoint - startPoint;
	if (diff.Length() < 12)
	{
@ajweeks
ajweeks / dvmbr_05.md
Last active January 31, 2016 15:54
Remember, Remember the Fifth of Devember

Devember Day 05

Today was the first day where I actually wasn't that excited to do some game development. Maybe it's because it is the weekend and I kind of want to relax a bit, or because I've just never consciously attempted to code everyday of the week for an extended period of time. I've probably gone longer than five days in a row programming every day, but doing it purposely is a little different.

Either way, I did get a good hour of work done on TM495. Nothing particularly interesting, I spent most of the time working on the movement system. It's not currently working, and the camera offset is turning out to be more difficult to implement than I thought it would be. Although, it is the kind of thing where you just add a negative sign somewhere and everything works perfectly, so I haven't given up hope yet.

I've also been distracted all evening by the streaming of HandmadeCon 2015. I've been listening in on that most of the night, including now as I type this

@ajweeks
ajweeks / dvmbr_07.md
Last active January 31, 2016 15:54
Seventh of Devember

Devember Day 07

Well I actually managed to get an hour of development done in class today. Maybe it helped that I have programming classes on Mondays. But usually the teacher spends a lot more time talking than allowing us to actually code.

Today's lesson was about classes in C++. They are starting at the absolute basics, which is understandable because some kids haven't ever seen programming before. However, I've had four semesters of computer science classes prior to this school so I guess I could say that I won't be worried about passing any programming tests any time soon.

The example program we made in class was a virtual ball pit type thing. We created a Circle class to store position, velocity, colour, and radius. Then just updated and rendered a vector of them. I spent a while trying to implement collision detection, which I got to work somewhat well. I'm interested in learning a more advanced way of doing it than simply checking if two circles intersect every frame and changing their velocities

@ajweeks
ajweeks / dvmbr_08.md
Last active January 31, 2016 15:54
Eighth of Devember

Devember Day 08

I kind of managed to get an hour of programming in today, but only sort of. If you haven't heard about it, there's this daily livestream called Handmade Hero, where Casey Muratori explains how to make a game, from scratch, in c++. No engines, no frameworks, not even OpenGL or DirectX. I watched the livestreams from the beginning of the series, but I never followed along. Recently I decided to start at the first episode and follow along, line by line. I think the only realistic way for me to actually meet the devember challenge, as well as catch up to where Casey is right now - episode 220 at the time of this writing - is to include time I spend watching his recorded livestreams. They are about an hour long, with 30-60 minutes of Q and A afterwards. I usualy take probably an extra 10 or 15 minutes than the actual length of the video, since I pause and try some things on my own. That extra time will only increase as the complexity of the project also increases.

Unf

@ajweeks
ajweeks / dvmbr_09.md
Last active January 31, 2016 15:54
Devember Ninth

Devember Day 09

Today was another easy day do get the hour of coding done on. However I'm going to have to keep this entry short, I don't have a ton of free time tonight.

I got a solid hour and three quarters of programming in today, during class. Nothing too difficult, but still kind of interesting work. This week's "theme" if you will, is classes. So in this exercise we had to make a Fraction class, a Light class, and a Cone class. We also had to implement some basic point in shape checking, for seeing when the mouse was clicked in a 'light' or when it was hovering over a triangle.

We are supposed to use the game engine's physics system to check if a point is inside each triangle, but I wanted to know how it's actually done so I implemented the Barycentric coordinate system. When I say that I implemented it, all I really mean is that I copied straight from a stack overflow answer and modified it to fit my variables. I don't quite understand how it works, b