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