-
Notifications
You must be signed in to change notification settings - Fork 6
/
scrolling.c
50 lines (42 loc) · 1.15 KB
/
scrolling.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
#include <stdio.h>
#include <stdlib.h>
#include <SDL/SDL.h>
#include <SDL/SDL_image.h>
#include <SDL/SDL_mixer.h>
#include <SDL/SDL_ttf.h>
#include"struct.h"
void scrolling (hero *leon,background *bckg,int co )
{
leon->heromoved=0;
switch(leon->mouvment)
{
case 1:
if (co!=2){
if ((bckg->pos_background2.x<6800)&&(leon->pos_hero2.x>=300))
bckg->pos_background2.x=bckg->pos_background2.x+5;
if (((leon->pos_hero2.x<300)||((bckg->pos_background2.x>=6800))&&(leon->pos_hero2.x<1100)))
leon->pos_hero2.x=leon->pos_hero2.x+5;
leon->heromoved=1;
}
break;
case 2:
if (co!=2){
if (bckg->pos_background2.x>0)
bckg->pos_background2.x=bckg->pos_background2.x-5;
if (((bckg->pos_background2.x!=0)&&(leon->pos_hero2.x>=150))||((bckg->pos_background2.x==0)&&(leon->pos_hero2.x=50)))
leon->pos_hero2.x=leon->pos_hero2.x-5;
leon->heromoved=2;
}
break;
case 3:
if (leon->pos_hero2.y>50){
if (bckg->pos_background2.x<6800){
leon->pos_hero2.y=leon->pos_hero2.y-20;
}
}
break;
}
if ((leon->mouvment!=3)&&(co!=10)&&(co!=2)){
leon->pos_hero2.y=leon->pos_hero2.y+5;
}
}