72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
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;
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
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
|
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 continue_animation(void) {
Uint32 n=firstobj;
Object*o;
Animation*a;
int i;
for(i=0;i<8;i++) if(anim_slot[i].length && ++anim_slot[i].vtime==anim_slot[i].speed && ++anim_slot[i].frame==anim_slot[i].length) anim_slot[i].frame=0;
while(n!=VOIDLINK) {
o=objects[n];
if((a=o->anim) && (a->status&ANISTAT_VISUAL)) {
i=a->vstep;
if(a->step[i].flag&ANI_SYNC) {
i=anim_slot[a->step[i].slot].frame+a->step[i].start;
if(i!=a->vimage) {
a->vimage=i;
draw_cell(o->x,o->y);
}
} else if(++a->vtime>=a->step[i].speed) {
a->vtime=0;
if(a->vimage==a->step[i].end) {
if(a->step[i].flag&ANI_ONCE) {
if(a->vstep==a->lstep) {
a->status&=~ANISTAT_VISUAL;
} else {
if(++a->vstep==max_animation) a->vstep=0;
a->vimage=a->step[a->vstep].start;
}
} else if(a->step[i].flag&ANI_OSC) {
a->step[i].end=a->step[i].start;
a->step[i].start=a->vimage;
goto advance;
} else {
a->vimage=a->step[i].start;
}
} else {
advance:
if(a->step[i].end>=a->step[i].start) ++a->vimage; else --a->vimage;
}
draw_cell(o->x,o->y);
}
}
n=o->next;
}
SDL_Flip(screen);
}
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;
|
96
97
98
99
100
101
102
103
104
105
106
107
108
109
|
t=load_level(id)?:init_level();
if(t) {
gameover=-1;
screen_message(t);
} else {
gameover=0;
}
}
static inline void exam_value(const char*t,int y,Value v) {
char buf[256];
int i;
y=(y-exam_scroll)*8;
if(y<0 || y>screen->h-8) return;
|
>
|
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
|
t=load_level(id)?:init_level();
if(t) {
gameover=-1;
screen_message(t);
} else {
gameover=0;
}
timerflag=0;
}
static inline void exam_value(const char*t,int y,Value v) {
char buf[256];
int i;
y=(y-exam_scroll)*8;
if(y<0 || y>screen->h-8) return;
|
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
|
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) {
break;
} else {
|
|
|
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
|
case SDL_QUIT:
exit(0);
break;
case SDL_MOUSEMOTION:
show_mouse_xy(&ev);
break;
case SDL_USEREVENT:
if(!gameover) continue_animation();
timerflag=0;
break;
case SDL_MOUSEBUTTONDOWN:
if(ev.button.x<left_margin) {
break;
} else {
|