Questions tagged [pset4]

The standard edition of Problem Set 4 will move beyond C programming language basics, testing your knowledge of pointers, memory management, file i/o and structs.

Filter by
Sorted by
Tagged with
0
votes
1answer
232 views

Should I implement initBricks in pset4 using drawRect or GRect?

Would it be best to initiate the bricks by: using GRect bricks = newGRect(x,y,width,height) (and would bricks be the best variable name?) or, by drawing the rectangles using drawRect(window, x,y,...
3
votes
1answer
449 views

Bricks are not available to the detectCollision function

My detectCollision function detects collisions between ball and paddle, but not between ball and bricks. Bricks 'exist' in 'window' but they don't exist in main(). I thought detectCollision might ...
0
votes
2answers
217 views

Ball appears but doesn't move

I have looked at all the other questions & answers but can't seem to find one that applies to me. I used waitForClick() and then the next line is making the ball appear. The ball shows but nothing ...
0
votes
1answer
208 views

Pset4 and bouncing ball

On Pset4 "bounce" walkthrough, I learnt how the ball bounces horizontally. Can anyone please help me in bouncing the ball at angles after it touches the window edges and paddle?
0
votes
2answers
197 views

in pset4 only 1 row of bricks appear even with nested loop

This is what I've done so far for pset 4 (I've started on main, initPaddle & initBricks) I have trouble printing out the bricks on the screen from the 2nd row onwards; the window doesn't show ...
0
votes
1answer
504 views

PSET4: error: Found "result" when expecting ","

When the updateScoreboard function is called, it throws the above error. The function (all pre-written code) is as follows: void updateScoreboard(GWindow window, GLabel label, int points) { // ...
0
votes
1answer
401 views

pset4 ball won't move on click?

I'm having some trouble getting the ball to move when the user clicks at the start of the game. I have the code below positioned in main, right after everything is instantiated, and before the while (...
0
votes
1answer
201 views

Why Does the Ball Disappear After Calling move()?

Code runs perfectly when the initialization functions are called. I get the bricks, the ball and the paddle which moves with mouse. However, when program calls move(ball, velocity, vertical); where ...
4
votes
4answers
1k views

Running breakout on Mac OS X

There's a similar question about running breakout on Linux variants: Can't run Breakout outside of appliance My question is specifically about compiling breakout (and hence SPL) on Mac OS X. So ...
3
votes
2answers
504 views

Bricks aren't disappearing when hit with the ball

I wrote the following code (within the while loop) but my bricks aren't disappearing. My ball just hits the bricks and bounces off. What am I missing here? GObject object = detectCollision(window, ...
0
votes
4answers
699 views

How to make ball initially go at random angle?

I don't want to have my ball go at a random velocity when it starts, just a random angle with respect to x. The specs say to use drand48, which I tried, but that makes the ball go really slowly or ...
0
votes
1answer
633 views

Pset4 error: invalid operands to binary expression ('double' and 'double (*)(void)')

The following error occurs in the lines where the velocity of the ball is initialized/changed using the drand48 function: When velocity is initialized : if(getEventType(event) == MOUSE_CLICKED) { ...
1
vote
2answers
674 views

Can't run Breakout outside of appliance

I have just finished implementing Breakout, and tried running it outside of the appliance in my Debian machine, but i get the following error, even though it's the same directory that's shared between ...
0
votes
1answer
357 views

Segmentation Fault in Pset4 when detecting is brick is hit

My code works well except when I insert the following code to detect if a brick is hit, I get a segmentation fault. Does anyone know why ? This is the short code inserted : // bounces if hits ...
1
vote
1answer
720 views

Why does the ball glide along the paddle whenever it touches its sides?

I have no idea why the ball will glide through the paddle when the side of the paddle is hit. It is not the same as normal case when the ball hits the top of the paddle and it bounces back. I have ...
0
votes
1answer
1k views

pset4 image resize properly but check50 says not correctly

:) resize.c and bmp.h exist :) resize.c compiles :) doesn't resize 1x1-pixel BMP when n is 1 :( resizes 1x1-pixel BMP to 2x2 correctly when n is 2 :( resizes 1x1-pixel BMP to 3x3 correctly when n is ...
2
votes
2answers
504 views

Why Do I Get a Segmentation Fault When Trying to Move the Paddle?

I am trying to get the paddle moving with the mouse but I keep getting the same error message : "Segmentation Fault (Core Dumped)". This is my function, which is very simple. Any suggestions? // ...
1
vote
1answer
108 views

Pset 4 Ending Game?

I got a problem, the game only ends after losing the 3 lives, but after destroying all bricks it doesnt... anybody know what is happening? I noticed that the condition was while(lives > 0 && ...
0
votes
1answer
279 views

How to Return a GRect From initPaddle()?

Just one quick question, what should I return in the InitPaddle function? I made to put it on screen without returning anything, but in the step to step tips ain the pset`s page says that I have to ...
0
votes
0answers
167 views

How to Fix "Found "result" when expecting ","`" Error? [duplicate]

Please help me! I am stuck at pset4. My code is correct, but in the middle of the game it is giving the error error: Found "result" when expecting "," How to fix this error?
7
votes
2answers
419 views

getType() causing a seg fault when called on object as returned by detectcollision?

This one is driving me nuts! Why would I get a seg fault when calling getType() on 'object' as returned by detectCollision()? gdb revels this is where the memory error is happening but as far as I can ...
1
vote
3answers
1k views

Can't run the staff implementation

i can't run the staff implementation for any problem set, i always get the same error, it's always something like : bash: ~cs50/pset4/breakout: No such file or directory
0
votes
2answers
195 views

Placing bricks precisely with initBricks (using floats and integers)

i'm trying to be very precise with the positioning of my bricks when using initBricks. however they are not placing exactly where they should be 9out by small fractions) and i'm pretty certain it is ...
0
votes
1answer
146 views

pset4 y m getting this error

if (strcmp(getType(object), "GRect") == 0) { if(object==rect) { if(velocity>0) { velocity=-velocity; } } else { removeGWindow(window,...
-5
votes
1answer
303 views

PSet4 (breakout ) ball is not moving :(

Ball is not bouncing :( while (lives > 0 && bricks > 0) { GRect rect = newGRect(162, 573, PWIDTH, PHEIGHT); // TODO add(window,rect); setFilled(rect,true); ...
0
votes
3answers
714 views

gevents.h File Not Found

When I compile this for pset4 #include "gevents.h" #include "gobjects.h" #include "gwindow.h" int main(void) { // do something } I get this error jharvard@appliance (~): clang -ggdb3 -Ispl/...
0
votes
1answer
474 views

pset 4 breakout ball hitting bricks

I am having trouble with hitting all my bricks. I'm done with all 10 steps in the pset but when I get to hitting the last 3 - 5 or so bricks, my ball doesn't have enough "randomness" to hit them. My ...
0
votes
3answers
319 views

initBricks as a 2d array of labelled bricks

i am trying to create a labelled 2d array of GRects called brick[i][j]. implementing the code below i am getting an error: breakout.c:112:23: error: variable-sized object may not be initialized ......
0
votes
2answers
517 views

How to Initialize Bricks in breakout?

starting pset4 but can't understand how to initialize bricks. Thnx in advance!
0
votes
2answers
87 views

Do we need to implement "God" mode for the standard edition of problem set 4?

I see in the staff's implemented solution for the standard edition of problem set 4 that "God" mode works, however I see that it is asked for only in the Hacker edition. Do we need to implement "God" ...
1
vote
2answers
342 views

PSET 4(breakout) : Paddle goes out of window

When i try code for moving paddle setting location x = getX(event) -getWidth(paddle)/2; but with this a part of my paddle goes out of window. What should i do ?
2
votes
3answers
831 views

Collision of ball with other objects

I don't understand what I actually have to do for the collision of ball with other objects. I am at the state where ball and paddle are just moving but collision is not yet defined. What should I do ...

1
31 32 33 34
35