Overview
Comment: | Start to implement object examination menu in game.c; this revealed that there are still some duplicate objects being loaded, though |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
76cf67a257c254fec291cba0a936aa05 |
User & Date: | user on 2020-12-10 05:37:39 |
Other Links: | manifest | tags |
Context
2020-12-10
| ||
08:09 | Remove an improper division by zero error check-in: 23b475cc02 user: user tags: trunk | |
05:37 | Start to implement object examination menu in game.c; this revealed that there are still some duplicate objects being loaded, though check-in: 76cf67a257 user: user tags: trunk | |
2020-12-08
| ||
03:53 | Add a few structures and stuff related to animation; not complete check-in: 8d8bcb34ca user: user tags: trunk | |
Changes
Modified game.c from [265f8fa7b6] to [d5437772c7].
︙ | ︙ | |||
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 | snprintf(buf,32,"%5d",level_code); draw_text(0,24,"C",0xF0,0xF7); draw_text(16,24,buf,0xF0,0xFF); } snprintf(buf,8,"%2dx%2d",pfwidth,pfheight); draw_text(8,32,buf,0xF0,0xFD); draw_text(24,32,"x",0xF0,0xF5); SDL_UnlockSurface(screen); SDL_Flip(screen); } static void begin_level(int id) { const char*t; t=load_level(id)?:init_level(); if(t) { gameover=-1; screen_message(t); } else { gameover=0; } } static int game_command(int prev,int cmd,int number,int argc,sqlite3_stmt*args,void*aux) { switch(cmd) { case '\' ': // Play a move return number; case '^E': // Edit return -2; case '^L': // Select level begin_level(number); return 1; case '^Q': // Quit return -1; default: return prev; } } static void set_caption(void) { const char*r; | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 | snprintf(buf,32,"%5d",level_code); draw_text(0,24,"C",0xF0,0xF7); draw_text(16,24,buf,0xF0,0xFF); } snprintf(buf,8,"%2dx%2d",pfwidth,pfheight); draw_text(8,32,buf,0xF0,0xFD); draw_text(24,32,"x",0xF0,0xF5); x=x>=left_margin?(x-left_margin)/picture_size+1:0; y=y/picture_size+1; if(x>0 && y>0 && x<=pfwidth && y<=pfheight) snprintf(buf,8,"(%2d,%2d)",x,y); else strcpy(buf," "); draw_text(0,40,buf,0xF0,0xF1); SDL_UnlockSurface(screen); SDL_Flip(screen); set_cursor(XC_arrow); } static void show_mouse_xy(SDL_Event*ev) { char buf[32]; int x,y; x=(ev->motion.x-left_margin)/picture_size+1; y=ev->motion.y/picture_size+1; if(ev->motion.x<left_margin) x=0; if(x>0 && y>0 && x<=pfwidth && y<=pfheight) snprintf(buf,8,"(%2d,%2d)",x,y); else strcpy(buf," "); SDL_LockSurface(screen); draw_text(0,40,buf,0xF0,0xF1); SDL_UnlockSurface(screen); SDL_Flip(screen); } static void begin_level(int id) { const char*t; t=load_level(id)?:init_level(); if(t) { gameover=-1; screen_message(t); } else { gameover=0; } } static void list_objects_at(int xy) { static const char*const dirs[8]={"E ","NE","N ","NW","W ","SW","S ","SE"}; SDL_Event ev; SDL_Rect r; char buf[256]; int scroll=0; int count=0; Uint32 n,t; Object*o; int i,j; if(xy<0 || xy>=64*64) return; n=playfield[xy]; if(n==VOIDLINK) return; while(n!=VOIDLINK) t=n,count++,n=objects[n]->up; redraw: r.x=r.y=0; r.w=screen->w; r.h=screen->h; SDL_FillRect(screen,&r,0xF1); r.y=8; r.h-=8; scrollbar(&scroll,r.h/8,count,0,&r); snprintf(buf,255," %d objects at (%d,%d): ",count,(xy&63)+1,(xy/64)+1); SDL_LockSurface(screen); draw_text(0,0,buf,0xF7,0xF0); n=t; for(i=0;i<scroll && n!=VOIDLINK;i++) n=objects[n]->down; for(i=0;i<screen->h/8 && n!=VOIDLINK;i++) { o=objects[n]; snprintf(buf,255," %8d: %-14.14s %3d %s",n,classes[o->class]->name,o->image,dirs[o->dir&7]); draw_text(24,r.y,buf,0xF1,o->generation?0xFF:0xF8); n=o->down; r.y+=8; } SDL_UnlockSurface(screen); SDL_Flip(screen); while(SDL_WaitEvent(&ev)) { switch(ev.type) { case SDL_MOUSEMOTION: set_cursor(XC_draft_small); break; case SDL_KEYDOWN: switch(ev.key.keysym.sym) { case SDLK_ESCAPE: case SDLK_RETURN: return; } goto redraw; case SDL_VIDEOEXPOSE: goto redraw; case SDL_QUIT: exit(0); break; } } } static int game_command(int prev,int cmd,int number,int argc,sqlite3_stmt*args,void*aux) { switch(cmd) { case '\' ': // Play a move return number; case '^E': // Edit return -2; case '^L': // Select level begin_level(number); return 1; case '^Q': // Quit return -1; case '^o': // List objects list_objects_at(number-65); return prev; default: return prev; } } static void set_caption(void) { const char*r; |
︙ | ︙ | |||
135 136 137 138 139 140 141 142 143 144 145 146 147 148 | while(SDL_WaitEvent(&ev)) { switch(ev.type) { case SDL_VIDEOEXPOSE: redraw_game(); break; case SDL_QUIT: exit(0); break; case SDL_USEREVENT: //TODO: animation timerflag=0; break; case SDL_MOUSEBUTTONDOWN: if(ev.button.x<left_margin) { | > > > | 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 | while(SDL_WaitEvent(&ev)) { switch(ev.type) { case SDL_VIDEOEXPOSE: redraw_game(); break; case SDL_QUIT: exit(0); break; case SDL_MOUSEMOTION: show_mouse_xy(&ev); break; case SDL_USEREVENT: //TODO: animation timerflag=0; break; case SDL_MOUSEBUTTONDOWN: if(ev.button.x<left_margin) { |
︙ | ︙ |