Hot answers tagged

4

detectCollision assumes that the width of your ball is RADIUS*2. You have initialized your ball with a width of RADIUS. So detectCollision will return a collision before the ball hits the paddle.


1

GRect initPaddle(GWindow window) your returning a newGRect, does that even compile. You should return the paddle from the line with GRect paddle = newGRect((getWidth(window) - PWT)/2 , PY, PWT, PHT);


1

After a bit of playing with code, it turns out that the problem is caused by getGObjectAt. It doesn't return a pointer to your paddle even though it's in the specified location. Rather, it returns NULL. Below is a short program that verifies that #include <stdio.h> #include <math.h> #include "gwindow.h" #include "gobjects.h" int main(void) { ...


1

One thing that had me for a bit was my functions for instantiating the paddle and the ball. since we have to program movement inside of main we want ball and paddle exist inside of that function. make sure your initPaddle and initBall RETURN paddle and ball respectively. That might help with some of the issues you are having with movement.


1

Try to change the == in the object detection section with either >= or <=


Only top voted, non community-wiki answers of a minimum length are eligible