Starbeamrainbowlabs

Stardust
Blog


Archive


Mailing List Articles Atom Feed Comments Atom Feed Twitter Reddit Facebook

Tag Cloud

3d 3d printing account algorithms android announcement architecture archives arduino artificial intelligence artix assembly async audio automation backups bash batch blog bookmarklet booting bug hunting c sharp c++ challenge chrome os cluster code codepen coding conundrums coding conundrums evolved command line compilers compiling compression containerisation css dailyprogrammer data analysis debugging demystification distributed computing docker documentation downtime electronics email embedded systems encryption es6 features ethics event experiment external first impressions freeside future game github github gist gitlab graphics hardware hardware meetup holiday holidays html html5 html5 canvas infrastructure interfaces internet interoperability io.js jabber jam javascript js bin labs learning library linux lora low level lua maintenance manjaro minetest network networking nibriboard node.js operating systems own your code pepperminty wiki performance phd photos php pixelbot portable privacy problem solving programming problems project projects prolog protocol protocols pseudo 3d python reddit redis reference release releases rendering resource review rust searching secrets security series list server software sorting source code control statistics storage svg systemquery talks technical terminal textures thoughts three thing game three.js tool tutorial tutorials twitter ubuntu university update updates upgrade version control virtual reality virtualisation visual web website windows windows 10 worldeditadditions xmpp xslt

Tips on writing annoying / difficult code

If you've been programming for any length of time, you'll know that eventually you will have to implement a particularly complex algorithm or conquer some other especially difficult challenge. Maybe it's implementing specular lighting, or perhaps it's fixing a nasty annoying bug in your physics engine.

Since I seem to have been doing this with increasing frequency at the moment due to University coursework, I thought I'd share a few things with you that I personally find helpful.

Plan out what you intend to do. Create a flowchart. Fill a whiteboard with notes. Talk to someone. Even if it's a rubber duck. Planning out what you want to do ensures that you have a clear idea in your head as to what you want to accomplish and how to go about doing it. It's very easy to fall into the trap of doing random things and just hoping that it will work.

Break the task down into steps. This goes hand in hand with the above point. Break your task down into small, manageable steps that you can follow one at a time to achieve your goal. I often find if I don't do this the problem I'm trying to solve looks an awful lot bigger than it really is.

Tackle the steps one at a time, and test regularly. Skipping to step 3 when you've barely started step 1 might be tempting, but it will probably cause more problems that it solves and lead to confusion. If you're thinking of doing this, then you might not have your steps in the right order.

Similarly, doing steps 1-4 before testing what you've done also isn't a good idea, because you might have made a mistake in step 1 that affects the output of step 4, and then spend an hour debugging step 4's code only to realise it is fine and it's actually the code you wrote in the beginning that is causing the problem.

I hope you find these tips helpful. If you did, leave a comment below!

Organise your code snippets with GistBox

Gistbox logo

As I have been progressing with my degree, I have found myself with an increasingly large library of reusable code. While this is a good thing as it means that I don't have to write the same functionality twice, I have been discovering that it is rather difficult to find the code snippet I want to use in any reasonable length of time - probably due to the absence of a meaningful organisational system.

Recently I found GistBox whilst scouring the internet for a decent solution. It lets you tag and organise the code snippets that you have uploaded to Github Gist. Now instead of hunting through past projects to find a piece of code I want to reuse, I can instead (in theory) just open GistBox and search that instead, assuming that I have gotten around to uploading that snippet to Github as a gist.

GistBox does have it's flaws (like a terribly uncustomizable code editor that doesn't let you switch between space and tabs), but all in all it's a huge improvement over my previous (non-existent) system. Now all I have to do is to move all my snippets over to it so that they are all in one place (assuming that I can find them).

Portfolios are important

Attending the Game Development conference for students at Hull University gave me a little bit more of an idea as to what companies are looking for in perspective graduates (and more importantly interns in my case) that they are thinking of hiring. The thing that came across to me as the most important is the idea of an up to date portfolio. If you haven't come across one of these before, a portfolio is basically a showcase of everything that you've done, presented in a manner that is pleasing to the eye.

In my case my portfolio is my website, so I've just been spending half an hour or so updating it to reflect my current projects and accounts (I've opened an account on Codepen). You should do this too, and if you haven't got a portfolio set up, you can create one for free with Github Pages. If you're feeling particularly adventurous, you could also create a blog using Jekyll - Github pages supports this too, and it lets you create blog posts as markdown documents (like I do for this blog, although I wrote my blog engine myself), and it automatically transforms them into a blog post on your website for you. You can even use the Github web interface to do everything here!

If you comment below or get in touch with me in some other manner, I might feature a selection here on this blog.

The Big Wheel in HTML5

The Big Wheel in HTML5.

Just in time for Hull Fair to leave (yes I know they left last week), I've finished recreating the big wheel using the HTML5 Canvas. It's even got search lights and gradients.

Here's a link to the Big Wheel - Make sure that you use a recent browser (I'm using ES6 classes).

The basic pattern I used to create it was to break the scene down into different things, create a different class for each thing (except the background), and then break each thing down into its component parts. Each component part then got its own drawing function, which are then all called by the master renderer function for that class.

In order to position everything correctly, I abused context.save(), context.restore(), context.translate() and context.rotate(). Since the saving / restoring of the canvas state works like a stack, you can push as many drawing states to the stack as you like, and then pop them all off when you're done.

If anyone is interested in proper 'making of' post, please comment down below and I'll write one up!.

Static Variable Memory Allocation

Recently we were asked in an Advanced Programming lecture to write a program that proves that static variables in C++ are located in a different area of memory to normal variables. This post is about the program I came up with.

But first I should probably explain a little bit about memory allocation in C++. I'm by no means an expert (I'm just learning!), but I'll do my best.

There are two main areas of memory in C++ - the stack and the heap. The stack is an ordered collection of data that contains all the local variables that you define. It grows downward from a given address in memory. The stack is split up into frames, too, with each frame being a specific context of execution. You can find more information about this in the Intel Software Developer's Manual, Section 6.2.

The second area of memory is the heap. The heap is a large portion of memory that can be used for storing large lumps of unordered data. I haven't taken a look at this yet, so I don't know much more about it.

Apparently variables that are declared to be static are not located in the stack (where they are located I'm not entirely sure), and we were asked to prove it. Here's what I came up with:

#include <iostream>
#include <string>

using namespace std;

void staticTest()
{
    static int staticD = 0;
    cout << "staticD: " << &staticD << endl;
}

int main()
{
    int a = 50;
    int b = 200;
    int c = 23495;

    cout << "a: " << &a << endl;
    cout << "b: " << &b << endl;
    cout << "c: " << &c << endl;

    staticTest();

    int e = 23487;
    cout << "e: " << &e << endl;

    //cin.get();

    return 0;
}

The above simply creates 3 normal variables, outputs their addresses, calls the staticTest() function to create a static variable and output it's memory address, and then creates a 4th normal variable and outputs its address too. The above program should output something like this:

a: 0091F8C4 b: 0091F8B8 c: 0091F8AC staticD: 00080320 e: 0091F8A0

In the above output, the normal variables a, b, c, and e are all located next to each other in memory between the adresses 0091F8C4 and 0091F8A0 (note how the memory address is decreasing - the stack grows downward, like a stalactite). The static variable staticD, however, is located in an entirely different area of memory over at 00080320. Since it's located in an entirely different area of memory, it's safe to assume, I think, that static variables are not stored in the stack, but somewhere else (I'm not sure where - the heap maybe?).

If you know where they are stored, please leave a comment below!

Programming 2 Coursework - PickupTheCrew

A screenshot PickupTheCrew I recently got an email from a university friend asking for my Programming 2 coursework. It gave me the idea that I should make a blog post about it, so here it is. For my Programming 2 coursework this seester I was asked to build a game to a specification called "Pickup The Crew". My implementation can be found below:

I am releasing this under the CC-BY-SA (Creative Commons Attribution Share-Alike) license. If this is not the correct license for this thing, please contact me (leave a message in the comments!) and I will change it.

You can find it here: PickUpTheCrew

To extract the above archive you will need 7-zip. Once extracted navigate to PickupTheCrew\PickupTheCrew\bin\Windows\Release and double click PickupTheCrew.exe.

If you have any problems, please comment below and I will try to help.

Rob Miles' Tags for Red Nose Day

The tags that I bought

Hello again!

Rob Miles sold these unique 3D printed tags generated by a python program for red nose day for £1 each. I bought 4. If you had a tag that was identical to a picture that he showed on the board in his Lecture in Rhyme (which was great by the way), then you won either a Remote control Car or a Robot. Needless to say I didn't win, but I did have a great time :)

Thing list for 3 Thing Game!

The thing list for 3 thing game has just been released!

Find it here.

In case you can't read the list there, the list is as follows:

Tower, Beaver, Brain, Seagull, plane, Polo, Wombat, Harmonica, Pastie, Spam Fritter, Waifu, Shop, Pasta, Apocalypse, Pirate, Haunted, Really large gun, Struggle, Tentacles, Elephant, MLG, Skeleton, Parrot, Mayhem, Heist, Mountain Dew, Rhythm, Wristwatch, Rubber, Cauldron, Jacket, Doritos, Puzzler, stealth, Cat, Kit-Kat, Crimping, Undersea, Grunting, Zeus, Flesh Eating, Spell, Cool Spot, Potato, Clock, Boiler Suit, Pineapple, Space, Ocean Liner, Robot, Boots, Alien, Rainbow, Frantic, Drainpipe, Pig, Puzzle, Mushroom, Dressing Up, Hand grenade, Gong, Ninja, Steroids, Potion, Dilemma, Zombie, Bones, Graveyard, planets, Cube, Wand, Electric, Warlock, Jellyfish , Vampire, German, Paint, Nerds, Circles, Bus, Tunnel, Cupcakes, System, Broomstick, Party, Lazer, Sci-Fi, Panic, Skull, Ethical, Voxel, Plot, Locked, Robotic, Pixies, Unity, Spacecraft, Inventor, kettle, Balloon, Topdown, Ghost, Satan, Nuke, Nose, University , Banjo, Fingers, petril, Panini, Green, Flying Fish, Banana, Gems, Anti-aircraft gun, Android, Falling, Snakes, Combat, Goat, instakill, Chickens, Communism, Tribal, of Doom, Downstairs, Wolf, Umbrella, Maggot, Ship, Time, Weapon, Football, wizard, Cheesebot, Hunting, Grave, Slippery, Endoscope, Meme, Cheese, Yeti, Bat, Beard, Trousers, Attack, Witch, Assassin, Pension, Pea, Web, Triangles, Spider

Art by Mythdael