Battle pong #2 -Book 1, Page 1, Chapter 1

Hello !

I spent some time on this tutorial, playing (or messing up…) with some options in order to understand the basics. Good thing is that the physic engine in Unity spares me the problem of computing the ball bounce direction.

Setting up some code conventions

On the other hand I start to understand how can I correctly architecture the project. I checked at some guidelines here. For now, I will try to apply the following rules concerning scripts :

  • Keep the Game Manager concept, it will be the controller of the GamePlay part
  • Separate UI and Game engine running code in order to make the code cleaner
  • Each Game Object will have its own script, I don’t feel comfortable with having one script manipulating other Game Objects.

 

Reshape the tutorial

So now the trick is to “adapt” the pong game into something with a gameplay that will look more like the desired game. For that I create a new prefab for coins that will increment the score on impact. When all the coins will be down then the round is won. Since one pictures worth a thousand words here’s the result:

currentstate

Yeah that’s the current state. Of course it will change over time (I can’t really keep the FTL background of course). It’s playable but it  is for 2 human players. So another challenge will be the AI here !

Wait ! The cores are waaaayyy to big. I just realized that I can control the sprite size directly via the Sprite Editor by changing the Pixel Per Unit size. I can try playing with the Game Object scale but I prefer to keep these values at 1 to avoid playing with multiple factors.

Then since we want more than one coin I wrote a script that generates multiple cores on each wall giving the following result.

state2

Ups…. I’ll change it and try to reduce the number of core next time. So I guess next step, is to reduce the number of coins and also have the coherent core behavior.

Anyway that’s all for today more progress to come later.

What I learnt ?

  • Unity physics engine is great !
  • The OnGUI functions seems nice but I am not really convinced, I will have to look for another way to display the UI… Also it doesn’t seem to scale to the screen
  • So… When you create a sprite on Unity you can set the Unit per pixel dimension so you can make it bigger/smaller instead of messing up with the scale.

 

Another step forward !

Battle pong #2 -Book 1, Page 1, Chapter 1

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s