Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
Shooter
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TARDIEU Loic
Shooter
Commits
fbb66c47
Commit
fbb66c47
authored
6 years ago
by
FOURREAUX Mathias
Browse files
Options
Downloads
Patches
Plain Diff
creation niveau fichier
parent
93a2ab6f
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
image.c
+15
-5
15 additions, 5 deletions
image.c
image.h
+1
-1
1 addition, 1 deletion
image.h
listeR.c
+63
-31
63 additions, 31 deletions
listeR.c
listeR.h
+1
-1
1 addition, 1 deletion
listeR.h
main.c
+41
-1
41 additions, 1 deletion
main.c
with
121 additions
and
39 deletions
image.c
+
15
−
5
View file @
fbb66c47
...
@@ -12,7 +12,8 @@ SDL_Texture* charger_image(const char* cheminFichier, SDL_Renderer* renderer, in
...
@@ -12,7 +12,8 @@ SDL_Texture* charger_image(const char* cheminFichier, SDL_Renderer* renderer, in
return
image
;
return
image
;
}
}
void
afficher_niveau
(
int
*
tab
,
SDL_Renderer
*
renderer
,
SDL_Texture
**
spriteMap
,
int
xCamera
,
int
yCamera
){
void
afficher_niveau
(
char
*
tab
,
SDL_Renderer
*
renderer
,
SDL_Texture
**
spriteMap
,
int
xCamera
,
int
yCamera
){
SDL_Rect
destrect
;
SDL_Rect
destrect
;
destrect
.
h
=
50
;
destrect
.
h
=
50
;
destrect
.
w
=
50
;
destrect
.
w
=
50
;
...
@@ -21,11 +22,20 @@ void afficher_niveau(int *tab, SDL_Renderer *renderer, SDL_Texture **spriteMap,
...
@@ -21,11 +22,20 @@ void afficher_niveau(int *tab, SDL_Renderer *renderer, SDL_Texture **spriteMap,
destrect
.
x
=
i
*
50
-
xCamera
;
destrect
.
x
=
i
*
50
-
xCamera
;
destrect
.
y
=
j
*
50
-
yCamera
;
destrect
.
y
=
j
*
50
-
yCamera
;
SDL_RenderCopy
(
renderer
,
spriteMap
[
0
],
NULL
,
&
destrect
);
SDL_RenderCopy
(
renderer
,
spriteMap
[
0
],
NULL
,
&
destrect
);
for
(
int
k
=
1
;
k
<
9
;
k
++
){
if
(
tab
[
30
*
j
+
i
]
==
k
){
switch
(
tab
[
30
*
j
+
i
]){
SDL_RenderCopy
(
renderer
,
spriteMap
[
k
],
NULL
,
&
destrect
);
}
case
'H'
:
SDL_RenderCopy
(
renderer
,
spriteMap
[
1
],
NULL
,
&
destrect
);
break
;
case
'Q'
:
break
;
case
'V'
:
SDL_RenderCopy
(
renderer
,
spriteMap
[
3
],
NULL
,
&
destrect
);
break
;
}
}
}
}
}
}
return
;
return
;
...
...
This diff is collapsed.
Click to expand it.
image.h
+
1
−
1
View file @
fbb66c47
...
@@ -2,4 +2,4 @@
...
@@ -2,4 +2,4 @@
#include
<SDL2/SDL_image.h>
#include
<SDL2/SDL_image.h>
SDL_Texture
*
charger_image
(
const
char
*
fichier
,
SDL_Renderer
*
renderer
,
int
r
,
int
g
,
int
b
);
SDL_Texture
*
charger_image
(
const
char
*
fichier
,
SDL_Renderer
*
renderer
,
int
r
,
int
g
,
int
b
);
void
afficher_niveau
(
int
*
tab
,
SDL_Renderer
*
renderer
,
SDL_Texture
**
spriteMap
,
int
xCamera
,
int
yCamera
);
void
afficher_niveau
(
char
*
tab
,
SDL_Renderer
*
renderer
,
SDL_Texture
**
spriteMap
,
int
xCamera
,
int
yCamera
);
This diff is collapsed.
Click to expand it.
listeR.c
+
63
−
31
View file @
fbb66c47
#include
"listeR.h"
#include
"listeR.h"
#include
<stdio.h>
void
cons_listeR
(
ListeR
*
L
,
SDL_Rect
data
){
void
cons_listeR
(
ListeR
*
L
,
SDL_Rect
data
){
...
@@ -10,73 +11,104 @@ void cons_listeR(ListeR *L, SDL_Rect data){
...
@@ -10,73 +11,104 @@ void cons_listeR(ListeR *L, SDL_Rect data){
}
}
void
charger_niveau
(
int
*
tab
,
ListeR
*
L
){
void
charger_niveau
(
char
*
tab
,
ListeR
*
L
){
//on met toutes les case 0 pour dire que tout est du sol (provisoire)
for
(
int
j
=
0
;
j
<
30
;
j
++
){
for
(
int
i
=
0
;
i
<
30
;
i
++
){
tab
[
30
*
j
+
i
]
=
0
;
}
}
//ici lire fichier et remplacer les cases qu'il faut par 1-8 pour mettre des murs
FILE
*
fichier
=
NULL
;
//je mets a en attendant pour afficher des murs sur le bord de la map
fichier
=
fopen
(
"map.txt"
,
"r"
);
for
(
int
j
=
0
;
j
<
30
;
j
++
){
int
caractereActuel
;
tab
[
30
*
j
+
0
]
=
3
;
if
(
fichier
!=
NULL
){
tab
[
30
*
j
+
29
]
=
4
;
tab
[
30
*
0
+
j
]
=
1
;
for
(
int
j
=
0
;
j
<
33
;
j
++
){
tab
[
30
*
29
+
j
]
=
2
;
for
(
int
i
=
0
;
i
<
31
;
i
++
){
if
(
j
<
31
){
if
(
i
==
0
){
//caractereActuel = fgetc(fichier);
caractereActuel
=
fgetc
(
fichier
);
char
tmp
=
caractereActuel
;
// caractereActuel = fgetc(fichier);
caractereActuel
=
tmp
;
tab
[
30
*
j
+
i
]
=
caractereActuel
;
printf
(
"%c"
,
tab
[
30
*
j
+
i
]);
}
else
{
caractereActuel
=
fgetc
(
fichier
);
tab
[
30
*
j
+
i
]
=
caractereActuel
;
printf
(
"%c"
,
tab
[
30
*
j
+
i
]);
}
}
}
}
fclose
(
fichier
);
}
}
tab
[
30
*
0
+
0
]
=
5
;
tab
[
30
*
0
+
29
]
=
6
;
tab
[
30
*
29
+
0
]
=
7
;
tab
[
30
*
29
+
29
]
=
8
;
//Remplir la liste de murs
//Remplir la liste de murs
SDL_Rect
rect
;
SDL_Rect
rect
;
for
(
int
j
=
0
;
j
<
30
;
j
++
){
for
(
int
j
=
0
;
j
<
30
;
j
++
){
for
(
int
i
=
0
;
i
<
30
;
i
++
){
for
(
int
i
=
0
;
i
<
30
;
i
++
){
switch
(
tab
[
30
*
j
+
i
]){
switch
(
tab
[
30
*
j
+
i
]){
case
0
:
case
'S'
:
break
;
break
;
case
1
:
case
'H'
:
rect
.
x
=
i
*
50
;
rect
.
x
=
i
*
50
;
rect
.
y
=
j
*
50
;
rect
.
y
=
j
*
50
;
rect
.
h
=
25
;
rect
.
h
=
25
;
rect
.
w
=
50
;
rect
.
w
=
50
;
cons_listeR
(
L
,
rect
);
cons_listeR
(
L
,
rect
);
//tab[30*j+i] = 1;
break
;
case
'V'
:
rect
.
x
=
i
*
50
;
rect
.
y
=
j
*
50
;
rect
.
h
=
50
;
rect
.
w
=
25
;
cons_listeR
(
L
,
rect
);
//tab[30*j+i] = 3;
break
;
break
;
case
2
:
/**
case '2':
rect.x = i * 50;
rect.x = i * 50;
rect.y = j * 50 + 25;
rect.y = j * 50 + 25;
rect.h = 25;
rect.h = 25;
rect.w = 50;
rect.w = 50;
cons_listeR
(
L
,
rect
);
L =
cons_listeR(L, rect);
break;
break;
case
3
:
case
'3'
:
rect.x = i * 50;
rect.x = i * 50;
rect.y = j * 50;
rect.y = j * 50;
rect.h = 50;
rect.h = 50;
rect.w = 25;
rect.w = 25;
cons_listeR
(
L
,
rect
);
L =
cons_listeR(L, rect);
break;
break;
case
4
:
case
'4'
:
rect.x = i * 50 + 25;
rect.x = i * 50 + 25;
rect.y = j * 50;
rect.y = j * 50;
rect.h = 50;
rect.h = 50;
rect.w = 25;
rect.w = 25;
cons_listeR
(
L
,
rect
);
L =
cons_listeR(L, rect);
break;
break;
case
5
:
case
'5'
:
case
6
:
case
'6'
:
case
7
:
case
'7'
:
case
8
:
case
'8'
:
rect.x = i * 50;
rect.x = i * 50;
rect.y = j * 50;
rect.y = j * 50;
rect.h = 50;
rect.h = 50;
rect.w = 50;
rect.w = 50;
cons_listeR
(
L
,
rect
);
L = cons_listeR(L, rect);
break;
case '0':
break;
break;
*/
}
}
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
listeR.h
+
1
−
1
View file @
fbb66c47
...
@@ -11,5 +11,5 @@ struct s_ListeR
...
@@ -11,5 +11,5 @@ struct s_ListeR
void
cons_listeR
(
ListeR
*
L
,
SDL_Rect
data
);
void
cons_listeR
(
ListeR
*
L
,
SDL_Rect
data
);
void
charger_niveau
(
int
*
tab
,
ListeR
*
L
);
void
charger_niveau
(
char
*
tab
,
ListeR
*
L
);
bool
detecter_collision_murs
(
ListeR
L
,
SDL_Rect
rect
,
int
xCamera
,
int
yCamera
);
bool
detecter_collision_murs
(
ListeR
L
,
SDL_Rect
rect
,
int
xCamera
,
int
yCamera
);
This diff is collapsed.
Click to expand it.
main.c
+
41
−
1
View file @
fbb66c47
...
@@ -12,7 +12,8 @@ int main(int argc, char *argv[])
...
@@ -12,7 +12,8 @@ int main(int argc, char *argv[])
SDL_Texture
*
tmp
,
*
balleSprite
,
*
sprites
[
4
],
*
spritesMap
[
9
];
SDL_Texture
*
tmp
,
*
balleSprite
,
*
sprites
[
4
],
*
spritesMap
[
9
];
float
mouseX
,
mouseY
;
float
mouseX
,
mouseY
;
int
vitesse
,
tempsActuel
,
tempsPrecedent
,
tempsActuelTir
,
tempsActuelAnim
,
tempsPrecedentAnim
,
int
vitesse
,
tempsActuel
,
tempsPrecedent
,
tempsActuelTir
,
tempsActuelAnim
,
tempsPrecedentAnim
,
xCamera
,
yCamera
,
dxCamera
,
dyCamera
,
map
[
30
][
30
];
;
xCamera
,
yCamera
,
dxCamera
,
dyCamera
;
char
map
[
32
][
30
];
;
ListeB
ballesTirees
;
ListeB
ballesTirees
;
ListeP
persosListe
;
ListeP
persosListe
;
ListeR
mursListe
;
ListeR
mursListe
;
...
@@ -73,6 +74,45 @@ int main(int argc, char *argv[])
...
@@ -73,6 +74,45 @@ int main(int argc, char *argv[])
tmp
=
charger_image
(
"sprites/effets/blood/blood_hitv3.png"
,
ecran
,
0
,
0
,
-
1
);
tmp
=
charger_image
(
"sprites/effets/blood/blood_hitv3.png"
,
ecran
,
0
,
0
,
-
1
);
sprites
[
3
]
=
tmp
;
sprites
[
3
]
=
tmp
;
/**
FILE* fichier = NULL;
fichier = fopen("map.txt", "r");
int caractereActuel;
if (fichier != NULL){
for(int j = 0; j < 33; j++){
for(int i = 0; i < 31; i++){
if(j < 31){
if(i==0){
//caractereActuel = fgetc(fichier);
caractereActuel = fgetc(fichier);
char tmp = caractereActuel;
// caractereActuel = fgetc(fichier);
caractereActuel = tmp;
map[j][i] = caractereActuel;
printf("%c", map[j][i]);
}
else{
caractereActuel = fgetc(fichier);
map[j][i] = caractereActuel;
printf("%c", map[j][i]);
}
}
}
}
fclose(fichier);
}
*/
//Sons
//Sons
musique
=
NULL
;
musique
=
NULL
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment