169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
|
}
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) {
|
|
>
>
>
>
>
>
>
>
>
>
>
>
|
|
>
|
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
|
}
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) {
if(ev->button.y<48) {
strcpy(buf," ");
} else if(side_mode) {
// Inventory
x=(ev->button.y-52)/picture_size;
if(x<0 || x>=ninventory) strcpy(buf," "); else snprintf(buf,8,"%7d",inventory[x].value);
} else {
// Move list
x=replay_pos+(ev->button.y+4)/16-(screen->h-68)/32-4;
if(x<0 || x>replay_count) strcpy(buf," "); else snprintf(buf,8,"=%6d",x);
}
} else {
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) {
|
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
|
break;
case SDL_USEREVENT:
if(!gameover && !quiz_text) continue_animation();
timerflag=0;
break;
case SDL_MOUSEBUTTONDOWN:
if(ev.button.x<left_margin) {
break;
} else {
i=exec_key_binding(&ev,0,(ev.button.x-left_margin)/picture_size+1,ev.button.y/picture_size+1,game_command,0);
goto command;
}
case SDL_KEYDOWN:
i=exec_key_binding(&ev,0,0,0,game_command,0);
command:
if(i==-1) exit(0);
if(i==-2) {
main_options['e']=1;
SDL_SetTimer(0,0);
return;
}
if(inputs_count) {
//TODO: Check for solution replay
for(i=0;i<inputs_count && !gameover;i++) if(inputs[i]) input_move(inputs[i]);
inputs_count=0;
}
redraw_game();
timerflag=0; // ensure we have not missed a timer event
|
>
>
>
|
>
>
>
>
>
>
>
|
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
|
break;
case SDL_USEREVENT:
if(!gameover && !quiz_text) continue_animation();
timerflag=0;
break;
case SDL_MOUSEBUTTONDOWN:
if(ev.button.x<left_margin) {
if(ev.button.y<48) break;
if(side_mode) {
// Inventory
} else {
// Move list
i=(ev.button.y+4)/16-(screen->h-68)/32-4;
if(i<0) game_command(0,'- ',-i,0,0,0); else if(i>0) game_command(0,'+ ',i,0,0,0);
goto replay;
}
break;
} else {
i=exec_key_binding(&ev,0,(ev.button.x-left_margin)/picture_size+1,ev.button.y/picture_size+1,game_command,0);
goto command;
}
case SDL_KEYDOWN:
i=exec_key_binding(&ev,0,0,0,game_command,0);
command:
if(i==-1) exit(0);
if(i==-2) {
main_options['e']=1;
SDL_SetTimer(0,0);
return;
}
replay:
if(inputs_count) {
//TODO: Check for solution replay
for(i=0;i<inputs_count && !gameover;i++) if(inputs[i]) input_move(inputs[i]);
inputs_count=0;
}
redraw_game();
timerflag=0; // ensure we have not missed a timer event
|