1

When I compile my program, it says that "gevents" file is not found?

Whats wrong?

#include "gevents.h"
#include "gobjects.h"
#include "gwindow.h"

#define HEIGHT6 00
#define WIDTH 400
#define Rows 5
#define Cols 10
#define Radius 10
#define Lives 3

void intBricks(GWindow window);
GOval initBall(GWindow window);
GRect initPaddle(GWindow window):
GLabel initScoreboard(GWindow window);
void updateScoreboard(GWindow window, GLabel label, int points);
GObject detectCollision(GWindow window, GOval ball);
double x_velocity;
double y_velocity;

int main(void)
{
    srand48(time(NULL));

    GWindow window = newGwindow(WIDTH, HEIGHT);

    intBricks(window);

    GOval= initBall(window);

    GLabel label = intScoreboard(window):

    int bricks = Cols*Rows;

    int lives = Lives;

    int points = 0

    waitForClick();

    x_velocity = 2;
    y_velocity = 4;

    while(Lives > 0 && bricks > 0)
    {
        updateScoreboard(window, label, points);

        move(ball, x_velocity, y_velocity);

        pause(10);

        GEvent event = GetNextEvent(MOUSE_EVENT);

        if (event != NULL)
        {
            if (getEventType(event) == MOUSE_MOVED)
            {
                // ensure paddle follows top cursor
                double x = getX(event) - getWidth(paddle) / 2;
                double y = 500;
                setLocation(paddle, x, y);
            }
        }


        GObject object = detectCollision(window, ball);

        if (object != NULL)
        {
            if (object == paddle)
            {
                y_velocity = -y_velocity;
            }

            else if (strcmp(getType(object), "GRect") == 0)
            {
                removeGWindow(window, object);
                y_velocity = -y_velocity;
                points++;
                bricks--;                
            }
        }

        if (getX(ball) + getWidth(ball) >= getWidth(window))
        {
            x_velocity = -x_velocity;
        }

        if (getX(ball) <= 0)
        {
            x_velocity = -x_velocity;
        }

        if (getY(ball) <= 0)
        {
            y_velocity = -y_velocity;
        }

        if (getY(ball) + getHeight(ball) >= getHeight(window))
        {
            lives--;
            setLocation(ball, 190, 200);
            setLocation(paddle, 160, 500);
            waitForClick();
        }

    }

    if (bricks > 0)
    {
        GLabel game_over = newGLabel("YOU LOSE!");
        setFont(game_over, "SansSerif-70");
        setColor(game_over, "RED");
        add(window, game_over);
        setLocation(game_over, 15, 300);
    }
    else
    {
        GLabel game_over = newGLabel("YOU WIN!");
        setFont(game_over, "SansSerif-70");
        setColor(game_over, "GREEN");
        add(window, game_over);
        setLocation(game_over, 15, 300);
    }

    waitForClick();

    closeGWindow(window);
    return 0;
}

void initBricks(GWindow window)
{

    int brick_y = 50; 
    int row_space = 20; 

    for (int i = 0; i < ROWS; i++) 
    {
        int brick_x = 2; 
        for (int j = 0; j < COLS; j++) /
        {
            GRect brick = newGRect(brick_x + 5, brick_y, 35, 10);

            if (i == 0)
            {
                setColor(brick, "PURPLE");
            }
            if (i == 1)
            {
                setColor(brick, "BLUE");
            }
            if (i == 2)
            {
                setColor(brick, "CYAN");
            }
            if (i == 3)
            {
                setColor(brick, "GREEN");
            }
            if (i == 4)
            {
                setColor(brick, "YELLOW"); 
            }

            setFilled(brick, true);
            add(window, brick);
            brick_x = brick_x + 39; 
        }
        brick_y = brick_y + 15;
    }
}

GOval initBall(GWindow window)
{
    GOval ball = newGOval(200 - 10, 200, 20, 20); 
    setColor(ball, "BLACK");
    setFilled(ball, true);
    add(window, ball);
    return ball;
}

GRect initPaddle(GWindow window)
{
    GRect paddle = newGRect(200 - 35, 500, 70, 10);
    setColor(paddle, "7F00FF"); //purple
    setFilled(paddle, true);
    add(window, paddle);
    return paddle;
}

GLabel initScoreboard(GWindow window)
{
    GLabel label = newGLabel(" ");
    setFont(label, "SansSerif-50");
    setColor(label, "C0C0C0");
    add(window, label);
    setLocation(label, 185, 300);
    return label;
}

void updateScoreboard(GWindow window, GLabel label, int points)
{
    char s[12];
    sprintf(s, "%i", points);
    setLabel(label, s);

    double x = (getWidth(window) - getWidth(label)) / 2;
    double y = (getHeight(window) - getHeight(label)) / 2;
    setLocation(label, x, y);
}

GObject detectCollision(GWindow window, GOval ball)
{
    double x = getX(ball);
    double y = getY(ball);

    GObject object;

    object = getGObjectAt(window, x, y);
    if (object != NULL)
    {
        return object;
    }

    object = getGObjectAt(window, x + 2 * RADIUS, y);
    if (object != NULL)
    {
        return object;
    }

    object = getGObjectAt(window, x, y + 2 * RADIUS);
    if (object != NULL)
    {
        return object;
    }

    object = getGObjectAt(window, x + 2 * RADIUS, y + 2 * RADIUS);
    if (object != NULL)
    {
        return object;
    }

    return NULL;
}       
1

I think you have to write #include <spl/gevents.h> instead of #include "gevents.h"

And you have to change also #include"gobjects.h" to #include<spl/gobjects.h> and also #include"gwindow.h" to #include<spl/gwindow.h>

And make sure that the "make file" in the same directory where is the breakout file exist.

| improve this answer | |
0

The include statement uses " " when the headers are in a subdirectory. The videos indicate that those statements should be written with (as example) when using the latest appliance. Looking at the src4m sample files, the includes are written using the < >.

| improve this answer | |
  • still doesnt work....anything else? – Ani Jul 18 '15 at 15:12
  • Did you try #include <spl/gevents.h>? – lyflonglerner Jul 18 '15 at 20:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .