pmc/main.cc
changeset 46 4b9e1ac40246
parent 45 7197576fedcf
child 54 c064ce9f40f5
equal deleted inserted replaced
45:7197576fedcf 46:4b9e1ac40246
    35     if ((height < 10) || (height >= 360))
    35     if ((height < 10) || (height >= 360))
    36         height = 200;
    36         height = 200;
    37 
    37 
    38     Vector p1 (0, 0);
    38     Vector p1 (0, 0);
    39     Vector p2 (height, 0);
    39     Vector p2 (height, 0);
    40     Vector p3 (height, height);
    40     Vector p3 (height + 100, height + 100);
    41     Vector p4 (0, height);
    41     Vector p4 (100, height + 100);
    42 
    42 
    43     surface = new Surface (1024, 768, 16);
    43     surface = new Surface (1024, 768, 32);
       
    44     SDL_WM_SetCaption ("Pimp my Cube", NULL);
    44 
    45 
    45     d[0] = new Rectangle (surface, p1, p2, p3, p4);
    46     d[0] = new Rectangle (surface, p1, p2, p3, p4);
    46     d[1] = new Cube (surface);
    47     d[1] = new Cube (surface);
    47     d[2] = new Cube (surface, p1, p2, p3, p4, height);
    48     d[2] = new Cube (surface, p1, p2, p3, p4, height);
    48 
    49 
    49     bool running = true;
    50     bool running = true;
    50     int i, x, y;
    51     int i, x, y;
    51 
    52 
    52     x = y = 0;
    53     x = y = 0;
    53 
    54 
    54     d[1]->move (Vector (25, 25));
    55     d[1]->move (Vector (3 * height, 25));
    55     d[2]->move (Vector (290, 0));
    56     d[2]->move (Vector (290, 0));
    56 
    57 
    57     while (running) {
    58     while (running) {
    58         SDL_PollEvent (&event);
    59         SDL_PollEvent (&event);
    59 
    60 
    62 
    63 
    63         if (event.type == SDL_KEYDOWN) {
    64         if (event.type == SDL_KEYDOWN) {
    64             surface->setColor (Surface::BLACK);
    65             surface->setColor (Surface::BLACK);
    65             for (i = 0; i < MAX; i++)
    66             for (i = 0; i < MAX; i++)
    66                 d[i]->show ();
    67                 d[i]->show ();
    67             surface->setColor (Surface::RED);
    68             surface->setColor (Surface::GREEN);
    68 
    69 
    69             switch (event.key.keysym.sym) {
    70             switch (event.key.keysym.sym) {
    70             case SDLK_ESCAPE:
    71             case SDLK_ESCAPE:
    71                 running = false;
    72                 running = false;
    72                 break;
    73                 break;