Theology Through Music

Reading Time: 8 minutes

Singing-worship on Sunday morning is a difficult time for me to worship; I have a tendency to let my mind wander and not focus on the Object of our worship.

I used to blame it on seven-eleven songs,1 musical arrangements built for vocal acrobats, or skinny-jean worship leaders. As I’ve matured a little, I’ve realized that while these may be factors, the lion’s share of the blame rests on my own two shoulders. I’m not very good at this worship thing.

One way that I’m trying to combat this is by reflecting on the truth (or lack thereof in some unfortunate cases) of the lyrics that are being sung. As a sermon to myself as much as anything else, I want to take a moment to do this with some of our modern-day hymns.

Continue reading

  1. Songs with seven words sung eleven times. []

Speaking Truth in Love

Reading Time: 10 minutes

Lately our young adult group at church has been doing an in-depth study of the book of Ephesians, and I’ve been struck by a particular passage:

But speaking the truth in love, let us grow in every way into Him who is the head — Christ. From Him the whole body, fitted and knit together by every supporting ligament, promotes the growth of the body for building up itself in love by the proper working of each individual part. – Ephesians 4:15-16, HCSB

Throughout this book Paul has explained how God has richly blessed his people; how He has brought them back to life spiritually the same way He brought Jesus back to life physically. Even more than this, God had begun to heal the great racial divide between the Jewish and Gentile/Non-Jewish worlds (a divide comparable in some ways with our ethnic divides) by “creating one new humanity”1 where “there is no Jew or Greek, slave or free, male or female”-2 where all are brought together on level ground before Christ. God is growing and maturing the Church into an earthly extension of Jesus- acting as His metaphorical hands and feet in God’s plan to fix the universe we’ve broken.

The passage above is the conclusion to Paul’s first call to action- now that God’s plan has been revealed, we are to live our lives in a way that is worthy of this calling. I know the Church isn’t there yet- this past election has made it abundantly clear that she isn’t- but as a child matures into an adult, we as the Church must mature into Jesus-ness.

As we grow, we are expected to be “speaking the truth with love”- and as I’ve been meditating on that phrase, it has led me to some important places.

Continue reading

  1. Ephesians 3:15 []
  2. Galations 3:28 []

libGDX Jam Day 13: Physics I

Reading Time: 4 minutes

Back in the Jam!

In my last post, I mentioned that my computer had died- specifically my HDD was dying due to overheating. I did have a USB stick with Ubuntu installed on it, but it has very limited space and fun little quirks (like somehow undoing any customizations or installations I’ve made each time I reboot).

Good news is, in my now-copious spare time, I found a way to get Ubuntu installed onto a larger stick (and for real this time, not a “try it out” version which resets each time). It still has a bunch of crashes and quirks, but I was able to set up my development environment.

All that being said, on to the development!

Adding Physics

During my downtime I spent a lot of time studying entity systems. I like the concept, but the implementation is still a little fuzzy- most of the examples out there are for simple games you can finish in an hour-long presentation. Because I am foolish, I am not making a simple game. Fortunately I was able to garner enough tidbits from my research to figure out how Box2D (and other 3rd party libraries, for that matter) can be integrated with an entity system.

As you probably already know, one of the key principles of an entity or component/entity system is to store all our data into components, and all our logic into systems((N.B. There seems to be a gray area for getters and setters in components, but for the time being I decided not to mess with that.)). Thus, we would normally begin by breaking entities down into the data and systems they need. I’ve taken a first pass at it using the hierarchy below:

Iteration #1

  • “Player Ship” Entity
    • Physics System
      • Bounds Component
      • Player Controller Component
      • Transform Component
      • Movement Component
    • Graphics System
      • Bounds Component1
      • Label Component
      • Texture Component
      • Transform Component
  • “Asteroid” Entity
    • Physics System
      • Bounds Component
      • Transform Component
      • Movement Component
    • Graphics System
      • Bounds Component
      • Texture Component
      • Transform Component

Uh-oh, it looks like we have a problem. If you look at the systems listed for the “Player Ship” and the “Asteroid”, you’ll notice that the asteroids use fewer components than the player ship does. The physics of the player ship are influenced by the player’s input, whereas asteroids don’t care if the player is mashing keys. We can solve this problem by breaking the systems down into more atomic pieces like so:

Iteration #2

  • “Player Ship” Entity
    • Physics System
      • Bounds Component
      • Transform Component
      • Movement Component
    • Engine Control System (If you’ve got a better name, post in the comments below)
      • Player Controller Component
      • Velocity Component
    • Texture Drawing System
      • Bounds Component
      • Texture Component
      • Transform Component
    • Label Drawing System
      • Label Component
      • Transform Component

Now we can share two of the systems across the Asteroid and Player Ship entities, and our two new systems will likely be reused by other entities we come up with.

This leads us to our second problem- Box2D doesn’t give a rip about our components. It has a Body and Shape class which encapsulate bounds, transforms, and velocity. It doesn’t really decompose into the nice little components we have listed above. Best as I can figure, we have several options:

  1. Component: Create a Physics component which holds the physics information for Box2D.
  2. System: Hide the Box2D data structures inside the system.
  3. Hybrid: Create a “light-weight” physics component which contains ‘raw’ physics data, and then use the system method for the Box2D specific objects.
  4. DIY: We build our own physics system that uses the components we want.

Method #1 is the correctest-way, aside from building the physics system ourselves. However, whatever initializes the component/entity will have to have access to the Box2D world and need to know how our physics system works. Method #2 encapsulates all the logic in one place (making it easy to switch out physics systems later), but we’re going with Method #3 because it has the added bonus of giving us more control over which objects have physics (i.e. we can make non-collidable objects by omitting the Physics component).

Implementing Box2D

I wanted to get player input done today, but it turned out Box2D was a large effort on its own.

The first challenge I had was mapping everything out in Box2D. It’s really a Java wrapper around a C++ library, so its structure is a little odd. First, you create a Body Definition object, give it a shape, and then use it to generate the body. After that you create a Fixture Definition and use that to generate a Fixture, which gets added to the body.

I wonder if BodyDef and FixtureDef are some sort of optimization for if you need to generate a bunch of similar physics objects? I’ll need to do some more research into Box2D and see. I might need to pull some of this information into the Physics component after all.

The second issue I ran into was that Box2D “thinks” a little differently than the graphics classes- this is a problem, because I need the hit box to line up with the sprite!

One of the biggest differences was in dealing with position. Box2D likes to use the center of the body or fixture as its position. SpriteBatch likes to use the lower left corner. If you’ve worked with the Sprite class in the past, you may recall that it has setPosition() and setCenter() (lower left corner and center respectively). Box2D uses its Body.setPosition() like Sprite.setCenter().

The other gotcha that had me going for a while was that Box2D thinks in terms of radians, whereas SpriteBatch thinks in terms of degrees. Fortunately the MathUtils class has some helper constants to deal with the conversions.

Overall, I finally got it working, but it would’ve been a lot easier if libGDX had a consistent API. Heck, after today I’d love to code it, but I suspect a change that big would break a lot of code, so I don’t know when/if we’ll ever see that happen.

But at the end of the day, it appears to work, and the code can be found in the “physics-branch” branch until I can clean it up a bit.

Summary

So here’s what I got done these last few days:

  • Fixed a bug that was crashing the debugger.
  • Pulled the background rendering into its own system.
  • Created a Texture System
  • Created a Label System
  • Created the Physics System*
  • Created Entity Factory

*Still need to add player control and collision events.

Screenshot

*Whew*- That was a lot. Thoughts? Suggestions? Let me know below!

  1. This depiction shows “Bounds” multiple times, since multiple systems need to use it. However in reality, the entity will have one shared instance. []

libGDX Jam Day 6: It’s Dead, Jim

Reading Time: 1 minutes

The Project Peanutbutter dev log has been kind of quiet lately- namely because my laptop died.

The good news is that all the code is in GitHub, I was able to back up my hard files, I can afford a new laptop, and I have some access to the outside world via Ubuntu-on-a-stick and a Raspberry Pi. That’s actually a lot of good news!

The bad news is that my development environment won’t really fit on my Ubuntu-on-a-stick, I can’t get libGDX to work on the Raspberry Pi (even the stuff that does work takes minutes to compile/run), and the new laptop won’t be here for 3 weeks or so. I’m in, dare I say, a bit of a jam pickle. Unless I can find a way of writing/testing code without using libGDX (which is tricky at best), I’m not going to be able to do any development for a while.

In the meantime, I’m enjoying the holidays with my family, researching game design and programming theory (I’m working on a monster of an article on Entity Systems to process all I’m learning), and trying to figure a way around my current hardware limitations.

At any rate, have a great Christmas and a happy New Year if I don’t see you sooner!

Debugger Screenshot

libGDX Jam Day 3: Slow ‘n Steady

Reading Time: 3 minutes

Check out the latest commit!

I didn’t get as far as I would’ve liked these last two days, but I still got a few things done:

I made a debugger

One of the complications that comes with this sort of space game is that unlike classic Asteroids, we’re going to have a larger game world that can’t fit on the screen- our camera is going to need to move and follow the player as they fly about. Space is big, and it can be hard to find or track things. Thus, I decided to create a small debugging framework.

The code is all here on GitHub so I won’t go into all the details, but suffice to say I decided to borrow a page out of Mojang’s notebook and create an in-game debugger:

Debugger Screenshot

If you press F5, the debugger will toggle on and display green grid lines for the world, blue text for the camera, and (in the near future) red lines for collidable objects. I also created the debugger as an Ashley system, so removing the debugger from the final project just means removing one line of code!

I know it doesn’t do very much, but it was really helpful in debugging the endless star tiling, and I’m sure it will evolve as the jam continues.

I added tiling

To be honest, I thought this would be one of the easier parts, but it turns out to be an interesting little programming problem. You see, normally we would have a fixed number of tiles, and then just render them using a for-loop. However, since the player will be able to fly in any direction for as long as they like, we run into a problem since we can’t render infinite tiles.

Instead we have to only try and render the tiles we know will be seen by the camera. But how do we know which tiles those are?

Endless Tiling

Essentially we need to imagine the world as if it was grid paper, and the squares we want to fill are the ones that overlap with the camera. We do this by “rounding down” the camera’s position to the next lowest grid, and then drawing tiles until we would draw one outside the camera completely. The algorithm is below:

<code>
float cameraLeft = camera.position.x - camera.viewportWidth / 2f;
float cameraRight = camera.position.x + camera.viewportWidth / 2f;
float cameraTop = camera.position.y + camera.viewportHeight / 2f;
float cameraBottom = camera.position.y - camera.viewportHeight / 2f;</code>

float width = background.getWidth();
float height = background.getHeight();

batch.begin();
for(float column = (float) Math.floor(cameraLeft / width) * width; column &lt; cameraRight; column += width) {
    for(float row = (float) Math.floor(cameraBottom / height) * height; row &lt; cameraTop; row += height) {
        batch.draw(background, column, row);
    }
}
batch.end();

Admittedly it isn’t that pretty, and is kind of expensive, but it works until we actually need to optimize it.

Where to next?

The next thing to do (which I really hoped I’d have today) is the actual player ship flying around. Normally this would be easy, but I’m trying to blend three different libraries together:

  1. Ashley: This library lets one create entity-component type systems. The idea is that all of your game objects become bundles of “components” which let them do different things (act as a gravity well, have health, get rendered, etc.). Essentially we create a bunch of different parts which can be snapped on to any entity we want like Lego bricks.
  2. Scene2D: Scene2D provides a graph which is very useful in tracking parent/child relationships. For example, we may want to have engines or shields or lasers or turrets which are components of our ship. Scene2D will update their position and rotation relative to the position of their parent.
  3. Box2D: Box2D provides physics (which are a real pain to do from scratch). This will be very useful for detecting collisions and acting accordingly. For example, we’ll want to know when ships collide with asteroids.

One way or another I plan to get these three to play together tomorrow so we can move on to more of the fun stuff.

Thoughts? Suggestions? Snarky comments? Let me know below! Also make sure to check out the other libGDX Jam Dev logs here!

Give a Mouse a Cookie…

Reading Time: 3 minutes

This last year at work at that-corporation-which-shall-not-be-named has been one of the most challenging ones yet. Without going in to too many details, I’ve been helping lead architecture on a multi-million dollar project with over 100 teams involved in some way. It’s been nuts. An average day is 7-8 straight hours of virtual meetings followed by updating and writing documentation when the east coast (darn them and their 6 AM calls) goes home. Lunch, breaks, training, and the like have been put on indefinite hold for nearly a year.

Don’t get me wrong, I have no problem with working hard. There are always going to be periods of time (like the end of a release) where we just need to do what we need to do to get the project out the door on time and in good shape. Heck, if it wasn’t for my boss holding me back I would probably work even more.

However, this only works if those periods of time are temporary- things have to “go back to normal” at some point. It’s like a quest- in “The Hobbit,” Bilbo had to work really hard for a time, then was rewarded, then went back to normal until his next adventure.

What I have experienced has been the opposite- instead of hard work being rewarded with an eventual reprieve, it has been rewarded with more work. The extra effort becomes the expected effort. Things just escalate until someone breaks.

In my project, folks have started realizing that the extra effort our team put in is something that we should be doing all the time (and they’re right; what we’re doing is awesome and helpful). The problem is that the techniques and processes we’ve been implementing are being taken even further, and the amount of work we’re being asked to do is multiplying. We need more people (of course we have been needing more people pretty much the entire time I’ve worked here).

So what am I to do? I want to do a good job, I want to be helpful, and I won’t want to be a whiner (contrary to what it might seem in this post). However, I also have a fixed set of resources to work with.

First, I’m going to set some boundaries. No more 5 AM calls, no more new projects, no more staying at the office until 7 PM. Naturally there will be exceptions, and I’ll be flexible, but I have to reverse a few of the new norms I set. I’m not trying to slack off, not trying to be difficult, but if I burn myself out or take on more than I can physically do, none of it is going to get done and nobody is going to be happy.

Second, I’m investing in “Smart Time.” One of our SVPs said something this year which stuck with me- “Working really really hard just isn’t enough any more … you’re expected to learn and keep up [outside of the office].” At first that sounded incredibly unfair- weren’t VPs like him responsible for saddling us with so much work we couldn’t take time for training in the first place? But later I realized he was referring to this concept of balancing short term necessities with long term investments.

I’m going to take a note from Stephen Covey’s classic “7 Habits of Highly Effective People” and make sure I purposefully set aside time to make long-term investments. Do I have a weekly task which takes an hour? I’ll set aside two hours to automate it. Is there an area of the architecture which has been hurting? I will set up a small group to make sure we have a long-term plan in place to fix the design.

Third, I’m going to train my coworkers, not enable them. I truly want to be helpful. I consider that one of my few virtues. I also want to do things my way. That’s probably one of my many vices. The combination of these two leads me to say “Let me help you with that” or “Sure, I can just do that for you real quick” more often than I should. It hurts me because I take on more work than I can handle, and it hurts my coworkers because they don’t reap the benefit of learning our new tools and processes.

One of the investments that I will need to make this coming year is to purposefully spend time providing documentation and training to my coworkers so that they are empowered to help themselves instead of depending on me for everything.

What do you guys think? Have you experienced this difficulty before? Is this the right way to respond? Let me know what you think in the comments section below.

Why do we post on Facebook?

Reading Time: 3 minutes

Earlier this evening I had the opportunity to lie back, close my eyes, and listen to some music. No videos, no distractions, just the music. As I lay there, it occurred to me that simply enjoying music (or art, for that matter) is not something that we do often.

The very next thought that popped into my head was “That almost sounds profound! I should post it on Facebook!” Then I realized that this was a rather odd compulsion- why did I feel the need to blast out every event in my life to my friends? I’m not yet that old, but I’m old enough to remember a time before Facebook, and I don’t recall life working quite this way.

The third thought was that my second thought had proven more profound than the first, so I decided I should write a blog post. This behavior is insidious.

Regardless, now that I’m here, I want to think a little about why we do what we do on Facebook. A while back, a friend posted a link to a very interesting article in Business Insider on keys to lasting relationships. One of those keys is the idea of “bidding” for your spouse’s attention, as described below:

For example, say that the husband is a bird enthusiast and notices a goldfinch fly across the yard. He might say to his wife, “Look at that beautiful bird outside!” He’s not just commenting on the bird here: he’s requesting a response from his wife — a sign of interest or support — hoping they’ll connect, however momentarily, over the bird.

The wife now has a choice. She can respond by either “turning toward” or “turning away” from her husband, as Gottman puts it. Though the bird-bid might seem minor and silly, it can actually reveal a lot about the health of the relationship. The husband thought the bird was important enough to bring it up in conversation and the question is whether his wife recognizes and respects that.

This article is very interesting to me because I see a form of this occurring outside of marital relationships.

I used to see this all the time when hanging out with my friends. We’d talk, play games, and have a good time. One thing however that I noticed is that we’d play this weird little social game of “one-upsmanship” in our conversation. For example, I would mention something new that I was excited about. My friend would acknowledge what I had said, but then change the subject to something new that he was excited about.

In Gottman’s terms, I had made a “bid” for attention- I had brought up something that I was excited about, and given my friend an opportunity to join in that excitement. Instead, they chose to offer their own “bid” and invite me to join in what excited them. Don’t get me wrong, I did this too, and I doubt there was anything malicious or intentional about it (we weren’t the most thoughtful bunch)- it was just a pattern I observed, and it was uncomfortable.

Perhaps if we both had been less selfish the relationship would have been deepened. C’est la vie. It now serves as a reminder for me to keep an eye on my own selfishness as well as an illustration of how these “bids” can be made amongst friends.

Now armed with this understanding of social “bidding”, or “bids for attention”, I think we can apply the same concept to Facebook. People such as you or I who post status updates are making bids for our friends’ attention in the form of comments or “likes.” I don’t think that this is necessarily a bad thing. Requesting (and reciprocating) attention is an important part of relationships.

But why seek attention on Facebook instead of in person? Surely the attention from someone you’re with is worth more than a count of how many people “liked” your bid- unless that’s the only way.

I don’t want to go into too much detail on this tonight, but recently I’ve woken up to the fact that much of my life has been and is still spent alone. I live alone, I work alone, many nights I relax alone. Back in college, aside from hanging out on Saturdays, most of my time was spent working or studying- alone. When I feel the need to cry out into the void of aloneness, Facebook offers the hope that someone might hear that cry.

I wonder if we Facebook so much because we’re lonely?

I wonder if that’s why some people write blogs?

The Philosopher’s Prayer

Reading Time: 3 minutes

While the word “Philosopher” may bring images of madmen and ivory-towered intellectuals to mind, the term originally meant “lover of wisdom.”1 I am not a professional “Philosopher” in the modern sense, but I do love wisdom, and the prayer later on in this post is an outpouring of that love.

Before I enter into writing this prayer, I feel it important to explain why I am doing this. Jesus said2 that we are not to pray in order to make ourselves look good, and while I am aware that I am proud and self-centered, it is not my intention to try and do that with this post. Instead, I hope to accomplish three things:

  1. First, as a thinker and lover of wisdom, I feel misunderstood in a culture which has become disillusioned with disingenuous thinking and philosophy. With this prayer I hope to in some small way demonstrate worship with the mind.
  2. Second, by publishing this prayer I hope to bring certain sins and wrongs into the light so that I and my fellow lovers of wisdom can see them and turn away from them by the grace of God.
  3. Third, I hope that this prayer will somehow elicit worship within the hearts of my fellow Philosophers, that ultimately this post would show how God is Good, and not myself.

Father, you are high in Heaven above, and I am down below on Earth. I pray, hope, and desire that as Your Kingdom comes that Your will would be done down here on Earth as it is in Heaven. I long for the day when Your name is held with honor and respect amongst all mankind- for You are the maker of all good things.

Father, in the beginning you created all things- including Wisdom- and for this I rejoice and recognize your greatness. As I read the wisdom You bestowed upon the saints of old, my spirit is delighted. As I read even the echos of truth in the philosophers’ writings, my heart rejoices. 

Yet, all the knowledge and wisdom of mankind does not even approach your foolishness- if indeed you have ever had such a thing.3 How then can it be compared to the true wisdom from the creator of wisdom? Even the thoughts of the pagans- those who did not know You, would be impossible without the gift of intellect and wisdom that You bestowed.

Yet I fear, Father, that this delight is not without taint. For what is sin but a twisting of what You have created good? But my perversion is this- that I have loved wisdom more than the Creator of wisdom.4 Father God, please forgive me for the times when I have taken the good things which you have created and set them up as little gods in my heart. Help me to repent of such idolatry.

This is not all. I confess that in my zeal for Wisdom I have neglected Love- sacrificing what was lesser in a vain attempt to display what I thought greater. In doing so I “puffed myself up” as you warned not to do, and in my pride chose to love myself instead of you and those you love.5 Help me to repent of such arrogance.

Finally, I confess that I have been at times complacent to let my mind be idled and entertained by lesser things- the plastic, disposable, temporal thoughts of this world, despite having experienced the joy and the marvel at the Greater Thoughts with which you have blessed mankind.6 In doing so I have forgone opportunities to appreciate and worship. Help me to repent of such sloth.

Father, you guide the hearts of Kings- surely you guide the hearts of lesser men and women. Please guide my heart to use whatever wisdom and knowledge you bless me with-
…to raise you up, and not myself…
…to edify others, and not myself…
…to seek your kingdom, and not my own.

Amen.

  1. See this article. []
  2. Matthew 6:5-7 []
  3. 1 Corinthians 2:19-20 []
  4. This thought isn’t entirely my own- it was prompted by something Mr. John Piper tweeted. []
  5. 1 Corinthians 8:1-3 []
  6. 1 Peter 1:13-14, Colossians 3:1-3 []

Of Pharisees and Tax Collectors

Reading Time: 2 minutes

From some of the stuff I’ve seen on Facebook recently, the parable of the Pharisee and the Tax Collector came to mind. To save you the time of looking it up, I’ve posted it below:

“Two men went up to the temple complex to pray, one a Pharisee and the other a tax collector. The Pharisee took his stand and was praying like this: ‘God, I thank You that I’m not like other people —greedy, unrighteous, adulterers, or even like this tax collector. I fast twice a week; I give a tenth of everything I get.’

“But the tax collector, standing far off, would not even raise his eyes to heaven but kept striking his chest and saying, ‘God, turn Your wrath from me—a sinner!’ I tell you, this one went down to his house justified rather than the other; because everyone who exalts himself will be humbled, but the one who humbles himself will be exalted.”

– Luke 18:10-14

The Pharisees were a religious sect within ancient Judaism. I think that they started out like a lot of us who would be called “fundamentalists” or “conservatives” today. As they read the Law and the Prophets they observed how God’s people were given over to the surrounding nations when they turned away from God. By bringing the people of Israel back into right relationship with God they probably hoped that God would send a savior to free them from the oppressive Romans.

There is absolutely nothing wrong with this. In fact, this is a very good thing! However, those who take the moral high ground are prone to lifting themselves up over others. In the case of the Pharisees, their pride inflated them to the point that when they met Jesus, God in the flesh, they had Him executed. I’m afraid that myself and some of my conservative/reformed brethren run the same risk.

The tax collectors were just the opposite. They were Jews who had sold out to the Romans by enforcing their taxes on the Israeli people. Not only were they traitors supporting the occupying power, but they were often dishonest- taking more than the Romans actually demanded. They were the lowest of the low- pond scum. I think of them as equivalent with those who sold out to the Nazis in World War II France.

Jesus’ parable was striking to His original audience because He points out how when representatives of these two groups comes before God, it was the scumbag who was made right with God instead of the holy man because he humbled himself.

So many of my generation have been so focused on fighting back against our ultra-conservative/Pharisaical past that we ourselves are adopting the very pride we hate. We walk around saying “Thank you for not making me like that hell-fire and brimstone preacher!” or “Thank you for not making me like that legalistic hypocrite.” or “Thank you for not making me like that guy on Fox News.” When we do this we essentially twist the parable so that instead of crying out to God for mercy, both sides are thanking Him that they are better than the other.

I probably haven’t earned the right, whether by age or friendship, to offer advice. But as someone who is having difficulty in this area himself, I would just caution you to check yourself if you ever start to despise someone as a religious hypocrite- you may have indeed just become one yourself.