Posts Tagged ‘Javascript’

Let’s Build a Game! Part 1

June 29th, 2013 2 Comments

Game screen
Canvas has been something I wanted to make games with for a while now. It can be tough to put the time into it when you are focusing on other things, but every now and then I get to sit down and play around. But I have learned a few things, so lets see if I can help you too as well!.

So to begin, you can find an example of the game here I will be creating a separate repo for the game, so that you can see the code as it is from part to part. The game we will be creating will be very simple. We will have a few key features:

1. Player movement from input
2. Getting the player firing bullets!
3. Getting the enemy to fire back.

So in the end we will have a simple game. You have your players ship, it can move up and down and left and right etc, you can fire bullets, and we will have an enemy that can fire back at us. Super simple but pretty satisfying to get set up. Lets dive in!

All game files can be found Here. So that you can follow along, or create your own!

jQuery CSS Multi-property getter

May 28th, 2013 No Comments

How many times have you wanted to get more than one property, say the margin or padding of an element with jQuery? After looking through the jQuery 1.9 release notes I saw that you can now use .css() to get many properties.

Now, apparently being able to set something like the padding short hand was something that you have be able to do for a while.

$('div').css('padding','1em 2em 3em 4em');

As of 1.9 you are now able to get multiple values:

var cssProps = $('div').css(['paddingTop','paddingRight','paddingBottom','paddingLeft']);