#ifndef _MAIN_ENGINE_H_
#define _MAIN_ENGINE_H_

//how many sprites can be held
#define MAXSPRITE 40

#include <SDL/SDL.h>
#include <stdlib.h>
#include <iostream>
#include <fstream>
#include "Cplayer.h"

using std::ifstream;

//sound stuff carrying struct
typedef struct
{
  char menup[256];
  char mendown[256];
  char mensel[256];
  char mencan[256];
  char ambient[256];
  bool music[5][1];
}SoundFX;

//sprite structure for keeping the sprite picture data
typedef struct
{
  SDL_Surface *sprite;
}SpriteP;

//sprite structure for names
typedef struct
{
  char sprites[MAXSPRITE][256]; //up to 40 sprites (for now <.<)
  bool spriteb[MAXSPRITE][1]; //check which parts contain sprites
  SpriteP *SPIC;
}SpriteS;

//the second piece for the block stucture
typedef struct
{
  int x, y; //containers for coordinate
  int w, h; //width and height of picture
  int tex; //texture used
  bool collision; //collision detection checker (true = on, false = off)
}BlockInfo;

//main block structure
typedef struct
{
  //how many blocks there are
  int BlockNum;
  BlockInfo *blockinfo;
}BlockS;

class CEMain
{
  public:
  //start loading everything 
  CEMain(SDL_Surface * back, int videox, int videoy, int bitdepth);
  //main loop: controls all processes 
  void Loop();
  //made to lead up image files 
  SDL_Surface * ImageLoad(char * file);
  //drawing the image onto the screen 
  void DrawIMG(SDL_Surface *img, int x, int y);
  //loading the map 
  void LoadMap(char * filename);
  //make sure background is displayed every loop
  void BackGround();
  //parses sprite file
  void ParseSpriteFile(char * filename);
  //parses music file
  void ParseMusicFile(char * filename);
  //parses coordinate file for sprites
  void ParseMapCoord(char * filename);
  //draw all blocks onscreen
  void BlockDraw();
  //check the block-to-player collisions
  void BlockCollideCheck();
  
  protected:
  //keep track of keys pressed
  Uint8* keys;
  //screen containers and for sprites
  SDL_Surface *back;
  SDL_Surface *background;
  
  //reading file containers
  ifstream file, muzfile, sprfile, coorfile;
  
  //string container (for file stuff)
  char bg[512];
  
  //container struct for sounds
  SoundFX SFX;
  
  //container struct for sprites
  SpriteS SPRITE;
  
  //container struct for block data
  BlockS BLOCK;
};

#endif