haraldhv
/
aigo
Archived
1
0
Fork 0
This repository has been archived on 2024-07-04. You can view files and clone it, but cannot push or open issues or pull requests.
aigo/lib/state.h

60 lines
1.3 KiB
C
Raw Normal View History

2007-02-23 18:10:32 +01:00
#ifndef _STATE_H_
#define _STATE_H_
#include "settings.h"
#include <SDL/SDL.h>
#include <stdint.h>
// get pixel/something in array p of size w*h
#define PX_(p, x, y, w, h) ((p)[(x)+(y)*(w)])
// get pixel in SDL_Surface i
#define PX(i,x,y) (PX_((uint32_t*)(i)->pixels, (x), (y), (i)->w, (i)->h))
// get color components of pixel value. should probably be done in a nicer way
#define PXR(px) ((px) & 0xff)
#define PXG(px) (((px) & 0xff00) >> 8)
#define PXB(px) (((px) & 0xff0000) >> 16)
// iterate over SDL_Surface s with variables x, y
#define iter_pixels(s,x,y) for (x = 0; x < s->w; x++) for (y = 0; y < s->h; y++)
2007-02-23 18:10:32 +01:00
2007-02-23 18:10:32 +01:00
/**
* Describes the current state of a go board.
*/
class State
{
public:
/**
* Standard constructor
*/
State( void );
virtual ~State( void );
2007-02-23 18:10:32 +01:00
void setSize(int size) { State::size = size; }
void printState( void );
2007-02-23 18:10:32 +01:00
static State generateState( SDL_Surface *board, Settings settings);
/*
* Get the image point corresponding to board position (i, j) using
* settings s.
*/
static point positionPoint(int i, int j, Settings s);
private:
/**
* The size of the board, e.g. 19x19, 13x13 etc.
*/
2007-02-23 18:10:32 +01:00
static int size;
/**
* array describing the board situation
*/
type *board;
2007-02-23 18:10:32 +01:00
};
#endif /* ifndef _STATE_H_ */