1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
|
#include "Defines.h"
#include "SDL/SDL.h"
#include "vars.h"
void apply_surfaceClip( int x, int y, SDL_Surface* source, SDL_Surface* destination, SDL_Rect* clip = NULL )
{
//Holds offsets
SDL_Rect offset;
//Get offsets
offset.x = x;
offset.y = y;
//Blit
SDL_BlitSurface( source, clip, destination, &offset );
}
void apply_surface (int x, int y, SDL_Surface* source, SDL_Surface* destination){
SDL_Rect offset;
offset.x = x;
offset.y = y;
SDL_BlitSurface( source, NULL, destination, &offset );
}
int findSlot (int reel, int search){
int index = -1;
if (reel == 1){
for (int a = 0; a <= 9; a++){
if (reel_1.slots[a] == search){
index = a;
a + 9;
}
}
return index;
}
else if (reel == 2){
for (int a = 0; a <= 9; a++){
if (reel_2.slots[a] == search){
index = a;
a + 9;
}
}
return index;
}
else if (reel == 3){
for (int a = 0; a <= 9; a++){
if (reel_3.slots[a] == search){
index = a;
a + 9;
}
}
return index;
}
}
int drawScreen(){
apply_surfaceClip(REEL1X, ROW1Y, reel1, Background, &reel_1.clip[findSlot(1, reel_1.current[0])]);
apply_surfaceClip(REEL1X, ROW2Y, reel1, Background, &reel_1.clip[findSlot(1, reel_1.current[1])]);
apply_surfaceClip(REEL1X, ROW3Y, reel1, Background, &reel_1.clip[findSlot(1, reel_1.current[2])]);
apply_surfaceClip(REEL2X, ROW1Y, reel2, Background, &reel_2.clip[findSlot(2, reel_2.current[0])]);
apply_surfaceClip(REEL2X, ROW2Y, reel2, Background, &reel_2.clip[findSlot(2, reel_2.current[1])]);
apply_surfaceClip(REEL2X, ROW3Y, reel2, Background, &reel_2.clip[findSlot(2, reel_2.current[2])]);
apply_surfaceClip(REEL3X, ROW1Y, reel3, Background, &reel_3.clip[findSlot(3, reel_3.current[0])]);
apply_surfaceClip(REEL3X, ROW2Y, reel3, Background, &reel_3.clip[findSlot(3, reel_3.current[1])]);
apply_surfaceClip(REEL3X, ROW3Y, reel3, Background, &reel_3.clip[findSlot(3, reel_3.current[2])]);
apply_surface(0,0, Background, screen);
if (SDL_Flip(screen) == -1){
return 1;
}
return 0;
}
void drawRow1(){
apply_surface(0, 0, Row1, Background);
}
void drawRow2(){
apply_surface(0, 0, Row2, Background);
}
void drawRow3(){
apply_surface(0, 0, Row3, Background);
}
void drawDia1(){
apply_surface(0, 0, Dia1, Background);
}
void drawDia2(){
apply_surface(0, 0, Dia2, Background);
}
|