Skip to content
Snippets Groups Projects
game.h 3.29 KiB
Newer Older
#ifndef GAME_H_INCLUDED
#define GAME_H_INCLUDED

Jin Zijun's avatar
Jin Zijun committed
#include <SDL/common.h>
#include <SDL/Button.h>
#include <SDL/InputBox.h>

#define RGB_WHITE 0x00FFFFFF
#define RGB_GREEN 0x0000FF00
#define RGB_GREY 0x00BEBEBE
#define RGB_RED 0x00FF0000
#define RGB_BLUE 0x000000FF
Jin Zijun's avatar
Jin Zijun committed

#define BACKGROUND_STACK_SIZE           100
Jin Zijun's avatar
Jin Zijun committed
#define PERUDO_FPS_DELAY                10
Jin Zijun's avatar
Jin Zijun committed
#define PERUDO_BACKGROUND_WIDTH         600
#define PERUDO_BACKGROUND_HEIGHT        480
#define PERUDO_TEXTBOX_WIDTH            800
#define PERUDO_TEXTBOX__HEIGHT          160
#define PERUDO_INFOBOX_WIDTH            200
#define PERUDO_INFOBOX__HEIGHT          480
#define PERUDO_NB_INPUTS                6
#define PERUDO_NB_BUTTONS               10
#define PERUDO_ACTIVE_BUTTONS           8
#define Perudo_STACK_SIZE               50
Jin Zijun's avatar
Jin Zijun committed

Jin Zijun's avatar
Jin Zijun committed
typedef struct stack{
    unsigned int stack[BACKGROUND_STACK_SIZE];
    unsigned short stackPointer;
}stack;

enum inputs{dice1,dice2,dice3,dice4,dice5,dice6,save,paco,dudo,clear,
            No1,No2,No3,No4,No5,No6,No7,No8,No9,No10,
            No11,No12,No13,No14,No15,No16,No17,No18,No19,No20,
            No21,No22,No23,No24,No25,No26,No27,No28,No29,No30};
Jin Zijun's avatar
Jin Zijun committed
typedef struct perudo{
    SDL_Surface* background_screen;
    SDL_Rect background_pos;
    SDL_Surface* save_background;
    Boolean left_click;
    Boolean right_click;
    Boolean is_active;
    short tool;
    stack stack;
    SDL_InputBox input_box;
    SDL_Surface* input_surf[PERUDO_NB_INPUTS];
    SDL_Rect input_pos[PERUDO_NB_INPUTS];
    TTF_Font* font;
    SDL_Color text_color;
    Uint32 draw_color;
    Uint32 draw_color_bright;
Jin Zijun's avatar
Jin Zijun committed
    Uint32 save_color;
    Boolean input_active[PERUDO_ACTIVE_BUTTONS];
Jin Zijun's avatar
Jin Zijun committed
    SDL_Button buttons[PERUDO_NB_BUTTONS];
    SDL_Surface* button_state;
    SDL_Rect button_state_pos;
    SDL_Surface* background_error;
Jin Zijun's avatar
Jin Zijun committed
    SDL_Rect background_error_pos;
    SDL_Surface* textbox;
    SDL_Rect textbox_pos;
    SDL_Surface* infobox;
    SDL_Rect infobox_pos;
    SDL_Surface* textbox_image;
    SDL_Surface* infobox_image;
    Uint32 backgroundtext_color;
    Uint32 backgroundinfo_color;
    SDL_Surface* player[MAX_PLAYERS];
    SDL_Surface* dices[MAX_DICES_PER_PLAYER];
Jin Zijun's avatar
Jin Zijun committed
    SDL_Rect positionPlayer[MAX_PLAYERS];

    SDL_Surface* number[NB_DICES];
    SDL_Rect posNum[NB_DICES];
Jin Zijun's avatar
Jin Zijun committed
    Boolean on_background;
Jin Zijun's avatar
Jin Zijun committed
    Boolean nb_over,nb_over2;
    Boolean value_over,value_over2;
Jin Zijun's avatar
Jin Zijun committed
    Boolean error;
    Boolean left_button_released;

Jin Zijun's avatar
Jin Zijun committed
}perudo;
Jin Zijun's avatar
Jin Zijun committed


void Perudo_launch(SDL_Surface* screen);

void Perudo_init(SDL_Surface* screen, perudo* background);

Jin Zijun's avatar
Jin Zijun committed
void Perudo_initBackground(perudo* background);
Jin Zijun's avatar
Jin Zijun committed

void Perudo_free(perudo* background);

Jin Zijun's avatar
Jin Zijun committed
void Perudo_createBackground(SDL_Surface* screen, perudo* background, SDL_Event* event);
Jin Zijun's avatar
Jin Zijun committed

Jin Zijun's avatar
Jin Zijun committed

Jin Zijun's avatar
Jin Zijun committed
Boolean Perudo_onSurface(short surfx, short surfy,short surfw, short surfh, short x, short y);

void SetPixel(SDL_Surface *surface, int x, int y, Uint32 pixel);

Uint32 GetPixel(SDL_Surface *surface, int x, int y);

void SetPixelSquare(SDL_Surface* surface, short sx0, short sy0, short x, short y, short widht, Uint32 pixel);


Jin Zijun's avatar
Jin Zijun committed

Jin Zijun's avatar
Jin Zijun committed
short Sqrt(short x, short y, short xf, short yf);


Jin Zijun's avatar
Jin Zijun committed
void Perudo_initDice(perudo* background);
Jin Zijun's avatar
Jin Zijun committed


void Stack_emptyStack(stack* s,short h);

Boolean Stack_push(short x, short y, stack* s,short h);

Boolean Stack_pop(short* x, short* y, stack* s,short h);
Jin Zijun's avatar
Jin Zijun committed
#endif