20100212
[gdash.git] / src / caveobject.h
blob2717243be837dfaf89acfe1c6758251158fecd0a
1 /*
2 * Copyright (c) 2007, 2008, 2009, Czirkos Zoltan <cirix@fw.hu>
4 * Permission to use, copy, modify, and distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 #ifndef _GD_CAVEOBJECT_H
17 #define _GD_CAVEOBJECT_H
19 #include <glib.h>
20 #include "cave.h"
22 typedef enum _gd_object_type {
23 NONE, /* this one to be zero. */
24 GD_POINT, /* single point of object1 */
25 GD_LINE, /* line from (1) to (2) of object1 */
26 GD_RECTANGLE, /* rectangle with corners (1) and (2) of object1 */
27 GD_FILLED_RECTANGLE, /* rectangle with corners (1) and (2) of object1, filled with object2 */
28 GD_RASTER, /* aligned plots */
29 GD_JOIN, /* every object1 has an object2 next to it, relative (dx,dy) */
30 GD_FLOODFILL_REPLACE, /* fill by replacing */
31 GD_FLOODFILL_BORDER, /* fill to another element, a border */
32 GD_MAZE, /* maze */
33 GD_MAZE_UNICURSAL, /* unicursal maze */
34 GD_MAZE_BRAID, /* braid maze */
35 GD_RANDOM_FILL, /* random fill */
36 GD_COPY_PASTE, /* copy & paste with optional mirror and flip */
37 } GdObjectType;
39 typedef enum _gd_object_levels {
40 GD_OBJECT_LEVEL1=1<<0,
41 GD_OBJECT_LEVEL2=1<<1,
42 GD_OBJECT_LEVEL3=1<<2,
43 GD_OBJECT_LEVEL4=1<<3,
44 GD_OBJECT_LEVEL5=1<<4,
45 GD_OBJECT_LEVEL_ALL=GD_OBJECT_LEVEL1|GD_OBJECT_LEVEL2|GD_OBJECT_LEVEL3|GD_OBJECT_LEVEL4|GD_OBJECT_LEVEL5,
46 } GdObjectLevels;
48 extern GdObjectLevels gd_levels_mask[];
50 typedef struct _gd_object {
51 GdObjectType type; /* type */
52 GdObjectLevels levels; /* levels to show this object on */
54 int x1, y1; /* (first) coordinate */
55 int x2, y2; /* second coordinate */
56 int dx, dy; /* distance of elements for raster or join */
57 GdElement element, fill_element; /* element type */
59 gint32 seed[5]; /* for maze and random fill */
60 int horiz; /* for maze */
62 gboolean mirror, flip; /* for copy */
64 gboolean c64_random; /* random fill objects: use c64 random generator */
65 GdElement random_fill[4];
66 int random_fill_probability[4];
67 } GdObject;
69 GdObject *gd_object_new_point(GdObjectLevels levels, int x, int y, GdElement elem);
70 GdObject *gd_object_new_line(GdObjectLevels levels, int x1, int y1, int x2, int y2, GdElement elem);
71 GdObject *gd_object_new_rectangle(GdObjectLevels levels, int x1, int y1, int x2, int y2, GdElement elem);
72 GdObject *gd_object_new_filled_rectangle(GdObjectLevels levels, int x1, int y1, int x2, int y2, GdElement elem, GdElement fill_elem);
73 GdObject *gd_object_new_raster(GdObjectLevels levels, int x1, int y1, int x2, int y2, int dx, int dy, GdElement elem);
74 GdObject *gd_object_new_join(GdObjectLevels levels, int dx, int dy, GdElement search, GdElement replace);
75 GdObject *gd_object_new_floodfill_border(GdObjectLevels levels, int x1, int y1, GdElement fill, GdElement border);
76 GdObject *gd_object_new_floodfill_replace(GdObjectLevels levels, int x1, int y1, GdElement fill, GdElement to_replace);
77 GdObject *gd_object_new_maze(GdObjectLevels levels, int x1, int y1, int x2, int y2, int wall_w, int path_w, GdElement wall_e, GdElement path_e, int horiz_percent, const gint32 seed[5]);
78 GdObject *gd_object_new_maze_unicursal(GdObjectLevels levels, int x1, int y1, int x2, int y2, int wall_w, int path_w, GdElement wall_e, GdElement path_e, int horiz_percent, const gint32 seed[5]);
79 GdObject *gd_object_new_maze_braid(GdObjectLevels levels, int x1, int y1, int x2, int y2, int wall_w, int path_w, GdElement wall_e, GdElement path_e, int horiz_percent, const gint32 seed[5]);
80 GdObject *gd_object_new_random_fill(GdObjectLevels levels, int x1, int y1, int x2, int y2, const gint32 seed[5], GdElement initial, const GdElement random[4], const gint32 prob[4], GdElement replace_only, gboolean c64);
81 GdObject *gd_object_new_copy_paste(GdObjectLevels levels, int x1, int y1, int x2, int y2, int dx, int dy, gboolean mirror, gboolean flip);
89 void gd_cave_draw_object(GdCave *cave, const GdObject *object, int level);
90 char *gd_object_get_bdcff(const GdObject *object);
91 GdObject *gd_object_new_from_string(char *str);
93 GdCave *gd_cave_new_rendered(const GdCave *data, const int level, guint32 seed);
94 void gd_flatten_cave(GdCave *cave, const int level);
96 #endif /* CAVEOBJECT.H */