Exponential Spirals for Game Effects May 4th, 2009
Patrick Stein

In earlier posts, I mentioned finding polynomials, riffing off of damped harmonic motion, and then hitting on exponential spirals all trying to come up with a nice looking way to snap game tiles back into place when they are released. I want them to overshoot and then settle into place rather than snap directly into their spot.

The Basic Spiral

I am talking about a simple spiral of the form:

\theta(t) = Kt
r(t) = \alpha\left(Kt\right)^{n}
for some integer n.

That would be an equation for a spiral that starts at the origin and heads outward as t increases. For my application though, I want to end at the origin so I need to substitute 1-t in for t.

\theta(t) = K(1-t)
r(t) = \alpha\left(K(1-t)\right)^{n}

The math is also going to work out slightly better if I use n-2 in place of n in the above equations:

\theta(t) = K(1-t)
r(t) = \alpha\left(K(1-t)\right)^{n-2}

I don’t want the piece to spiral into place when released though. So, really, I am concerned with just the x coordinate from the above equations:

x(t) = r(t) \cos \theta(t) = \alpha K^{n-2} (1-t)^{n-2} \cos \left(K\left(1-t\right)\right)

To normalize everything, I am going to let \alpha = K^{2-n}. And, since I want my interpolation value to go from zero to one instead of one to zero, I am again going to subtract this all from one:

x(t) = 1 -  (1-t)^{n-2} \cos \left(K\left(1-t\right)\right)

Read the rest of this entry ⇒

A Eureka Moment May 1st, 2009
Patrick Stein

I was pondering the Phony Physics again as I set to work on my iPhone app.

In the previous post, I twiddled the equations for damped spring motion until I found something visually pleasing. Last night, I went back to the drawing (a.k.a. white) board.

What if I used an exponential spiral (parameterized by arc length). Then, I could easily adjust the number of times it bounces back and forth. I could use a spiral like r(t) = \alpha K (1-t)^n and \theta(t) = K(1-t) where K is some multiple of 2\pi. Then, I could walk along the spiral getting to the origin when t = 1 going around the origin \frac{K}{2\pi} times in the process. If I follow the curve at a fixed rate, then I guarantee that my oscillations will pick up speed as I approach the origin.

Rather than have it spiral into the center, I am just using the x-coordinate of the spiral as my new t value to interpolate with. I like the effect for the most part. It overshoots a little bit far on the first oscillation. I may tweak it some more before it’s all over. For now though, I am sticking with it.

I will post some graphs soon.

Kindle Content Trumps eReader April 30th, 2009
Patrick Stein

Until the most recent releases of eReader, content was a close call between the Kindle app and eReader on the iPhone. Now, eReader dropped the ball, and Kindle scored on them.

What eReader Botched

Until the most recent release, eReader let you add books to your bookshelf from places like ManyBooks.net that provide free books in eReader format. I am hoping it was just an oversight when they wove in their own site a bit tighter. We shall see. It is obvious from the app reviews that the customers are annoyed.

The Kindle Advantage

You can download the free books mentioned above for the Kindle as well. You just have to jump through some hoops and re-upload them to Amazon before you can get them onto the Kindle app.

In addition to this, the new content available on Amazon is newer and cheaper than the content on the eReader site. It has always seemed wrong to pay full paperback prices for a book at eReader. eBooks for the Kindle seem to run between half and two thirds of the paperback prices.

Where To Go From Here

At the moment, I am stuck using both apps. I bought and got quite a few books in my eReader bookshelf, and it’s a better app anyway. But, there’s some newer, cheaper content at Amazon. And, now, if I want Project Gutenberg books or other free books, I’m going to have jump through Amazon’s hoops.

*shrug*

Four Ways eReader Beats Kindle on the iPhone April 29th, 2009
Patrick Stein

Reading electronic books on the iPhone may not be as easy on the eyes as reading it on a dedicated eBook or reading a paper book. But, c’mon. The iPhone fits in your pocket. Plus, you were already going to be carrying it anyway, right? The iPhone and eBooks were made for each other.

Here’s what eReader (v2.0.2) has over the Kindle app (v1.0).

Options, options, options

ereader-optionsIn eReader, you can tweak your font, your font size, your line spacing, your margins, and your justification. On the Kindle app, you can pick your font size, but you are stuck with their font, their line spacing, their margins, and their justification. Even worse, the insets and tables in the text will only display completely when you use the Kindle app’s smallest font size.

In eReader, you can lock the display in Portrait mode, Upside-down Portrait mode, Landscape mode with up on the left, or Landscape mode with up on the right. You can even let it track your orientation if you prefer. On the Kindle app, you’re in Portrait mode.

In eReader, you can choose to turn pages by swiping them horizontally, swiping them vertically, tapping left or right, or tapping high or low. In the Kindle app, you have to swipe horizontally to change pages. eReader’s tapping modes let you read easily with one hand. Trying to swipe pages with the thumb of the hand holding the iPhone is fraught with misfires—accidentally not turning the page, accidentally turning back a page instead of forward, dropping the phone, etc.

eReader also lets you choose your color scheme. The Kindle app locks you into black text on a white background. Actually, I feel like I once found an option to switch the Kindle app to white text on a black background, but I can’t find it today.

Searches

What’s the biggest advantage of eBooks over paper? They are electronic. Because they are electronic, you can fit two thousand of them in your pocket, you don’t have to kill any trees, and you can search for text in them. The Kindle app forgot about that last bit. I am sure there are indexes in the print versions of the Kindle books that I own. But, in the Kindle versions, there is no index and no way to search. The only navigation is page at a time or table of contents.

I have the King James Bible and the Constitution of the United States in eReader. Because of that, I can always zoom right to the spot someone’s talking about. When I’m trying to refer to something in one of the Kindle books, I end up guessing by chapter title, swiping, swiping, swiping, and scanning with my eyes to find the data I seek. Seriously?

Dictionaries

I am reading along, reading along, reading along. All of the sudden, in the middle of the text, there it is: soliped. What is that? How did it get into this book?

In eReader, I tap on the word and it looks it up in my Pocket Oxford English Dictionary. The Kindle app makes me fumble for a paper dictionary, go search an online dictionary, or pretend I never saw the word.

Thumbed Bookshelf

ereader-bookshelfI have 42 eBooks in eReader. I have 3 eBooks in the Kindle app. In either app, I can sort by title or author. eReader adds separators in the display to mark off each starting letter. With that, I can find one of my 42 eReader titles as easily as I can find one of my 3 Kindle selections.

Hopefully the next version of the Kindle app will address some of these things.

 

Can We Refluidize CSS? April 28th, 2009
Patrick Stein

I mentioned earlier that CSS makes each object responsible for how it flows in the layout rather than making the container responsible. So, what can be done?

Take a look at this very site. All of the widgets on the left are floating over there. If you narrow your browser window (or bump up your text size), they will eventually fall into a single column. Narrow further and they will fall below this text.

That’s 80% of what I wanted out them. There are weird artifacts though caused by the different widget sizes. To accomplish this, I not only had to float each widget, but I had to float the main column as well.

What I really wanted was a container that would flow things for me instead making me flow each item (poorly). It seems I should be able to specify a container that adds objects top-to-bottom-then-left-to-right keeping the minimum needed height for any addition. So, in adding a <div> to this container it would:

  • insert it below the last inserted item if it need not lengthen itself to do so
  • otherwise, insert it to the right of the last items as high up as it will go if it need not widen itself to do so
  • otherwise, lengthen itself enough to place it below the rest of the contents

It may be as simple as preferred-width and -height attributes on the container, a flow-order: top-bottom-left-right;, and judicious use of maximum-width and -height.

Nobody’s Perfect

This wouldn’t solve every fluidity problem one might like to tackle. But, it would make many of them much simpler. No one would ever switch apartments if each piece of furniture got to say where it belongs on the moving truck.

Updates In Email

Email:

l