Game Studio: A Logical View

So we're back to Game Studio again this week.
And we're going to look at the beginnings of everyone's favorite (to program...that is) game - a simple Pong-style game.
By the end of the next few weeks we'll have a full game playable with this, and we'll delve into everything but for now, a first look at getting the logic in place.

So first, a look:

Nothing special there, other than a bit of re-design of the UI of Game Studio. It now operates primarily in landscape mode.
Other than that, it's just what you'd expect...4 walls, 2 paddles, and a ball. What's special here about Game that with just a tiny bit of wiring together, and without really having to write any complicated code, we're going to make this whole thing work.

In the bottom right, the inspector showing properties for the currently selected object - in this case the P1Paddle, which is of the LeftPaddle class.

Let's look a bit deeper at that LeftPaddle class. We're starting off with a VERY basic implementation here...
simple screenshot

This is everything that GameStudio knows about "LeftPaddle" objects. And the 4 basic events that can be handled by objects in GameStudio:

  • init: Fired off when the game is (re)started
  • tick: Fired off once per frame. GameStudio runs everything at a fixed 30fps currently
  • collision: When 2 objects collide - in the next post we'll be adding to this
  • input: When the player touches (or moves, or stops touching) on the screen

Currently this is very simple, with only a couple of simple behaviors.

First, when init is called, it then proceeds to call Set Scale. This is because all of the images in this pong game share a single 2x2 texture, which is then scaled to the appropriate size. I'm an engineer, not an artist.

Then, when input is called, we have 2 additional nodes here. First, the y output of the event is wired up to a red node (a variable node) called p1y. This saves that value out and allows us to use it later. Then, it continues on to call Set Position, using that same p1y variable to update the Y position of our sprite.

Just like that, tapping on the screen causes our paddle to move around (but ONLY in the Y axis). Now this is VERY simple movement. The paddle will just jump to wherever we touch, but the goal here was to show just how simply you can string together simple ideas (like get this value, or set this position) and have things happen. We'll be moving on to more complex behaviors VERY soon.

Hopefully the concept of node-based behavior trees (the "fancy" words for what we have here) is starting to make sense, and next time we'll get that ball moving and bouncing off walls!