Vous utilisez un navigateur obsolète, veuillez le mettre à jour.
Veuillez utiliser un navigateur internet moderne avec JavaScript activé pour naviguer sur OpenClassrooms.com
Une question ? Pas de panique, on va vous aider !
Ce sujet est fermé.
Bonjour je redige ce message je suis précé j'ai un petit probleme avec une structure quand je compile il me dit que ma structure Fond(SDL_Surface)
n'est pas dans une structure ou un union je ne comprend pas pourtant elle y est ? pouvais vous m'aider
erreure:
C:\Users\Admin\Desktop\ClicDefender\Game.c|14|erreur: request for member 'Fond' in something not a structure or union|
prog:
main.c
#include <stdlib.h> #include <stdio.h> #include <SDL/SDL.h> #include <SDL/SDL_image.h> #include <SDL/SDL_ttf.h> #include "Hider.h" int main(int argc, char *argv[]) { struct VariableAff Affichage; struct VariablePos Pos; SDL_Init(SDL_INIT_VIDEO); Affichage.ecran = SDL_SetVideoMode(800, 600, 32, SDL_HWSURFACE | SDL_DOUBLEBUF); Menu(&Affichage); SDL_Quit(); return EXIT_SUCCESS; }//j'auraiss du faire une fonction qui initialise tous XD
Game.c:
#include <stdlib.h> #include <stdio.h> #include <SDL/SDL.h> #include <SDL/SDL_image.h> #include <SDL/SDL_ttf.h> #include "Hider.h" int Menu(VariableAff *VariableBox) { VariablePos Position; Position.PosFond.x = 0; Position.PosFond.y = 0; VariableBox.Fond = SDL_LoadBMP("MenuDepart.bmp"); int Boucle = 1; SDL_Event event; while(Boucle) { SDL_WaitEvent(&event); switch(event.type) { case SDL_KEYDOWN: switch(event.key.keysym.sym) { case SDLK_SPACE: Boucle = 0; break; } } } return 0; }
Hider.h:
#ifndef Hide #define Hide #endif // Hide typedef struct VariableAff VariableAff; struct VariableAff { SDL_Surface *ecran; SDL_Surface *Fond; }; typedef struct VariablePos VariablePos; struct VariablePos { SDL_Rect PosFond; }; int Menu(VariableAff *VariableBox);
Salut,
ta fonction menu reçoit un pointeur. Ligne 14 tu traites la structure comme si elle était locale...
Il faut remplacer VariableBox.Fond par VariableBox->Fond.
Ta protection contre les inclusions multiples n'est pas correcte dans ton fichier Hider.h.
Bonne continuation.
Bonhomme !! | Jeu de plateforme : Prototype.
Bonhomme !! | Jeu de plateforme : Prototype.