-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbac1.c
54 lines (40 loc) · 861 Bytes
/
bac1.c
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
#include "bac1.h"
#include <stdio.h>
#include <stdlib.h>
#include <SDL/SDL.h>
#include <SDL/SDL_image.h>
void charger_Background(Background *B)
{
B->backgroundImg = IMG_Load("/home/makki/oo/baaac.png");
}
void initBackground(Background *B)
{
B->back_Pos.x=0;
B->back_Pos.y=0;
B->back_Pos.w=700;
B->back_Pos.h=700;
B->camera.x=0;
B->camera.y=0;
B->camera.w=1800;
B->camera.h=900;
}
void blitBackground(Background *B,SDL_Surface *screen)
{
}
void freeBackground(Background *B)
{
SDL_FreeSurface(B->backgroundImg);
}
void scrol(Background *B, SDL_Surface *screen, SDL_Event * event ){
switch(event->type)
{
case SDL_KEYDOWN:
if(event->key.keysym.sym==SDLK_RIGHT){
B->camera.x+=10;}
if(event->key.keysym.sym==SDLK_LEFT){
if(B->camera.x!=0){
B->camera.x-=10;}}
}
SDL_BlitSurface(B->backgroundImg,&B->camera,screen,NULL);
SDL_Flip(screen);
}