src/proto2/Drawer.cc.disabled
author terom
Sun, 09 Nov 2008 21:51:13 +0000
changeset 25 af75a1894a32
parent 12 9b51949fdca6
permissions -rw-r--r--
simple proto *almost* works
12
9b51949fdca6 fiddling with cmake linking
terom
parents:
diff changeset
     1
#include <ClanLib/core.h>
9b51949fdca6 fiddling with cmake linking
terom
parents:
diff changeset
     2
#include <ClanLib/gl.h> //do I need this in linux?
9b51949fdca6 fiddling with cmake linking
terom
parents:
diff changeset
     3
#include <ClanLib/display.h>
9b51949fdca6 fiddling with cmake linking
terom
parents:
diff changeset
     4
#include <ClanLib/application.h>
9b51949fdca6 fiddling with cmake linking
terom
parents:
diff changeset
     5
#include "GameState.hh"
9b51949fdca6 fiddling with cmake linking
terom
parents:
diff changeset
     6
#include "Dimension.hh"
9b51949fdca6 fiddling with cmake linking
terom
parents:
diff changeset
     7
9b51949fdca6 fiddling with cmake linking
terom
parents:
diff changeset
     8
class CL_Game : public CL_ClanApplication {
9b51949fdca6 fiddling with cmake linking
terom
parents:
diff changeset
     9
private:
25
af75a1894a32 simple proto *almost* works
terom
parents: 12
diff changeset
    10
        bool keep_going;
af75a1894a32 simple proto *almost* works
terom
parents: 12
diff changeset
    11
        void check_input() {
af75a1894a32 simple proto *almost* works
terom
parents: 12
diff changeset
    12
                if(CL_Keyboard::get_keycode(CL_KEY_ESCAPE))
af75a1894a32 simple proto *almost* works
terom
parents: 12
diff changeset
    13
                        keep_going = false;
af75a1894a32 simple proto *almost* works
terom
parents: 12
diff changeset
    14
                        
12
9b51949fdca6 fiddling with cmake linking
terom
parents:
diff changeset
    15
        LocalPlayer& lp = gs.getLocalPlayer();
9b51949fdca6 fiddling with cmake linking
terom
parents:
diff changeset
    16
25
af75a1894a32 simple proto *almost* works
terom
parents: 12
diff changeset
    17
                if(CL_Keyboard::get_keycode(CL_KEY_UP)) {
af75a1894a32 simple proto *almost* works
terom
parents: 12
diff changeset
    18
                        lp.doMovement(PositionDelta(0,3));
af75a1894a32 simple proto *almost* works
terom
parents: 12
diff changeset
    19
                }
af75a1894a32 simple proto *almost* works
terom
parents: 12
diff changeset
    20
                if(CL_Keyboard::get_keycode(CL_KEY_DOWN)) {
af75a1894a32 simple proto *almost* works
terom
parents: 12
diff changeset
    21
                        lp.doMovement(PositionDelta(0,-3));
af75a1894a32 simple proto *almost* works
terom
parents: 12
diff changeset
    22
                }
af75a1894a32 simple proto *almost* works
terom
parents: 12
diff changeset
    23
                if(CL_Keyboard::get_keycode(CL_KEY_LEFT)) {
af75a1894a32 simple proto *almost* works
terom
parents: 12
diff changeset
    24
                        lp.doMovement(PositionDelta(-3,0));
af75a1894a32 simple proto *almost* works
terom
parents: 12
diff changeset
    25
                }
af75a1894a32 simple proto *almost* works
terom
parents: 12
diff changeset
    26
                if(CL_Keyboard::get_keycode(CL_KEY_RIGHT)) {
af75a1894a32 simple proto *almost* works
terom
parents: 12
diff changeset
    27
                        lp.doMovement(PositionDelta(3,0));
af75a1894a32 simple proto *almost* works
terom
parents: 12
diff changeset
    28
                }
af75a1894a32 simple proto *almost* works
terom
parents: 12
diff changeset
    29
        }
12
9b51949fdca6 fiddling with cmake linking
terom
parents:
diff changeset
    30
9b51949fdca6 fiddling with cmake linking
terom
parents:
diff changeset
    31
public:
25
af75a1894a32 simple proto *almost* works
terom
parents: 12
diff changeset
    32
        GameState gs;
12
9b51949fdca6 fiddling with cmake linking
terom
parents:
diff changeset
    33
25
af75a1894a32 simple proto *almost* works
terom
parents: 12
diff changeset
    34
        CL_Game() : keep_going(true) {}
af75a1894a32 simple proto *almost* works
terom
parents: 12
diff changeset
    35
        virtual int main(int argc, char **argv) {
af75a1894a32 simple proto *almost* works
terom
parents: 12
diff changeset
    36
                CL_SetupCore setup_init;
af75a1894a32 simple proto *almost* works
terom
parents: 12
diff changeset
    37
                CL_SetupDisplay setup_disp;
af75a1894a32 simple proto *almost* works
terom
parents: 12
diff changeset
    38
                CL_SetupGL setup_gl;
af75a1894a32 simple proto *almost* works
terom
parents: 12
diff changeset
    39
                
af75a1894a32 simple proto *almost* works
terom
parents: 12
diff changeset
    40
                //gs.player_list.push(Player(Coordinate()));
12
9b51949fdca6 fiddling with cmake linking
terom
parents:
diff changeset
    41
25
af75a1894a32 simple proto *almost* works
terom
parents: 12
diff changeset
    42
                CL_DisplayWindow win("ikkuna", 640, 480);
af75a1894a32 simple proto *almost* works
terom
parents: 12
diff changeset
    43
//              CL_Surface bg(CL_PNGProvider("image.png");
12
9b51949fdca6 fiddling with cmake linking
terom
parents:
diff changeset
    44
25
af75a1894a32 simple proto *almost* works
terom
parents: 12
diff changeset
    45
                unsigned int last_draw = CL_System::get_time();
af75a1894a32 simple proto *almost* works
terom
parents: 12
diff changeset
    46
                int r = 100, g = 100, b = 100;
af75a1894a32 simple proto *almost* works
terom
parents: 12
diff changeset
    47
                unsigned int frame_count = 0;
af75a1894a32 simple proto *almost* works
terom
parents: 12
diff changeset
    48
                bool R = false, G = false, B = false;
af75a1894a32 simple proto *almost* works
terom
parents: 12
diff changeset
    49
af75a1894a32 simple proto *almost* works
terom
parents: 12
diff changeset
    50
                while(keep_going) { //not good idea to put infinite loop
af75a1894a32 simple proto *almost* works
terom
parents: 12
diff changeset
    51
                        CL_Display::clear(CL_Color(r, g, b));
12
9b51949fdca6 fiddling with cmake linking
terom
parents:
diff changeset
    52
            
25
af75a1894a32 simple proto *almost* works
terom
parents: 12
diff changeset
    53
                        int colorIdx = 0;
af75a1894a32 simple proto *almost* works
terom
parents: 12
diff changeset
    54
                        for(std::list<Player>::iterator it = gs.player_list.begin(); it != gs.player_list.end(); ++it) {
12
9b51949fdca6 fiddling with cmake linking
terom
parents:
diff changeset
    55
25
af75a1894a32 simple proto *almost* works
terom
parents: 12
diff changeset
    56
                                CL_Display::fill_rect(CL_Rect(it->getPosition().scaledX()-10, it->getPosition().scaledY()-10, 
af75a1894a32 simple proto *almost* works
terom
parents: 12
diff changeset
    57
                                        it->getPosition().scaledX()+10, it->getPosition().scaledY()+10), CL_Color((colorIdx*30)%255, (colorIdx*30)%255, (colorIdx*30)%255));
12
9b51949fdca6 fiddling with cmake linking
terom
parents:
diff changeset
    58
25
af75a1894a32 simple proto *almost* works
terom
parents: 12
diff changeset
    59
                                colorIdx++;
af75a1894a32 simple proto *almost* works
terom
parents: 12
diff changeset
    60
                        }
af75a1894a32 simple proto *almost* works
terom
parents: 12
diff changeset
    61
                        
af75a1894a32 simple proto *almost* works
terom
parents: 12
diff changeset
    62
                        CL_Display::flip(1);
af75a1894a32 simple proto *almost* works
terom
parents: 12
diff changeset
    63
                        frame_count++;
af75a1894a32 simple proto *almost* works
terom
parents: 12
diff changeset
    64
                        unsigned int cur_draw = CL_System::get_time();
af75a1894a32 simple proto *almost* works
terom
parents: 12
diff changeset
    65
                
af75a1894a32 simple proto *almost* works
terom
parents: 12
diff changeset
    66
                        check_input();
af75a1894a32 simple proto *almost* works
terom
parents: 12
diff changeset
    67
af75a1894a32 simple proto *almost* works
terom
parents: 12
diff changeset
    68
                        last_draw = cur_draw;
af75a1894a32 simple proto *almost* works
terom
parents: 12
diff changeset
    69
                        CL_System::keep_alive();
af75a1894a32 simple proto *almost* works
terom
parents: 12
diff changeset
    70
//                      sleep(10); //flip already wait a short amount of time
af75a1894a32 simple proto *almost* works
terom
parents: 12
diff changeset
    71
                }
af75a1894a32 simple proto *almost* works
terom
parents: 12
diff changeset
    72
                return 0;
af75a1894a32 simple proto *almost* works
terom
parents: 12
diff changeset
    73
        }
12
9b51949fdca6 fiddling with cmake linking
terom
parents:
diff changeset
    74
};
9b51949fdca6 fiddling with cmake linking
terom
parents:
diff changeset
    75
9b51949fdca6 fiddling with cmake linking
terom
parents:
diff changeset
    76
CL_Game inst;