Main Page | Alphabetical List | Class List | File List | Class Members | File Members

editor/palette.c

Go to the documentation of this file.
00001 #include "editor.h"
00002 
00003 #define PALETTE_WIDTH  8   /* As number of tiles. Each tile is 8 pixels. */
00004 #define PALETTE_HEIGHT 6
00005 #define PALETTE_X 24       /* Must be a multiple of 8. */
00006 #define PALETTE_Y 32
00007 static int palette_cursor_pos=0;
00008 
00009 char palette_map[] = {
00010     TILE_KYE,
00011     TILE_DIAMOND,
00012     TILE_TWIST_CW,
00013     TILE_TWIST_CCW,
00014     TILE_WALL_7,
00015     TILE_WALL_8,
00016     TILE_WALL_9,
00017     TILE_BLOB,
00018     
00019     TILE_ROCKY_E,
00020     TILE_ROCKY_W,
00021     TILE_SLIDER_E,
00022     TILE_SLIDER_W,
00023     TILE_WALL_4,
00024     TILE_WALL_5,
00025     TILE_WALL_6,
00026     TILE_VIRUS,
00027     
00028     TILE_ROCKY_N,
00029     TILE_ROCKY_S,
00030     TILE_SLIDER_N,
00031     TILE_SLIDER_S,
00032     TILE_WALL_1,
00033     TILE_WALL_2,
00034     TILE_WALL_3,
00035     TILE_TWISTER,
00036     
00037     TILE_PUSHER_E,
00038     TILE_PUSHER_W,
00039     DOOR_WE,
00040     DOOR_EW,
00041     TILE_STICKY_EW,
00042     TILE_STICKY_NS,
00043     TILE_EXPLODER,
00044     TILE_GNASHER,
00045     
00046     TILE_PUSHER_N,
00047     TILE_PUSHER_S,
00048     DOOR_SN,
00049     DOOR_NS,
00050     TILE_MAGNET_EW,
00051     TILE_MAGNET_NS,
00052     TILE_PIT,
00053     TILE_SPIKE,
00054     
00055     TILE_FUZZY,
00056     TILE_BOULDER,
00057     TILE_BLOCK
00058     };
00059 
00060 //{{{
00061 void enter_palette_state(void)
00062 {
00063     int ii;
00064     
00065     draw_rect(PALETTE_X-2, PALETTE_Y-2, (PALETTE_WIDTH<<3)+5,
00066                (PALETTE_HEIGHT<<3)+5);
00067     
00068     for(ii=0; ii<NUM_TILE_TYPES-1; ii++) {
00069         draw_sprite(tile_sprites[ (int)palette_map[ii] ],
00070             PALETTE_X + ((ii%PALETTE_WIDTH)<<3),
00071             PALETTE_Y + ((ii/PALETTE_WIDTH)<<3));
00072     }
00073     draw_palette_cursor();
00074     
00075     input_state = palette_state;
00076 }
00077 //}}}
00078 //{{{
00079 void draw_palette_cursor(void)
00080 {
00081     draw_sprite_xor(black_square,
00082                     PALETTE_X + ((palette_cursor_pos%PALETTE_WIDTH)<<3),
00083                     PALETTE_Y + ((palette_cursor_pos/PALETTE_WIDTH)<<3));
00084 }
00085 //}}}
00086 //{{{
00087 void move_palette_cursor(int dd)
00088 {
00089     if(palette_cursor_pos+dd < 0 || palette_cursor_pos+dd >= NUM_TILE_TYPES-1)
00090         return;
00091     draw_palette_cursor();
00092     palette_cursor_pos += dd;
00093     draw_palette_cursor();
00094 }
00095 //}}}
00096 //{{{
00097 void palette_state(int key)
00098 {
00099     if(key == KEY_LEFT) {
00100         move_palette_cursor(-1);
00101     } else if(key == KEY_UP) {
00102         move_palette_cursor(-PALETTE_WIDTH);
00103     } else if(key == KEY_RIGHT) {
00104         move_palette_cursor(1);
00105     } else if(key == KEY_DOWN) {
00106         move_palette_cursor(PALETTE_WIDTH);
00107     } else if(key == KEY_ENTER) {
00108         edit_brush = palette_map[palette_cursor_pos];
00109         enter_edit_state();
00110     } else if(key == KEY_ESC) {
00111         enter_edit_state();
00112     }
00113 }
00114 //}}}
00115 

Generated on Thu Apr 22 14:06:32 2004 for SKye by doxygen 1.3.6