Skip to content

Commit

Permalink
bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jcgraybill committed Oct 7, 2022
1 parent de468d4 commit 8ab3c4c
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions multipong.c
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,11 @@ void HandleMouseDown( EventRecord *eventPtr ) {
break;
case inDrag:
if ( gameOn ) EraseBall(); // hide the ball while player is dragging windows
DragWindow( window, eventPtr->where, &screenBits.bounds );
if ( GetWRefCon( window ) == kMultiPongWindow ) {
SelectWindow( window ) ;
} else {
DragWindow( window, eventPtr->where, &screenBits.bounds );
}
if ( gameOn ) {
DisplayBall();
DrawPlayfield( window );
Expand Down Expand Up @@ -563,7 +567,8 @@ void InitMenu( void ){
}

void InitOpponent( void ) {
gOpponentYPosition = Randomize(gWindows[ kMultiPongWindow ]->portRect.bottom);
gOpponentYPosition = Randomize(gWindows[ kMultiPongWindow ]->portRect.bottom / kGoalHeight);
gOpponentYPosition += gWindows[ kMultiPongWindow ]->portRect.bottom / (kGoalHeight * 2);
}

void InitShapes( void ) {
Expand Down Expand Up @@ -668,13 +673,15 @@ void MoveBall( void ) {
gVertical = -gVertical;
gBall.top += gVertical*2;
gBall.top -= 1;
DrawPlayfield( gWindows[ kBottomWindow ] );
}
break;
case kPlayerWindow:
if ( DetectCollision( &gShapes[ 5 ], gWindows[ kPlayerWindow ] ) ) {
gHorizontal = -gHorizontal;
gBall.left += gHorizontal*2;
gBall.left -= 1;
DrawPlayfield( gWindows[ kPlayerWindow ] );
}
break;
}
Expand Down Expand Up @@ -734,7 +741,7 @@ short Randomize(short range) {
void RandomRect (Rect *rectPtr) {
WindowPtr window;
window = gWindows[ kMultiPongWindow ];
rectPtr->left = Randomize(window->portRect.right / 2 - kBallSize ) + (window->portRect.right / 2);
rectPtr->left = Randomize(( window->portRect.right / 2) - ( kBallSize * 2) ) + (window->portRect.right / 2);
rectPtr->right = rectPtr->left + kBallSize;
rectPtr->top = Randomize(window->portRect.bottom - kBallSize );
rectPtr->bottom = rectPtr->top + kBallSize;
Expand Down Expand Up @@ -846,4 +853,4 @@ void WriteStrPound ( int which ) {
}
}

}
}

0 comments on commit 8ab3c4c

Please sign in to comment.