/*
   spacemaze - Fly a space ship through a maze and collect all the items.
   Copyright (C) 2000, 2001, 2002 John Ericson

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

   2000-03-25 High / John Ericson john.ericson@home.se
*/

#ifndef LEVEL_HEADER
#define LEVEL_HEADER

#include <stdio.h>
#include <stdarg.h> /* We need va_list */
#include <stdlib.h> /* We need strtoi */
#include <string.h>
#include <math.h>

#include <libxml/parser.h>
#include <libxml/parserInternals.h>

#include "bool.h"
#include "defines.h"
#include "trim.h"
#include "sprite.h"

typedef enum {
   START        = 0,       /* 0  */
   LEVEL        = 1 << 0,  /* 1  */
   INFO         = 1 << 1,  /* 2  */
   NAME         = 1 << 3,  /* 4  */
   AUTHOR       = 1 << 4,  /* 8  */
   DESCRIPTION  = 1 << 5,  /* 16 */
   GAMETYPE     = 1 << 6,  /* .. */
   SETTINGS     = 1 << 7,
   GRAVITY      = 1 << 8,
   SIZE         = 1 << 9,
   W            = 1 << 10,
   H            = 1 << 11,
   ITEMS        = 1 << 12,
   PLAYERSTART  = 1 << 13,
   X            = 1 << 14,
   Y            = 1 << 15,
   BOX          = 1 << 16,
   LANDSCAPE    = 1 << 17,
   RECTANGLE    = 1 << 18,
   LANDINGPLATE = 1 << 19,
} state_s;

typedef struct {
   int x,
       y;
   int w,
       h;
   int type;
   bool visible;
   bool crashable;
   int activate;
   int color;
} landscape_s;

typedef struct {
   int x,
       y;
} playerstart_s;

typedef struct {
   int x,        /* Position */
       y;
   //int w,        /* Size */
   //    h;
   int type;
   int color;
   bool visible;
   int activate;
   sprite sprite;
} items_s;

typedef struct {
   float         gravity;
   int           sizew,
                 sizeh;
   char          name[255];
   int           maxplayers;
   char          version[32];
   int           numitems;
   items_s       item[MAXITEMS];
   int           numstartpos;
   playerstart_s playerstart[MAXPLAYERS];
   int           size;
   landscape_s   landscape[MAXLEVELSIZE];
} level_s;

int LoadLevel(level_s *level, const char *filename);


#endif /* LEVEL_HEADER */