Skip to content

Instantly share code, notes, and snippets.

View ajweeks's full-sized avatar

AJ Weeks ajweeks

View GitHub Profile
@ajweeks
ajweeks / dvmbr_30.md
Last active January 31, 2016 15:55
Devember Thirtieth

Devember Day 30

I added another improvement to the game's realism today, by requiring the player to face trees to chop them down. This can be done by a simple check of which direction the player is facing and to which direction the tree is.

I then disabled buttons, which required a bit of a rework of how I handled button clicks. The need for this feature arose while I was thinking about adding a save/load feature. I will likely have a "Resume Game" button in the main menu, along with a "New Game" button. If you don't have any previous saves, then the "resume game" button should be disabled. It's not the prettiest thing ever but here's what I'm using at the moment:

function buttonClick(button: string, event: MouseEvent, callback: () => void) {
    if (get(button).className === 'button enabled' && clickType(event)===ClickType.LMB) {
        callback.call(this);
@ajweeks
ajweeks / dvmbr_29.md
Last active January 31, 2016 15:55
Twenty-Ninth of Devember

Devember Day 29

I looked up how to flip meshes in three.js the other day when I went to the nearest library here in Vienna for their internet, and found a few stackoverflow.com answers which explained a few ways of doing what I wanted. So I implemented that today, and it's in the game now! It looks sweet, and somewhat surprisingly doesn't seem to cause any lag at all, even though it's updated every frame. The way I'm doing it by the way, in case you are wondering is:

if (xv < 0) {
    this.playerMesh.rotation.y = Math.PI;
} else if (xv > 0) {
    this.playerMesh.rotation.y = 0;
}
@ajweeks
ajweeks / dvmbr_27.md
Last active January 31, 2016 16:07
Twenty-Seventh of Devember

Devember Day 27

I added a walking animation for the player, so there are now three states: idling, walking, and running. I think it turned out quite well actually. I still haven't added any animations for when the player is walking straight up or down, so it looks quite strange at the moment. I also still haven't found a way to mirror the animations when the player moves to the left, but the animations look great when he walks to the right.

I also improved the way axe types are handled, by adding an AXE enumeration. I'm not sure what I'm going to require the player to do to upgrade their axe, I think there needs to be more than just "chop down 134 trees to get a gold axe". It would be quite cool to be able to purchase slaves (or robots maybe, to be more politically correct) which chop down trees for you. Then as you progress through the game, you go from being a humble, lonesome lumberjack to a CEO of a large logging corporation which you see over. These are just random ideas popping into my head as I wri

@ajweeks
ajweeks / dvmbr_26.md
Last active January 31, 2016 16:06
Devember Twenty-Sixth

Devember Day 26

I'm considering splitting the TM495 code base into separate files, mostly because Atom starts lagging a bit with files larger than a few hundred lines. That by the way is quite stupid, since handling files is a pretty basic functionality that every text editor should be able to do without any problem whatsoever, almost regardless of their size. It isn't always laggy, but once in a while it slows down for some reason. For the most part, I really love Atom, it loads quick and does a good job most of the time. I use an Atom plugin to compile my typescript code, which works really well also. The reason I am hesitant to separate things into multiple files, is that I've heard that each load a webpage makes slows it down, and loading all your code in one file is faster than loading several files containing the same code. I could copy and paste the compiled javascript into a single file whenever I update TM495 on my website, but that would

@ajweeks
ajweeks / dvmbr_25.md
Last active January 31, 2016 15:55
Twenty-Fifth of Devember

Devember Day 25

Merry Christmas! (or maybe I should say "Fröhliche Weinachten!", since I'm spending the holidays in Austria)

I spent some time trying to implement a full screen feature, but it turns out that I might not even want it in the first place. Everything is simply too big. I had to sit back in my chair and push my computer back to get my eyes to focus on the player. I could quite easily fix that, by simply making things smaller, but then they would be too small for non-fullscreen mode. There are lots of other little problems, like; scrollbars showing, the fact that your score is currently only displayed off the canvas, etc. I could try to fix all of those, but it doesn't seem worth it. So for now fullscreen is just going to be something on the feature wish list.

It's quite annoying to not have access to the internet. Especially when programming. Extra especially when trying to program something you've never programmed before. For example, today I wanted to make the player face the correct directio

@ajweeks
ajweeks / dvmbr_24.md
Last active January 31, 2016 15:55
Devember Twenty-Fourth

Devember Day 24

So much for taking a day off implementing new features I guess. I added a slight improvement to the collision detection algorithm, which results in the player getting nudged only if they are near the edge of an object. I realize that not everyone wants to see the code, and since the collision detection code is getting quite long I'll upload it for those who want to see it (here), and for those who don't, read on!

I also allowed the player to swing their axe even when not near a tree, because it felt like the game was trying to control you too much otherwise. I also made wider trees take more hits to chop down, although I think all trees have the same width at the moment.

After that I spent a while implementing an entity system. When a tree is chopped down, it now drops a log entity which has a certain life span and a position somewhere around the tree. Upon pickup, a little sound is played and your wo

@ajweeks
ajweeks / dvmbr_23.md
Last active January 31, 2016 15:54
Twenty-Third of Devember

Devember Day 23

Working on TM495 is beginning to become that kind of difficult game development, where you haven't ever done a lot of the features which you want implemented. Up until this point, most things I've added to the game I have written before; getting a rendering context, drawing a sprite on the screen, retrieving keyboard input, etc. But recently, I've been doing a lot of "well, I've never tried implementing this kind of system before, but this janky thing I just tried seems to work..." I suppose that is one way of learning game dev, and to some extent, maybe it's simply how the medium is mastered.

In my first programming projects for example, I would figure out how to get a rendering context going (by following tutorials mostly) and then become completely overwhelmed by the enormity of the task ahead of me, and end up scrapping the project, half finished. Then, as my skills progressed, I would get further and further into projects, but eventually I seemed to almost always hit a certain point whe

@ajweeks
ajweeks / dvmbr_22.md
Last active January 31, 2016 15:54
Twenty-Second of Devember

Devember Day 22

tl;dr: TM495 is looking good.

Surprise surprise, more work on TM495 today. First thing I did was greatly improve the collision detection algorithm. Within the player's update method, if they have attempted to walk into a solid object, I nudge them to the correct direction. I still need to add a check to see if they're near the edge of the object. Even still, walking around the level feels much smoother now. Although I still need to tweak some values, as it can feel kind of weird getting shot to the side when walking into a tree. The algorithm could also probably use a bit of an efficiency improvement, but I will think about that later. For now, the game is silky smooth, and you know what they say - I don't want to be doing the root of all evil.

I realize that these posts are a little boring since I'm not adding any screenshots. The actual look of the game hasn't really changed over the last few days. But to keep things somewhat interesting, I'll try to add some code snippets here and there.

@ajweeks
ajweeks / dvmbr_21.md
Last active January 31, 2016 15:54
Devember Twenty-First

Devember Day 21

Unfortunately I don't have much access to internet atm, so I'm not sure when this will be uploaded. However I did get some good work done on TM495, it's looking really good actually!

EDIT: I've managed to find some free wifi at the nearest library, so I'll be uploading this entry along with the one following it now, two days after it was written.

Since yesterday, I've added slight variations to tree's heights (and therefore how much wood you get from chopping them down), an improved way of loading textures, and - most exciting thing of all - improved animations!! Now you can specify however many images you want to use for different animations, and simply switch between them at will! I would upload a gif of it working in action, or at the very least push it to GitHub, but until I get better access to internet I'll have to hold off. I'm planning on looking for a nearby library which offers free WiFi tomorrow.

By the way, since I haven't mentioned yet where I am - I'm in Austria for the h

@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"))
{
}