Comment First Coding

Comment first coding

Comment first coding is a technique that I have used for many many years, but only today found out it has an actual name! (I had a jolly good Google before starting writing this post).

I find it especially useful when I am coding in a language which I am not overly familiar with.

The basic premise of Comment first coding, is planning out what you want your code to do using either plain English, pseudo-code or a mixture of both, in comments.

Then going through one comment at a time, actually writing the code proper.

	//db-jointeam.php - POST(team ID), find playerID from username ($_SESSIONS variable)
	//	If playerID = specified Team's ownerID
	//		Add player to teamlobbyplayers
	//		Set isActive to 1
	//	Else
	//		If isActive = 1
	//			Add player to teamlobbyplayers
	//		Else
	//			Error, lobby not active
	//		Endif
	//	Endif

Above is an example of some Comment first coding from a project I am working on which uses PHP to access a MySQL Database which holds the games player and team data.

Conclusion

And that’s pretty much all there is to Comment first coding. Like I said earlier, I find this technique to be extremely helpful generally, but more so when I’m using a language which I’m not overly familiar with.

Game Progress Update #9

Update #9

Hello World, and welcome to the ninth Dev with Dave Game Progress Update. I’ve not managed to get as much done as I’d have liked, but once again, the curse of tiny image resolutions has made creating the graphical assets take a fair bit longer than I was expecting.

The Menu

The first and most obvious change to this update is the inclusion of the menu button in the bottom left hand corner of the screen.

I’ve used a simple ham burger style icon to represent the menu, shown above with the red exclamation mark indicating that there is something to see in one or more of the menus.

Pressing the menu button opens up the main menu screen. There are currently three buttons, but depending on how things look, I may split the upgrades into two sections, which would require a 4th button.

I didn’t have time to finish the icons for these buttons so they have only simple text labels right now. Each one of the buttons opens up a new UI page.

Pressing the Upgrade button takes you to the upgrade page, where the player can unlock and upgrade various powerups,

All of the UI elements on the menus are created using the existing UI systems which I created earlier in the project.

Power Up Icons

I’ve also created icons for the power ups which the player collects. Below are the icons for the Magnet, Shield, Multiplier and Smart-bomb powerups.

I’ve not however managed to implement them properly into the game yet though.

Refactoring the UI Systems

I spent several hours refactoring the UI systems code after I noticed a much better way of organising the variables. It’s not really changed the way the code works, and there are no visible changes to the player.

Next time

In the next update I hope to have the UI looking a lot more complete, and be fairly functional as well. I’d also like to get the power-up collection a little closer to completion as well.

I also have a lot of updating to do on the Trello board and the GDD, I will try and get these done soon and I’ll update you via social media.

See you next time 🙂