Clipping Images

Published September 21, 2007
Advertisement
After a little bit of research, and a little bit of experimentation, I have revamped my &#106avascript pipes game with some new graphics.

The code has been refactored, but that isn't that big of a deal. It still does the same stuff, it's just better organized into classes.

The biggest change in my mind was switching from individual graphics for each of the states that the cell can be in (a total of 128 images) to a single image.

In order to view a smaller part of a larger image in an IMG tag, one must use styles. In particular, one must use position, clip, left, and top.

Clip is by far the strangest style I have ever used. To specify a clipping rectangle, I need to pus something like:

clip:rect(0px 32px 32px 0px);

the order of the values in the rectangle are top, right, bottom, left... or what I had refered to as "completely stupid" when I first looked at it, but after thinking about it, and in thinking about other things that I do, like number directions in the order North, East, South, West, it makes complete sense. Plus it is important that styles were not created with programmers in mind, but rather designers.

so enjoy. pipes is starting to take some real shape.
Previous Entry Two things:
Next Entry Google Gadgetized
0 likes 0 comments

Comments

Nobody has left a comment. You can be the first!
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Profile
Author
Advertisement

Latest Entries

Music To My Ears

1765 views

Getting There...

2012 views

Guess Chess

1911 views

iPhone JetLag

1863 views

iPhone JetLag

1706 views
Advertisement