Skip to content
Snippets Groups Projects
Commit 5188ca59 authored by benjamin.sitbon's avatar benjamin.sitbon
Browse files

wheel_func

parent fe1396ff
No related branches found
No related tags found
No related merge requests found
...@@ -21,7 +21,6 @@ void *display_func(void *param) ...@@ -21,7 +21,6 @@ void *display_func(void *param)
{ {
int one_arm_width, one_arm_height; int one_arm_width, one_arm_height;
SDL_Window *window; SDL_Window *window;
int i;
// ------------------------- // -------------------------
// Graphic initialization // Graphic initialization
...@@ -43,45 +42,16 @@ void *display_func(void *param) ...@@ -43,45 +42,16 @@ void *display_func(void *param)
object_height=object_rect.h/9; object_height=object_rect.h/9;
while(1){
for(double a = 0; a<8.0; a +=0.1){
// ------------------------- wheel_func(a);
// example of board display:
// -------------------------
SDL_RenderCopy(renderer, one_arm_texture, NULL, &one_arm_rect);
SDL_Rect coin_rect_pos={700, 1020, coin_rect.w, coin_rect.h};
SDL_RenderCopy(renderer, coin_texture, NULL, &coin_rect_pos);
for (i=0; i<4; i++){
SDL_Rect coin_rect_pos={700, 400-10*i, coin_rect.w, coin_rect.h};
SDL_RenderCopy(renderer, coin_texture, NULL, &coin_rect_pos);
} }
}
SDL_Rect src_rect, dst_rect=object_rect;
dst_rect.h=object_height*1.5; // display 1.5 object on screen for a wheel
src_rect=dst_rect;
src_rect.x=0;
// src_rect.y is positionned here on the 2nd object of objects.png
src_rect.y=object_height;
dst_rect.x=85;
dst_rect.y=410-object_height/2; // setup the coord. of the icon in the global renderer
SDL_RenderCopy(renderer, objects_texture, &src_rect, &dst_rect);
// src_rect.y is positionned here on the 2nd object of objects.png
src_rect.y=object_height;
dst_rect.x=190;
dst_rect.y=410-object_height/2; // setup the coord. of the icon in the global renderer
SDL_RenderCopy(renderer, objects_texture, &src_rect, &dst_rect);
// src_rect.y is positionned here on the 2nd object of objects.png
src_rect.y=object_height;
dst_rect.x=295;
dst_rect.y=410-object_height/2; // setup the coord. of the icon in the global renderer
SDL_RenderCopy(renderer, objects_texture, &src_rect, &dst_rect);
SDL_RenderPresent(renderer);
// ------------------------- // -------------------------
// managing events: // managing events:
...@@ -127,3 +97,40 @@ void *display_func(void *param) ...@@ -127,3 +97,40 @@ void *display_func(void *param)
SDL_Quit(); SDL_Quit();
return NULL; return NULL;
} }
int wheel_func(double index){
// -------------------------
// example of board display:
// -------------------------
SDL_RenderCopy(renderer, one_arm_texture, NULL, &one_arm_rect);
SDL_Rect coin_rect_pos={700, 1020, coin_rect.w, coin_rect.h};
SDL_RenderCopy(renderer, coin_texture, NULL, &coin_rect_pos);
for (int i=0; i<4; i++){
SDL_Rect coin_rect_pos={700, 400-10*i, coin_rect.w, coin_rect.h};
SDL_RenderCopy(renderer, coin_texture, NULL, &coin_rect_pos);
}
SDL_Rect src_rect, dst_rect=object_rect;
dst_rect.h=object_height*1.5; // display 1.5 object on screen for a wheel
src_rect=dst_rect;
src_rect.x=0;
for(int i=0; i<3; i++){
// src_rect.y is positionned here on the 2nd object of objects.png
src_rect.y=object_height*index;
dst_rect.x=85 + i*104 + 1;
dst_rect.y=410-object_height/2; // setup the coord. of the icon in the global renderer
SDL_RenderCopy(renderer, objects_texture, &src_rect, &dst_rect);
}
SDL_RenderPresent(renderer);
sleep(0.1);
return 0;
}
#ifndef DISPLAY_H #ifndef DISPLAY_H
#define DISPLAY_H #define DISPLAY_H
#include <time.h>
void *display_func(void *param); void *display_func(void *param);
int wheel_func(double index);
// height of one single object // height of one single object
extern int object_height; // global for convenience extern int object_height; // global for convenience
......
No preview for this file type
No preview for this file type
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "one_armed_bandit.h" #include "one_armed_bandit.h"
int main() int main()
{ {
display_func(NULL); display_func(NULL);
......
No preview for this file type
No preview for this file type
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment