Public feed #723553

Untitled

public text v1 · immutable
Raw Edit
·published 2007-10-02 21:21 UTC
rendered paste body
#ifndef Map_Class_H
#define Map_Class_H

#include "SDL_Side_G.h"


const int MapSizeX=50;
const int MapSizeY=50;

class Map
{
    private:
    char MapData[ MapSizeX*MapSizeY ];
    SDL_Surface Tiles[20];
    int TileSizeX;
    int TileSizeY;
    int ScreenX;
    int ScreenY;
    
    
    
    public:
    void LoadTiles();
    int DrawOnScreen(Coordinates PlayerLoc,Coordinates Offset);
    int LoadMap();
    
};

void Map::LoadTiles()
{
     Tiles[0] = SDL_LoadImage("Slayer.bmp");
};

//Warning No out of bounds check
int Map::DrawOnScreen(Coordinates PlayerLoc,Coordinates Offset)
{
    PlayerLoc.X -= ScreenX/2;
    PlayerLoc.Y -= ScreenY/2;
    
    
    
    int MaxX = ScreenX*2;
    int MaxY = ScreenY*2;
    
    int X = 0;
    int Y = 0;
    
    
    while(X < MaxX )
    {
        while( Y < MaxY )
        {
            ApplyImage(X+Offset.X ,Y+Offset.Y ,Tiles[ ( MapData[MapSizeX*MapSizeY] ) -'0' ] ,Screen );
            Y++;
        }
        X++;
    }
    return 0;
}

int Map::LoadMap( char *location)
{ 
  int Length = MapSizeX*MapSizeY;
  
  FILE *INPUT = fopen(location, "r");
  if( fread(MapData, 1, Length, INPUT) != Length )
  {
      //Phailed :(    
  }
  fclose( INPUT);
  
  return 0;
};

#endif