4 * The geeky little puzzle game with a big noodly crunch!
6 * gPlanarity copyright (C) 2005 Monty <monty@xiph.org>
7 * Original Flash game by John Tantalo <john.tantalo@case.edu>
8 * Original game concept by Mary Radcliffe
10 * gPlanarity is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2, or (at your option)
15 * gPlanarity is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with Postfish; see the file COPYING. If not, write to the
22 * Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
29 #include "gameboard.h"
31 static fade_list
*pool
=0;
34 static void fade_add_vertex(fade_state
*f
,vertex
*v
){
39 pool
= calloc(CHUNK
,sizeof(*pool
));
40 for(i
=0;i
<CHUNK
-1;i
++) /* last addition's next points to nothing */
41 pool
[i
].next
=pool
+i
+1;
54 static gint
animate_fade(gpointer ptr
){
55 Gameboard
*g
= (Gameboard
*)ptr
;
56 fade_state
*f
= &g
->fade
;
60 fade_list
*l
= f
->head
;
63 invalidate_vertex(g
,l
->v
);
74 void fade_cancel(Gameboard
*g
){
75 fade_state
*f
= &g
->fade
;
76 fade_list
*l
= f
->head
;
79 fade_list
*n
= l
->next
;
84 /* invalidate the vertex */
85 invalidate_vertex(g
,l
->v
);
95 g_source_remove(f
->fade_timer
);
99 void fade_attached(Gameboard
*g
,vertex
*v
){
100 fade_state
*f
= &g
->fade
;
101 edge_list
*el
=v
->edges
;
103 /* If a fade is already in progress, cancel it */
110 fade_add_vertex(f
,e
->B
);
112 fade_add_vertex(f
,e
->A
);
117 f
->count
= FADE_FRAMES
;
119 f
->fade_timer
= g_timeout_add(FADE_ANIM_INTERVAL
, animate_fade
, (gpointer
)g
);
122 void fade_grabbed(Gameboard
*g
){
123 fade_state
*f
= &g
->fade
;
124 vertex
*v
= g
->g
.verticies
;
126 /* If a fade is already in progress, cancel it */
131 edge_list
*el
=v
->edges
;
139 fade_add_vertex(f
,e
->B
);
142 fade_add_vertex(f
,e
->A
);
150 f
->count
= FADE_FRAMES
;
152 f
->fade_timer
= g_timeout_add(FADE_ANIM_INTERVAL
, animate_fade
, (gpointer
)g
);
155 void fade_marked(Gameboard
*g
){
156 fade_state
*f
= &g
->fade
;
157 vertex
*v
= g
->g
.verticies
;
159 /* If a fade is already in progress, cancel it */
164 fade_add_vertex(f
,v
);
168 f
->count
= FADE_FRAMES
;
170 f
->fade_timer
= g_timeout_add(FADE_ANIM_INTERVAL
, animate_fade
, (gpointer
)g
);