Je crois avoir compris mais un point reste assez... obscur, dirons-nous.
J'envoie à sfWindow_GetInput un pointeur de type sfRenderWindow (qui en C n'hérite pas de sfWindow, d'où mon erreur >_<), c'est peut-être pour ça que ça ne marche pas, non ?
Je te donne le code complet afin de mieux visualiser la chose (pour la petite histoire, on doit programmer un jeu du type Choplifter dans le cadre de nos études) :
Main :
#include <stdio.h>
#include <stdlib.h>
#include <SFML/Graphics.h>
#include "map.h"
#include "helico.h"
int main()
{
sfWindowSettings Settings = {24, 8, 0};
sfVideoMode Mode = {544, 416, 32};
sfRenderWindow* App;
sfEvent Event;
// Début test
Map map;
map.app = &App;
initMapArrayTo(&map, 1);
map.tab[0][0] = 2;
map.tab[16][12] = 2;
Helico helico;
helico.app = &App;
helico.texture = sfSprite_Create();
helico.coord.x = 0;
helico.coord.y = 208;
helico.speed = 1;
// Fin test
/* Create the main window */
App = sfRenderWindow_Create(Mode, "SFML window", sfClose, Settings);
/* Start the game loop */
while (sfRenderWindow_IsOpened(App))
{
/* Process events */
while (sfRenderWindow_GetEvent(App, &Event))
{
/* Close window : exit */
if (Event.Type == sfEvtClosed)
sfRenderWindow_Close(App);
}
/* Clear the screen */
sfRenderWindow_Clear(App, sfBlack);
drawMap(&map);
drawHelico(&helico, &map);
/* Update the window */
sfRenderWindow_Display(App);
}
/* Cleanup resources */
sfRenderWindow_Destroy(App);
return EXIT_SUCCESS;
}
Helico.c :
#include "helico.h"
void drawHelico(Helico *helico, Map *map)
{
sfImage *img;
sfInput *input = sfWindow_GetInput(*(helico->app));
helico->direction = 'd';
sfBool rightKeyDown = sfInput_IsKeyDown(input, sfKeyRight),
leftKeyDown = sfInput_IsKeyDown(input, sfKeyLeft),
upKeyDown = sfInput_IsKeyDown(input, sfKeyUp),
downKeyDown = sfInput_IsKeyDown(input, sfKeyDown);
if (upKeyDown == sfTrue)
helico->coord.y -= helico->speed;
if (downKeyDown == sfTrue)
{
// Si pas en contact avec le sol
helico->coord.y += helico->speed;
}
if (sfInput_IsKeyDown(input, sfKeyRight) == sfTrue)
{
helico->direction = 'd';
//if (helico->coord.x <= MIDDLESCREEN - MIDDLEWIDTH)
helico->coord.x += helico->speed;
//else map->scrolling--;
}
if (leftKeyDown == sfTrue)
{
helico->direction = 'g';
//if (helico->coord.x >= MIDDLESCREEN - MIDDLEWIDTH)
helico->coord.x -= helico->speed;
//else map->scrolling++;
}
if (helico->direction == 'd')
img = sfImage_CreateFromFile("helico_d.png");
else if (helico->direction == 'g')
img = sfImage_CreateFromFile("helico_g.png");
sfSprite_SetImage(helico->texture, img);
sfSprite_SetPosition(helico->texture, helico->coord.x, helico->coord.y);
sfRenderWindow_DrawSprite(*(helico->app), helico->texture);
}
void shoot(Helico *helico)
{
}
void update(Helico *helico)
{
}
Helico.h :
#ifndef HELICO_H_INCLUDED
#define HELICO_H_INCLUDED
#include "struct/coord.h"
#include "map.h"
#include <SFML/Graphics.h>
#define MAX_SPEED 3
#define MAX_LIFE 3
#define MIDDLESCREEN 272
#define MIDDLEWIDTH 32
typedef struct
{
Coord coord;
int speed, life;
char direction;
sfSprite *texture;
sfRenderWindow **app;
} Helico;
void drawHelico(Helico *helico, Map *map);
void shoot(Helico *helico);
void update(Helico *helico);
#endif // HELICO_H_INCLUDED
Une idée pour reprendre la chose sans se prendre la tête entre Window et RenderWindow ?
EDIT - Résolu !
=> sfRenderWindow_GetInput
Que je suis bête parfois u_u