Vintage PONG

  • October 14, 2012
  • 254 Downloads
  • 1 Like
  • Blender 2.6x
  • Render: Blender Internal
  • Creator: squat_kromera
  • License: CC-BY
You must be logged in to download.

Description:

Minimum modeling, no textures. Just game bricks design. You may use your own models for rackets, ball, walls etc, or stay with the vintage 2D look.

Hit P to run game engine (mouse in 3D View) and G to (re)start the game.

Player 1:

Q - racket up

A - racket down

Player 2:

P - racket up

L - racket down

Common:

G - Go!

M - Toggle mode

Most of the game logic is located in ball object. Properties:

dirx - positive: ball goes right, negative: goes left

diry - positive: ball goes up, negative: goes down

state - 0: idle, 1: playing

randomizer - timer counting 0..3, to determine random start direction of the ball

Objects (ball and rackets) change their positions by Simple Motion actuators.

The only different is mode switching, which is achieved by Action actuator. Initially it was supposed to play action that moves the middle rackets back and forth to invisible layer, but it did not work in BGE. If anybody knows how to do it please let us know!

We ended up making the guys invisible and moving them below the table, as the invisibility alone did not prevent collisions. See middle rackets logic for details. As for their property "racket" - the name itself is used for collision detection in ball logic. The property's value is used to determine visibility. It gets frame number of action "appear.action".

Collisions with vertical walls send messages to score.text.left or score.text.right objects, which keep and display the scores. We would be better off using old way of displaying texts in BGE, based on special texture with font painted on it. It could be designed as the vintage "brick" numbers. But we found it too cumbersome comparing to the new way, based on special Text property of the text object. A research of available tutorials shows that it may not be widely known, so you may want to take a closer look.

To avoid ball going through the horizontal walls when it hits the racket and the wall at the same time, the collision.wall.top and collision.wall.bottom sensors have true level triggering enabled. If anybody manages to shoot the ball out anyway, please let us know. We've spent considerable amount of time to deal with the ball going out.

Have a fun!

Squat Kromera

Comments: