Ejemplo n.º 1
0
void drawApple(struct node *tail){
    int tempY = rand() % 38 +1;
    int tempX = rand() % 51;
    tempY = (tempY*6);
    tempX = (tempX*6)+4;
    apple->y  = tempY;
    apple->x = tempX;
    struct node *tempnode;
    tempnode = tail;
    if(checkScreen(tempX, tempY) == green){
        drawApple(tail);
    }
    drawRect(apple->x, apple->y, 5, 5, &red);
}
Ejemplo n.º 2
0
Toplevel::Toplevel()
    : vis(NULL)
    , info(NULL)
    , ready_for_painting(true)
    , m_isDamaged(false)
    , m_client()
    , damage_handle(None)
    , is_shape(false)
    , effect_window(NULL)
    , m_clientMachine(new ClientMachine(this))
    , wmClientLeaderWin(0)
    , unredirect(false)
    , unredirectSuspend(false)
    , m_damageReplyPending(false)
    , m_screen(0)
{
    connect(this, SIGNAL(damaged(KWin::Toplevel*,QRect)), SIGNAL(needsRepaint()));
    connect(screens(), SIGNAL(changed()), SLOT(checkScreen()));
    connect(screens(), SIGNAL(countChanged(int,int)), SLOT(checkScreen()));
    setupCheckScreenConnection();
}
Ejemplo n.º 3
0
/* - Check for valid screen sizes ------------------------------------------- */
void fillScreens() {
	gint width, height;

	width = gdk_screen_width();
	height = gdk_screen_height();

	if(checkScreen("640x480", width, height))
		screensize = g_list_append(screensize, "640x480");
	if(checkScreen("800x600", width, height))
		screensize = g_list_append(screensize, "800x600");
	if(checkScreen("1024x768", width, height))
		screensize = g_list_append(screensize, "1024x768");
	if(checkScreen("1270x940", width, height))
		screensize = g_list_append(screensize, "1270x940");
	if(checkScreen("1280x1024", width, height))
		screensize = g_list_append(screensize, "1280x1024");
	if(checkScreen("1600x1280", width, height))
		screensize = g_list_append(screensize, "1600x1280");

	screensize = g_list_append(screensize, _("Fullscreen"));
}
Ejemplo n.º 4
0
void gameloop() { 
    srand( time(NULL));
    
    root = (struct node *) malloc(sizeof(struct node));
    body = (struct node *) malloc(sizeof(struct node));
    tail = (struct node *) malloc(sizeof(struct node));
    head = (struct node *) malloc(sizeof(struct node));
    temp = (struct node *) malloc(sizeof(struct node));
    apple = (struct node *) malloc(sizeof(struct node));


    int h = 5;
    int x = 100;
    int y = 120;
    root->x = 160;
    root->y = 120;
    body->x = 154;
    body->y = 120;
    tail->x = 0;
    tail->y = 0;
    head->x = 0;
    head->y = 0;
    // apple->x = 130;
    // apple ->y = 120;


    tail->next = root;
    head->next = body;
    root->next = body;

    bool go = true;
    int moving = 1;
    drawRect(0,0,320, 240, &white);
    drawRect(4,6, 306, 228, &black);
    drawRect(root->x, root->y, h, h, &green);
    drawRect(body->x, body->y, h, h, &green);
    drawApple(tail);


    struct timespec lastTime;
    clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &lastTime);



    //while (nanosleep(&sleeptime, &sleeptime) && errno == EINTR);
    getGpio();
        while(go){
            while (msSince(lastTime)<50);
                clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &lastTime);
            head->next->next =  (struct node *) malloc(sizeof(struct node));
            if (direction == 5){
                break;
            }
            if(direction != moving+2 && direction != moving-2 && direction != moving){
                if (direction != 0){
                    moving = direction;
                }
            }

            if (moving == 1){
                head->next->next->x = head->next->x-6;
                head->next->next->y = head->next->y;
            }
            else if(moving == 2){
                head->next->next->x = head->next->x;
                head->next->next->y = head->next->y-6;
            }
            else if(moving == 3){
                head->next->next->x = head->next->x+6;
                head->next->next->y = head->next->y;
            }
            else if(moving == 4){
                head->next->next->x = head->next->x;
                head->next->next->y = head->next->y+6;
            }
            if (checkScreen(head->next->next->x, head->next->next->y) == green)
            {
                printf("You f****n wanku55\n");
                break;
            }
            head->next = head->next->next;

            drawRect(head->next->x, head->next->y, h, h, &green);
            if(head->next->x >=308 || head->next->y >=235 || head->next->x <= 2 || head->next->y <= 5){
                printf("you f*****g wankuh\n");
                break;
            }
            if(head->next->x != apple->x || head->next->y != apple->y){
                drawRect(tail->next->x, tail->next->y, h, h, &black);
                temp = tail->next->next;
                free(tail->next);
                tail->next = temp;
            }
            else{
               drawApple(tail);
            }
        }

}
Ejemplo n.º 5
0
            m_screen = 0;
            emit screenChanged();
        }
        return;
    }
    const int s = screens()->number(geometry().center());
    if (s != m_screen) {
        m_screen = s;
        emit screenChanged();
    }
}

void Toplevel::setupCheckScreenConnection()
{
    connect(this, SIGNAL(geometryShapeChanged(KWin::Toplevel*,QRect)), SLOT(checkScreen()));
    connect(this, SIGNAL(geometryChanged()), SLOT(checkScreen()));
    checkScreen();
}

void Toplevel::removeCheckScreenConnection()
{
    disconnect(this, SIGNAL(geometryShapeChanged(KWin::Toplevel*,QRect)), this, SLOT(checkScreen()));
    disconnect(this, SIGNAL(geometryChanged()), this, SLOT(checkScreen()));
}

int Toplevel::screen() const
{
    return m_screen;
}

bool Toplevel::isOnScreen(int screen) const