Questions tagged [breakout]

Tag for questions related to pset3, Breakout.

Filter by
Sorted by
Tagged with
6
votes
2answers
416 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 ...
5
votes
1answer
687 views

Is something wrong with getType(object)?

For pset4, in this code(in main, to check collision of ball and anything else): GObject object = detectCollision(window, ball); if (strcmp(getType(object), "GRect") == 0) { ...
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
672 views

Segmentation fault when trying to detect collisions in breakout

This line of code results in the error Segmentation Fault (Core dumped): collision = detectCollision(window, ball); if (strcmp(getType(collision), "GRect") == 0) { // TODO } What is ...
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, ...
3
votes
1answer
448 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 ...
2
votes
3answers
820 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 ...
2
votes
2answers
480 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? // ...
2
votes
1answer
815 views

Segmentation fault (core dumped) in the updateScoreboard function of pset4

I am having a problem with the updateScoreboard function in pset4. Whenever I call it I get a Segmentation fault (core dumped) error. My code is the following: if(object!=NULL && strcmp(...
2
votes
1answer
199 views

Segmentation fault testing for detectCollision returning NULL

I am trying to detect collisions between the ball and paddle or bricks. The difficulty for me is trying to determine if detectCollision is returning NULL. An excerpt from my code is shown below. This ...
2
votes
2answers
272 views

Breakout slows down just before finishing the game

Just before finishing a game of Breakout, the game start to move very slow and the paddle behaves weirdly. The game works fine for the first 40 bricks. What causes this? This is my code: GObject ...
2
votes
1answer
150 views

Bricks don't appear on screen

I initialized the first bricks position, then made two for loops inside of which I created a GRect object, set its color and added it to the window and also adjusted the brick's location for each row ...
2
votes
1answer
164 views

Why use `pause` function if `velocity` could be defined to a smaller value in the first place?

In bounce.c in Problem set 3, why is pause(10) used to slow down the circle when circle's velocity could be defined to a smaller value in the first place? I tried velocity = 0.005 and it seems to be ...
1
vote
1answer
712 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 ...
1
vote
3answers
1k views

Coloring the bricks in breakout

I used the following formula to create the colors for the different rows in breakout. But I find myself repeating the if function 5 times to get 5 different colors. I was wondering if there is a more ...
1
vote
1answer
106 views

Breakout program freezes when i make it wait for click to start.

I have later done with waitForClick() function but want to know whats the problem with the below code. bool start = true; while (lives > 0 && bricks > 0) { // Creates a mouse ...
1
vote
1answer
331 views

Breakout - bounce off brick- why do I need to check for object == NULL?

When using detectCollision to get the ball to bounce off the paddle, I just need to check if detectCollison returns the object "paddle" and if so, reverse the movement. But for the brick, I have to ...
1
vote
2answers
128 views

pset4 Lives Unintentional infinite loop

I'm implementing part 9 of 10 in pset 4 when I found a flaw in my code. First, pseudo-code: If ball is below the screen remove ball Refer to initBall function to create new ball which is centered. ...
1
vote
1answer
108 views

pset3 - Breakout - Can't start again after loosing my first live

All my program work well till I lost my first ball. After that, I'm not able to start with an other one. I thought I've controlled that with my second while loop. There the first part of my code in ...
1
vote
1answer
82 views

What fonts are available using Stanford Portable Library?

Specifically for GLabels. I would just like to rub it in with some dark, bold text if the player loses. On the other hand, something celebratory would be in order for breaking out all bricks, right?
1
vote
1answer
315 views

Getting Many Breakout Errors

Here are some all the bugs im getting form breakout.c /usr/include/stdlib.h:376:13: note: 'srand' declared here extern void srand (unsigned int __seed) __THROW; ^ breakout.c:23:13: error: ...
1
vote
1answer
197 views

How come we can use objects in a structured programming language like C?

I noticed that data types like GWindow, GOval, etc. are actually classes and we are declaring objects using those eg. GWindow window; and GOval circle;. Here window and circle are objects right? How ...
1
vote
2answers
647 views

Ball moving problems

I’m having some problem with the movement and collisions of the ball. I’ve searched for answers here but I still cannot figure out how to do what they suggested. The ball gets stuck in the paddle ...
1
vote
1answer
189 views

Why won't my identical copy of breakout.c compile?

I'm approaching pset4 (Breakout) by making an exact copy of breakout.c, which I've named breakout1.c. This should let me insert my code into the copy and still have the original breakout.c to refer ...
1
vote
1answer
312 views

Cannot get both paddle moving and ball bouncing at the same time (pset4)

I can get either the paddle following the cursor, or the ball bouncing, but not both at the same time. I've succeeded in making the ball bounce code loop within the while loop, by enclosing it in an ...
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 ...
1
vote
1answer
104 views

Segmentation Fault w/paddle movement (already changed initPaddle return)

I instatiated the bricks and paddle without any trouble, but when I try to have the paddle move with the mouse I get a segmentation fault. And this error doesn't occur until I move my mouse over the ...
1
vote
1answer
466 views

Strange interactions between paddle and ball in Breakout

First of all, here is my code for Breakout (pset3): // // breakout.c // // Computer Science 50 // Problem Set 3 // // standard libraries #define _XOPEN_SOURCE #include <stdio.h> #include <...
1
vote
1answer
86 views

Compiling pset3 breakout on my native ubuntu

I want to run the breakout game on my native ubuntu. I tried installing the SPL files and making certain changes to the Makefile. But it's still not compiling. Has anyone else got it to work?
1
vote
1answer
152 views

Why function initBricks is void type if initBall is GOval?

i was wondering why those functions are different types ? Especially why initBricks is void? // prototypes void initBricks(GWindow window); GOval initBall(GWindow window); GRect initPaddle(GWindow ...
1
vote
1answer
530 views

Program failing to compile. Please see code below. Not a p-set problem [duplicate]

I have spent days trying to understand what went wrong, but there is no answer to this on Stack Exchange or the web. The problem below comes from the first video walk-through in week 4 of CS50x, from ...
1
vote
2answers
184 views

Why my new ball is not moving?

while (lives > 0 && bricks > 0) { move (ball,velocity,velocity_y); if(getY(ball) > 555) { lives -= 1; remove(window,ball); pause(2000); ...
1
vote
1answer
98 views

Is there a method to 'pack' The Breakout?

I'm wondering if there any method available to 'pack' or 'construct' Breakout game to an .exe or any installation file. A method that will include all of the header files and libraries. I want to show ...
1
vote
1answer
161 views

Paddle is lagging and how to use drand48?

Well when I coded for the creation of paddle and the movement of the paddle in initpaddle(), it was moving fine but now after step 6 of the problem set. With the ball too moving the paddle is lagging, ...
1
vote
0answers
96 views

Cannot find lcs : Error when compiling window.c in breakout

I am having issue on using spl library in ubuntu. When I try to compile window.c using make as given in the instructions I am always getting the same error(in pic) even though the spl/include folder ...
1
vote
1answer
152 views

Breakout (with no changes) won't compile

I always get the following messsage when I try to compile breakout in PSET3. jharvard@appliance (~/Dropbox/CS50/pset3/pset3/breakout): make breakout clang -ggdb3 -O0 -std=c99 -Wall -Werror -Wno-...
1
vote
1answer
113 views

Why does setLabel() freeze the program randomly?

I have a decent implementation of the Breakout program that normally runs perfectly all the way through. I have noticed, however, that occasionally the program will freeze. After a joint effort of ...
1
vote
2answers
540 views

Best solution to move the ball in Breakout?

What's the best solution for providing proper parameters (x,y) for move() function? "Move() function" we use it to move the ball in the Breakout game.
1
vote
1answer
334 views

CS50 pset 3 breakout segmentation fault when lives --;

I get a segmentation fault after x times i "die" (it varies) and if i decrement the lives each time the ball hits the bottom i get a segmentation fault after 1 time. It's very anoying and i can't find ...
1
vote
0answers
70 views

Ball mysteriously passes through one specific block, but successfully collides with all others, when block height is less than 11 [closed]

This problem is fixed but enlarging the block height from 10 to 11, however I'm wondering why it happened in the first place One of the GRects (or in my case, I used GRoundRect), or "block", doesn't ...
1
vote
1answer
111 views

what's the error in the below function

I tried to make my own function in pset4-breakout to move the paddle but when i run and take my mouse to the output window I always get segmentation fault. I have tried gdb also but still i'm not able ...
1
vote
2answers
69 views

what does “Unexpected error: decodeError: Illegal color value” mean?

I just finished the code for breakout.c and I received no errors when I typed in "make breakout". However when I typed in ./breakout I received a whole lot of errors saying that there was an ...
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 ...
0
votes
1answer
355 views

Why is this code unable to bounce the ball

In my code for breakout, the ball is unable to bounce up and down, though the same code works in bounce.c for bouncing the ball vertically! Here's the main part meant for moving the ball: while (...
0
votes
1answer
111 views

why doesn't getColor work?

I have almost all of my PSET3 breakout program complete. I want to add different point values based on the color of the bricks. I have each row colored differently and now when trying to determine ...
0
votes
1answer
251 views

How to use strcmp correctly in PSET4? (Using it cause my whole program to stop)

I am faced with a very strange problem on PSET 4 (Breakout.c)... The following is my code (main portion). All is well - the ball moves and bounces off the paddle and off the walls (not yet the bricks) ...
0
votes
2answers
195 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
2answers
93 views

Pset3 Breakout: Question on variable scope in while loop

I'm working through pset3 and noticed that when I declare my ball's velocities outside the while loop, my collisions against the wall's edges work, i.e. the ball bounces away, but when the velocities ...
0
votes
1answer
83 views

Breakout ScoreBoard

int label_x = (WIDTH / 2); int label_y = (HEIGHT / 2); GLabel label = newGLabel("0"); add(window, label); setLocation(label, label_x, label_y ); return label; In this way of initilizing scoreboard ,...
0
votes
3answers
89 views

Pset3 - Multiple nested if statements

I have been working on the pset3 Breakout problem, and find myself using many nested IF statements, specifically for the creation of the blocks, and the assigning of points based on where the block is ...