[r4]: / trunk / RetroGames / Pong / GameObjects / FB_Board_1 / COLLIDE / svnobj  Maximize  Restore  History

Download this file

20 lines (18 with data), 2.5 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
/// A board is static in x direction
/// The physics of pong is a bit special. So, while
/// reflecting the direction, it adds it's own impulse
/// to simulate some kind of spinning 
METHOD COLLIDE : BOOL
VAR_INPUT
	posIn : POSITION;
	vecIn : VECTOR;
END_VAR
VAR_OUTPUT
vecOut := vecIn;
	(posIn.iYPos >= posOld.iYPos -5) AND (posIn.iYPos <= posOld.iYPos + iHeight +5) THEN 
	vecOut.rVX := vecOut.rVX * -1;
	
	IF (vecOld.rVY <> 0) THEN
		vecOut.rVY := vecOld.rVY; 
	END_IF
	COLLIDE := TRUE;
END_IF