Sunday 7 January 2018

Connor's Portal 2 levels

Connor has been playing portal 2 since he was 3 years old, and has been making his own levels almost as long.

He's published 10 levels so far - they can be found here:
https://steamcommunity.com/profiles/76561198325470848/myworkshopfiles/?appid=620

(Most of them require the install of BEEMOD - it adds more puzzle elements to the pallet such as the pellets)

If you play portal 2 on PC and could try them out, that'd be amazing! If you leave comments/feedback he'd be over the moon!

If you don't have time to try all of them, my personal favourites are:

yes it is possible (if you're looking for a challenge),

I think laser levels is an elegant level full of re-use and recycling of puzzle elements,

and two headed test chamber purely for the aesthetics / symmetry.

Thanks for reading

Tim (and Connor).

Saturday 3 May 2014

Save a line - assign and test

In C++ if you Get() a member pointer and then check if it's null before you use it (which is probably quite a common occurrence) and you're using two lines to do it in, you can save a line by testing the result of the assignment inline.
 Player player1 = PlayerManager.GetPlayer(1);  
 if (player1 != NULL)  
 {  
    player1.doStuff();  
 }  

becomes:

 if (Player player1 = PlayerManager.GetPlayer(1))  
 {  
    player1.doStuff();  
 }  


Saturday 17 September 2011

More half baked ideas

I posted one half baked idea a while back (find people by interest).

Here's another.

A personal, multi-accessible, cross-platform, "cloud", simultaneous-accessible scheduler.

I want to be able to access my schedule through my phone or my home computer or my work computer.

I want the option of scheduling a reminder independently of the event - so I could say I want a reminder on this date at this time, and the title of the event is XYZ. Currently, with outlook, I have to specify 2 date / time periods - first when the event is, then when I want the reminder - I'd rather do it in one.

I want the reminder to pop up on all my synced devices simultaneously, so whichever I happen to have with me / am looking at, I get the reminder - at the moment I can't schedule everything in outlook at work because sometimes I'm not in the office. I can't schedule everything on my phone because sometimes my phone is on silent (e.g. when I'm in the office). When I get my reminder, I want to be able to snooze the reminder on one device, and it will pop up again after the snooze duration on all my synced devices, and any of the devices could snooze it again.

Thursday 3 March 2011

The taskbar is my mental stack

If I've got one objective that I'm trying to achieve, I might need to meet several sub-objectives along the way.

So if I've got visual studio open and I'm working on my main feature, then I notice I need to get something out of a folder, I'll open an explorer window and navigate to that folder. While I'm there, I realise I need to do something later, so I'll make a note of it in notepad. A colleague then asks me to fix something in another program, so I'll open another instance of visual studio, and maybe firefox to look up the issue in the bug database, and another explorer window to find the data.

Pre-windows 7, my taskbar would now have 6 items on it, in the order: visual studio 1, 1 explorer window, notepad, visual studio 2, firefox, and another explorer window.

The items on the taskbar were arranged in a similar way to how they were ordered in my mind. As I complete sub tasks, I can close the programs one by one, from latest, to earliest, until I've finished my main task. That was good.

Now, windows 7 groups similar items together. Which means the mental associations between the second visual studio and the explorer window (for example) are no longer matched by what's on screen, which means I have to spend mental effort connecting the various items whenever I try to work out what I was doing. And since lots of my work involves putting my mind through a mangler (figuratively), any extra mental effort that I have to put in that I didn't used to have to do, isn't appreciated :-(

Luckily, there's (at least) one app which "fixes" this for me. Windows 7 Taskbar Tweaker lets me change the behaviour so that buttons are no longer grouped. Back to full productivity again! :-)

Sunday 6 June 2010

One-liners: Prevent beep after pressing 'enter' in a control

If you're a fan of your keyboard shortcuts, you might notice that windows sometimes emits a beep (or bell) after pressing enter to select something. Prevent the bell by setting the KeyDown eventargs SuppressKeyPress member to 'true' if the enter key was pressed.

protected override void OnKeyDown(KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
e.SuppressKeyPress = true; // stop the bell!!!
}

One-liners: Designer autogenerates Property = null

Sick of the c# designer setting your control's property to null in the InitializeComponent() function? Then simply set the property's default value to null so InitializeComponent() doesn't have to!

[DefaultValue(null)]
My Property...

Saturday 5 December 2009

Apps Hungarian vs Systems Hungarian

Hungarian Notation is a convention where a prefix is given to a name to indicate its type. There are two flavours of Hungarian, and most of the criticisms are directed at Systems Hungarian, while people don't realise that Apps Hungarian even exists.

Systems Hungarian prefixes variable names with their type. One big argument against doing this is that if the type changes, then you have to change every occurence of that name to match the new type.

Apps Hungarian prefixes variable names with semantic information about the variable.

Without the prefix, "Filename" might be a string, a text box, or something else. "Car" could be an instance of the car class, or a pointer to a car, or an index into a list of cars. "First" and "Second" could be almost meaningless, but in a spreadsheet application (for example) they could refer to rows, columns, cells, or something else.

With a semantic prefix, things become clearer. In a forms application txtFilename is now likely to be the name of a textbox which contains a file name, while strFilename is more likely to be the string itself. Note that strFilename doesn't constrain me to any particular type of string - just that it is a string of some description.

"iCar" is a sensible index into an array of cars, "pCar" is a pointer to a car, and "car" is most likely to be a concrete instance of the car class.

My favourite example comparing Apps Hungarian to Systems Hungarian is based on spreadsheet software.

Using Systems Hungarian (prefixing the type to the name), if "first" and "second" are integer indices, the assignment "iFirst = iSecond" looks alright at first glance. However, if the two variables were refering to rows and columns respectively, then the assignment was used to assign incompatible values.

If we'd used Apps Hungarian instead, the assignment now becomes "rowFirst = colSecond" and without knowing anything about the type of the data, if we saw that assignment, alarm bells would be ringing.

A colleague told me that a 'p' prefix before a pointer name was unneccessary - His arguments were:
  1. we have strongly typed compilers which can tell us when we've tried using the variable incorrectly
  2. intellisense can tell us a type just by hovering the mouse
  3. if a name was followed by a dot '.' then it was a concrete instance
  4. if it was followed by an arrow '->' then it was a pointer.
My counter-arguments are:
  1. Wherever possible, I want to type code correctly in the first place - not have to wait for the compiler to tell me it's incorrect.
  2. Intellisense requires me to shift control-context to the mouse - which can be very disruptive during an intense coding-at-the-keyboard session
  3. Intellisense doesn't always get it right
  4. The code that has already been written isn't guaranteed to have used dots and arrows yet - explained below:
If you had a variable m_CurrentVehicle - and a member function, EnoughFuel(); which is correct? m_CurrentVehicle.EnoughFuel() or m_CurrentVehicle->EnoughFuel() ?
If the variable was named m_pCurrentVehicle, then you would be able to see the answer instantly.

I used to hate seeing things in Systems Hungarian like lpszMessage (long pointer to a string which is zero terminated), but I like Apps Hungarian.