Skip to content
Snippets Groups Projects
Commit 83be1695 authored by Le-Bao-Tin.Ha's avatar Le-Bao-Tin.Ha
Browse files

Ameliorer -> version 0.8

parent ba191e70
No related branches found
No related tags found
4 merge requests!8Modele,!7Modele,!6Modele,!5Modele Version 1
......@@ -13,10 +13,10 @@
#include "map.h"
#include "DS.h"
int testposition(Personnage * pers, Prof * prof, DS * exam, MAP * map); // return 0 if nothing, 1 if wall, 2 if exam, 3 if prof, 4 if bounds
int testposition(Personnage * pers, Prof * prof, DS * exam, MAP * map,int ,int ,int, int); // return 0 if nothing, 1 if wall, 2 if exam, 3 if prof, 4 if bounds
int testboundscol(Personnage * pers);
int testprofcol(Personnage * pers, Prof * prof);
int testmapcol(Personnage * pers, MAP * map, DS * exam);
int testprofcol(Personnage * pers, Prof * prof,int x_A,int y_A, int x_B, int y_B);
int testmapcol(Personnage * pers, MAP * map, DS * exam,int x_A,int y_A, int x_B, int y_B);
#endif /*INSAGAME_GAME_H*/
......@@ -12,12 +12,41 @@
#define WINDOW_WIDTH (700)
#define WINDOW_HEIGHT (700)
int testposition(Personnage * pers, Prof * prof, DS * exam, MAP * map){
int testposition(Personnage * pers, Prof * prof, DS * exam, MAP * map, int up,int down, int left, int right){
int x_A=0,x_B=0,y_A=0,y_B=0;
//calculer les points
if (up && !down) {
x_A= pers->x_pers;
y_A = pers->y_pers;
x_B = pers->x_pers + pers->larg_pers;
y_B = pers->y_pers;
}
if (down && !up) {
x_A= pers->x_pers;
y_A = pers->y_pers + pers->long_pers;
x_B = pers->x_pers + pers->larg_pers;
y_B = pers->y_pers + pers->long_pers;
}
if (left && !right) {
x_A= pers->x_pers;
y_A = pers->y_pers;
x_B= pers->x_pers;
y_B = pers->y_pers + pers->long_pers;
}
if (right && !left) {
x_A = pers->x_pers + pers->larg_pers;
y_A = pers->y_pers;
x_B = pers->x_pers + pers->larg_pers;
y_B = pers->y_pers + pers->long_pers;
}
//test variables
int testbounds = testboundscol(pers); ;
int testprof = testprofcol(pers,prof);
int testmap = testmapcol(pers,map,exam); // = 0 if nothing , 1 if wall, 2 if exam
int testprof = testprofcol(pers,prof,x_A,y_A,x_B,y_B);
//test bounds collision
......@@ -30,7 +59,7 @@ int testposition(Personnage * pers, Prof * prof, DS * exam, MAP * map){
//return the map test position
return testmapcol(pers,map,exam);
return testmapcol(pers,map,exam,x_A,y_A,x_B,y_B); // = 0 if nothing , 1 if wall, 2 if exam
}
......@@ -41,33 +70,43 @@ int testboundscol(Personnage * pers){
return 0;
}
int testprofcol(Personnage * pers, Prof * prof){
//calculer milieu
int x_milieu = pers->x_pers + (pers->larg_pers/2);
int y_milieu = pers->y_pers + (pers->long_pers/2);
int testprofcol(Personnage * pers, Prof * prof,int x_A,int y_A, int x_B, int y_B){
//test position vs prof
if (( x_milieu > prof->x_prof) && (x_milieu<prof->x_prof+prof->larg_prof)) {
if (( y_milieu > prof->y_prof) && (y_milieu < prof->y_prof + prof->long_prof)) {
if (( x_A > prof->x_prof) && (x_A<prof->x_prof+prof->larg_prof)) {
if (( y_A > prof->y_prof) && (y_A < prof->y_prof + prof->long_prof)) {
return 1;
}
}
if (( x_B > prof->x_prof) && (x_B<prof->x_prof+prof->larg_prof)) {
if (( y_B > prof->y_prof) && (y_B < prof->y_prof + prof->long_prof)) {
return 1;
}
}
return 0;
}
int testmapcol(Personnage * pers, MAP * map, DS * exam ){
//calculer milieu
int x_milieu = pers->x_pers + (pers->larg_pers/2);
int y_milieu = pers->y_pers + (pers->long_pers/2);
int testmapcol(Personnage * pers, MAP * map, DS * exam ,int x_A,int y_A, int x_B, int y_B){
if (map->functional[y_milieu][x_milieu] == 2){ //if zone exams
if (map->functional[y_A][x_A] == 2){ //if zone exams
//test exam collision
if ((x_milieu > exam->x_DS) && (x_milieu < exam->x_DS+exam->larg_DS)) {
if ((x_A > exam->x_DS) && (x_A < exam->x_DS+exam->larg_DS)) {
return 2;
}
}
else if (map->functional[y_milieu][x_milieu] == 1){ //if zone wall
else if (map->functional[y_A][x_A] == 1){ //if zone wall
return 1;
}
if (map->functional[y_B][x_B] == 2){ //if zone exams
//test exam collision
if ((x_B > exam->x_DS) && (x_B < exam->x_DS+exam->larg_DS)) {
return 2;
}
}
else if (map->functional[y_B][x_B] == 1){ //if zone wall
return 1;
}
return 0; //if nothing
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment