Accueil > > > JEU : ATTRAPE MOI !
JEU : ATTRAPE MOI !
Information sur la source
Description
Un jeu sympathique (SDL), une map est créée, à certains endroits sont disposés des arbustes. Il y a un petit fantôme rouge qui démarre dans un coin de la MAP, et dans l'autre coin, un petit chevalier avec une épée et un bouclier. Chaque joueur incarne un personnage et peu se déplacer sur la map selon un système de cases. Le but pour le chevalier, c'est d'attraper le fantôme, et le but du fantôme c'est de lui échapper... Pour celà, les deux joueurs disposes chacun de petits pouvoir, le fantôme passe "sous" les arbres, tandis que le chevalier passe "SUR" les arbres... Le fantôme peut se dédoubler, le chevalier lui peu poser des mines, se transforer en arbre lui même ou bien encore inverser la map... (3 semaines de programmation en C et 2 jour d'apprentissage à la SDL)
Source
- #include <stdlib.h>
- #include <stdio.h>
- #include <SDL/SDL.h>
- #include <FMOD/fmod.h>
-
-
-
- #define TAILLE_BLOC 48
- # define NB_BLOCS_HAUTEUR 14
- # define NB_BLOCS_LARGEUR 18
- #define LARGEUR_FENETRE TAILLE_BLOC * NB_BLOCS_LARGEUR
- #define HAUTEUR_FENETRE TAILLE_BLOC * NB_BLOCS_HAUTEUR
- enum {VIDE, ARBRE, DYNAMITE};
-
-
-
- int main(int argc, char *argv[])
- {
- long i;
- long j = 0;
- int carte[NB_BLOCS_LARGEUR][NB_BLOCS_HAUTEUR] = {VIDE, VIDE, ARBRE, ARBRE, VIDE, ARBRE, ARBRE, VIDE, VIDE, ARBRE, ARBRE, VIDE, VIDE, VIDE, ARBRE, ARBRE, ARBRE, ARBRE, VIDE, VIDE, VIDE, ARBRE, ARBRE, VIDE, VIDE, VIDE, VIDE, VIDE, ARBRE, ARBRE, ARBRE, ARBRE, VIDE, VIDE, VIDE, ARBRE, ARBRE, VIDE, VIDE, ARBRE, ARBRE, VIDE, VIDE, VIDE, ARBRE, ARBRE, ARBRE, ARBRE, VIDE, VIDE, VIDE, ARBRE, ARBRE, VIDE, VIDE, ARBRE, ARBRE, VIDE, VIDE, VIDE, ARBRE, ARBRE, ARBRE, ARBRE, VIDE, VIDE, VIDE, ARBRE, ARBRE, VIDE, VIDE, ARBRE, ARBRE, VIDE, VIDE, VIDE, ARBRE, ARBRE, ARBRE, VIDE, VIDE, VIDE, VIDE, ARBRE, ARBRE, ARBRE, ARBRE, VIDE, ARBRE, ARBRE, ARBRE, VIDE, VIDE, ARBRE, ARBRE, VIDE, VIDE, VIDE, ARBRE, ARBRE, ARBRE, ARBRE, VIDE, VIDE, VIDE, VIDE, ARBRE, ARBRE, ARBRE, ARBRE, VIDE, ARBRE, VIDE, VIDE, ARBRE, ARBRE, VIDE, VIDE, VIDE, ARBRE, ARBRE, ARBRE, ARBRE, VIDE, VIDE, ARBRE, ARBRE, ARBRE, VIDE, VIDE, VIDE, VIDE, VIDE, VIDE, VIDE, VIDE, VIDE, VIDE, VIDE, VIDE, VIDE, VIDE, VIDE, VIDE, ARBRE, VIDE, VIDE, VIDE,VIDE, ARBRE, ARBRE, ARBRE, ARBRE, VIDE, ARBRE, ARBRE, ARBRE, VIDE, VIDE, ARBRE, ARBRE, VIDE, VIDE, ARBRE, ARBRE, ARBRE, VIDE, VIDE, ARBRE, ARBRE, VIDE, VIDE, VIDE, VIDE, VIDE, ARBRE, VIDE, VIDE, VIDE, ARBRE, ARBRE, ARBRE, VIDE, VIDE, ARBRE, ARBRE, VIDE, VIDE, VIDE, VIDE, VIDE, ARBRE, VIDE, VIDE, VIDE, ARBRE, ARBRE, ARBRE, VIDE, VIDE, ARBRE, ARBRE, VIDE, VIDE, VIDE, VIDE, VIDE, ARBRE, VIDE, VIDE};
- int fin = 0;
- int choix = 0;
- int transphormation = 7;
- int bouger = 20;
- int inverser = 2;
- int coupFantome = 0;
- int dedoublement = 2;
- int bombeEnPlace = 0;
-
-
- SDL_Rect position;
- SDL_Rect positionPersonnage;
- SDL_Rect positionFantome;
- SDL_Rect positionLeurre;
- SDL_Rect positionDynamite;
-
-
- positionFantome.x = 0;
- positionFantome.y = 0;
-
- positionDynamite.x = 1555;
- positionDynamite.y = 1555;
-
- SDL_Rect positionFin;
- positionFin.x = (LARGEUR_FENETRE/2) - (529/2);
- positionFin.y = (HAUTEUR_FENETRE/2) - (73/2);
-
-
- int continuer = 0;
- SDL_Event event;
-
- SDL_Surface *ecran = NULL;
- ecran = SDL_SetVideoMode(LARGEUR_FENETRE, HAUTEUR_FENETRE, 32, SDL_HWSURFACE);
- SDL_WM_SetIcon(SDL_LoadBMP("maison.bmp"), NULL);
- SDL_WM_SetCaption("Attrape moi si tu peux !", NULL);
-
- SDL_Surface *arbre = NULL;
- SDL_Surface *personnage = NULL;
- SDL_Surface *fantome = NULL;
- SDL_Surface *fantomeHAUT = NULL;
- SDL_Surface *fantomeBAS = NULL;
- SDL_Surface *fantomeGAUCHE = NULL;
- SDL_Surface *fantomeDROITE = NULL;
- SDL_Surface *Fin = NULL;
- SDL_Surface *dynamite = NULL;
- SDL_Surface *commandes = NULL;
-
- arbre = SDL_LoadBMP("arbre.bmp");
- personnage = SDL_LoadBMP("personnage.bmp");
- fantomeHAUT = SDL_LoadBMP("fantomeHAUT.bmp");
- fantomeBAS = SDL_LoadBMP("fantomeBAS.bmp");
- fantomeGAUCHE = SDL_LoadBMP("fantomeGAUCHE.bmp");
- fantomeDROITE = SDL_LoadBMP("fantomeDROITE.bmp");
- Fin = SDL_LoadBMP("fin.bmp");
- fantome = fantomeDROITE;
- dynamite = SDL_LoadBMP("dynamite.bmp");
- commandes = SDL_LoadBMP("commandes.bmp");
-
-
-
-
-
- SDL_Init(SDL_INIT_VIDEO | SDL_DOUBLEBUF | SDL_INIT_AUDIO);
- FSOUND_Init(44100, 32, 0);
- FSOUND_STREAM *musique = NULL;
- musique = FSOUND_Stream_Open("musique.mp3", 0, 0, 0);
- FSOUND_Stream_Play(FSOUND_FREE, musique);
- FSOUND_SetVolume(FSOUND_ALL, 120);
-
-
-
-
-
-
-
-
-
-
-
- positionPersonnage.x = NB_BLOCS_LARGEUR*TAILLE_BLOC - TAILLE_BLOC;
- positionPersonnage.y = NB_BLOCS_HAUTEUR*TAILLE_BLOC - TAILLE_BLOC;
-
- while (!continuer)
- {
-
- SDL_WaitEvent (&event);
-
- switch (event.type)
- {
- case SDL_QUIT:
- continuer = 1;
- break;
- case SDL_KEYDOWN:
- continuer = 1;
- break;
- }
- SDL_BlitSurface(commandes, NULL, ecran, &positionFantome);
- SDL_Flip(ecran);
- }
-
-
-
-
- while(continuer)
- {
- coupFantome--;
- SDL_WaitEvent (&event);
-
- switch (event.type)
- {
- case SDL_QUIT:
- continuer = 0;
- break;
- case SDL_KEYDOWN:
- switch(event.key.keysym.sym)
- {
-
- //COMMANDES DU JEU
-
-
-
-
- case SDLK_SPACE:
- ecran = SDL_SetVideoMode(LARGEUR_FENETRE, HAUTEUR_FENETRE, 32, SDL_HWSURFACE | SDL_FULLSCREEN);
- break;
-
- case SDLK_ESCAPE:
- ecran = SDL_SetVideoMode(LARGEUR_FENETRE, HAUTEUR_FENETRE, 32, SDL_HWSURFACE );
- break;
-
-
-
-
- case SDLK_DELETE:
- if (dedoublement)
- {
- coupFantome = 60;
- dedoublement--;
- }
- break;
-
-
- case SDLK_UP:
- fantome = fantomeHAUT;
- positionFantome.y = positionFantome.y-TAILLE_BLOC;
- break;
-
-
- case SDLK_DOWN:
- fantome = fantomeBAS;
- if(positionFantome.y < HAUTEUR_FENETRE - TAILLE_BLOC)
- positionFantome.y = positionFantome.y+TAILLE_BLOC;
- break;
-
- case SDLK_RIGHT:
- fantome = fantomeDROITE;
- if(positionFantome.x < LARGEUR_FENETRE - TAILLE_BLOC)
- positionFantome.x = positionFantome.x+TAILLE_BLOC;
- break;
-
-
- case SDLK_LEFT:
- fantome = fantomeGAUCHE;
- positionFantome.x = positionFantome.x-TAILLE_BLOC;
- break;
-
- case SDLK_q:
- transphormation = transphormation - 1;
- if (transphormation > 0)
- {
- if (personnage ==arbre)
- personnage = SDL_LoadBMP("personnage.bmp");
-
- else
- {
- personnage = arbre;
- }
- }
-
- break;
-
-
- case SDLK_TAB:
- if(inverser)
- {
-
- for (j = 0; j < NB_BLOCS_HAUTEUR; j++)
- {
- for (i = 0; i < NB_BLOCS_LARGEUR; i++)
- {
-
-
- position.x = i*TAILLE_BLOC;
- position.y = j*TAILLE_BLOC;
-
-
-
- if( carte[i][j] == ARBRE )
- {
- carte[i][j] = VIDE;
- }
- else if( carte[i][j] == VIDE )
- {
- carte[i][j] = ARBRE;
- }
-
- }
- }
- inverser--;
- }
- break;
-
- case SDLK_e:
- bombeEnPlace++;
- positionDynamite.x = positionPersonnage.x;
- positionDynamite.y = positionPersonnage.y;
- break;
-
-
-
-
- case SDLK_w:
- if (personnage ==arbre)
- bouger--;
- if(!bouger)
- {personnage = SDL_LoadBMP("personnage.bmp");
- bouger = 15;
- }
-
- positionPersonnage.y = positionPersonnage.y-TAILLE_BLOC;
- break;
-
- case SDLK_s:
- if (personnage ==arbre)
- bouger--;
- if(!bouger)
- {personnage = SDL_LoadBMP("personnage.bmp");
- bouger = 15;
- }
-
- if(positionPersonnage.y < HAUTEUR_FENETRE - TAILLE_BLOC)
- positionPersonnage.y = positionPersonnage.y+TAILLE_BLOC;
- break;
-
- case SDLK_d:
- if (personnage ==arbre)
- bouger--;
- if(!bouger)
- {personnage = SDL_LoadBMP("personnage.bmp");
- bouger = 15;
- }
-
- if(positionPersonnage.x < LARGEUR_FENETRE - TAILLE_BLOC)
- positionPersonnage.x = positionPersonnage.x+TAILLE_BLOC;
- break;
-
- case SDLK_a:
- if (personnage ==arbre)
- bouger--;
- if(!bouger)
- {personnage = SDL_LoadBMP("personnage.bmp");
- bouger = 15;
- }
-
- positionPersonnage.x = positionPersonnage.x-TAILLE_BLOC;
- break;
- }
- break;
- }
-
- positionLeurre.x = positionFantome.x + TAILLE_BLOC + TAILLE_BLOC;
- positionLeurre.y = positionFantome.y + TAILLE_BLOC;
-
-
-
-
- SDL_FillRect(ecran, NULL, SDL_MapRGB(ecran->format, 255, 255, 255));
- SDL_BlitSurface(personnage, NULL, ecran, &positionPersonnage);
- SDL_BlitSurface(dynamite, NULL, ecran, &positionDynamite);
- SDL_BlitSurface(fantome, NULL, ecran, &positionFantome);
- if (coupFantome >0)
- SDL_BlitSurface(fantome, NULL, ecran, &positionLeurre);
-
-
-
-
-
- for (j = 0; j < NB_BLOCS_HAUTEUR; j++)
- {
- for (i = 0; i < NB_BLOCS_LARGEUR; i++)
- {
- position.x = i*TAILLE_BLOC;
- position.y = j*TAILLE_BLOC;
-
-
- if (carte[j][i] == ARBRE)
- {
- SDL_BlitSurface(arbre, NULL, ecran, &position);
- }
-
-
- }
- }
-
-
-
- SDL_BlitSurface(dynamite, NULL, ecran, &positionDynamite);
- SDL_BlitSurface(personnage, NULL, ecran, &positionPersonnage);
-
-
- SDL_Flip(ecran);
-
- if((positionLeurre.y == positionPersonnage.y && positionLeurre.x == positionPersonnage.x) || (positionLeurre.y == positionDynamite.y && positionLeurre.x == positionDynamite.x))
- {
- coupFantome = 0;
- positionDynamite.x = 2000;
- }
-
-
- if ((positionFantome.y == positionPersonnage.y && positionFantome.x == positionPersonnage.x) || (positionDynamite.y == positionFantome.y && positionDynamite.x == positionFantome.x))
- {
- for (i=0; i < 500; i++)
- {
- SDL_FillRect(ecran, NULL, SDL_MapRGB(ecran->format, 255, 255, 255));
- SDL_BlitSurface(Fin, NULL, ecran, &positionFin);
- SDL_Flip(ecran);
- positionPersonnage.x = NB_BLOCS_LARGEUR*TAILLE_BLOC - TAILLE_BLOC;
- positionPersonnage.y = NB_BLOCS_HAUTEUR*TAILLE_BLOC - TAILLE_BLOC;
- positionFantome.x = 0;
- positionFantome.y = 0;
-
- }
- transphormation = 7;
- bouger = 15;
- inverser = 4;
- coupFantome = 0;
- dedoublement = 1;
- positionDynamite.x = 1500;
- }
- }
-
-
- //liberation de la memoire a faire ou pas (je viens de le voir et j'ai fait ça il y a longtemps)
-
- SDL_Quit();
- FSOUND_Close();
- return EXIT_SUCCESS;
- }
#include <stdlib.h>
#include <stdio.h>
#include <SDL/SDL.h>
#include <FMOD/fmod.h>
#define TAILLE_BLOC 48
# define NB_BLOCS_HAUTEUR 14
# define NB_BLOCS_LARGEUR 18
#define LARGEUR_FENETRE TAILLE_BLOC * NB_BLOCS_LARGEUR
#define HAUTEUR_FENETRE TAILLE_BLOC * NB_BLOCS_HAUTEUR
enum {VIDE, ARBRE, DYNAMITE};
int main(int argc, char *argv[])
{
long i;
long j = 0;
int carte[NB_BLOCS_LARGEUR][NB_BLOCS_HAUTEUR] = {VIDE, VIDE, ARBRE, ARBRE, VIDE, ARBRE, ARBRE, VIDE, VIDE, ARBRE, ARBRE, VIDE, VIDE, VIDE, ARBRE, ARBRE, ARBRE, ARBRE, VIDE, VIDE, VIDE, ARBRE, ARBRE, VIDE, VIDE, VIDE, VIDE, VIDE, ARBRE, ARBRE, ARBRE, ARBRE, VIDE, VIDE, VIDE, ARBRE, ARBRE, VIDE, VIDE, ARBRE, ARBRE, VIDE, VIDE, VIDE, ARBRE, ARBRE, ARBRE, ARBRE, VIDE, VIDE, VIDE, ARBRE, ARBRE, VIDE, VIDE, ARBRE, ARBRE, VIDE, VIDE, VIDE, ARBRE, ARBRE, ARBRE, ARBRE, VIDE, VIDE, VIDE, ARBRE, ARBRE, VIDE, VIDE, ARBRE, ARBRE, VIDE, VIDE, VIDE, ARBRE, ARBRE, ARBRE, VIDE, VIDE, VIDE, VIDE, ARBRE, ARBRE, ARBRE, ARBRE, VIDE, ARBRE, ARBRE, ARBRE, VIDE, VIDE, ARBRE, ARBRE, VIDE, VIDE, VIDE, ARBRE, ARBRE, ARBRE, ARBRE, VIDE, VIDE, VIDE, VIDE, ARBRE, ARBRE, ARBRE, ARBRE, VIDE, ARBRE, VIDE, VIDE, ARBRE, ARBRE, VIDE, VIDE, VIDE, ARBRE, ARBRE, ARBRE, ARBRE, VIDE, VIDE, ARBRE, ARBRE, ARBRE, VIDE, VIDE, VIDE, VIDE, VIDE, VIDE, VIDE, VIDE, VIDE, VIDE, VIDE, VIDE, VIDE, VIDE, VIDE, VIDE, ARBRE, VIDE, VIDE, VIDE,VIDE, ARBRE, ARBRE, ARBRE, ARBRE, VIDE, ARBRE, ARBRE, ARBRE, VIDE, VIDE, ARBRE, ARBRE, VIDE, VIDE, ARBRE, ARBRE, ARBRE, VIDE, VIDE, ARBRE, ARBRE, VIDE, VIDE, VIDE, VIDE, VIDE, ARBRE, VIDE, VIDE, VIDE, ARBRE, ARBRE, ARBRE, VIDE, VIDE, ARBRE, ARBRE, VIDE, VIDE, VIDE, VIDE, VIDE, ARBRE, VIDE, VIDE, VIDE, ARBRE, ARBRE, ARBRE, VIDE, VIDE, ARBRE, ARBRE, VIDE, VIDE, VIDE, VIDE, VIDE, ARBRE, VIDE, VIDE};
int fin = 0;
int choix = 0;
int transphormation = 7;
int bouger = 20;
int inverser = 2;
int coupFantome = 0;
int dedoublement = 2;
int bombeEnPlace = 0;
SDL_Rect position;
SDL_Rect positionPersonnage;
SDL_Rect positionFantome;
SDL_Rect positionLeurre;
SDL_Rect positionDynamite;
positionFantome.x = 0;
positionFantome.y = 0;
positionDynamite.x = 1555;
positionDynamite.y = 1555;
SDL_Rect positionFin;
positionFin.x = (LARGEUR_FENETRE/2) - (529/2);
positionFin.y = (HAUTEUR_FENETRE/2) - (73/2);
int continuer = 0;
SDL_Event event;
SDL_Surface *ecran = NULL;
ecran = SDL_SetVideoMode(LARGEUR_FENETRE, HAUTEUR_FENETRE, 32, SDL_HWSURFACE);
SDL_WM_SetIcon(SDL_LoadBMP("maison.bmp"), NULL);
SDL_WM_SetCaption("Attrape moi si tu peux !", NULL);
SDL_Surface *arbre = NULL;
SDL_Surface *personnage = NULL;
SDL_Surface *fantome = NULL;
SDL_Surface *fantomeHAUT = NULL;
SDL_Surface *fantomeBAS = NULL;
SDL_Surface *fantomeGAUCHE = NULL;
SDL_Surface *fantomeDROITE = NULL;
SDL_Surface *Fin = NULL;
SDL_Surface *dynamite = NULL;
SDL_Surface *commandes = NULL;
arbre = SDL_LoadBMP("arbre.bmp");
personnage = SDL_LoadBMP("personnage.bmp");
fantomeHAUT = SDL_LoadBMP("fantomeHAUT.bmp");
fantomeBAS = SDL_LoadBMP("fantomeBAS.bmp");
fantomeGAUCHE = SDL_LoadBMP("fantomeGAUCHE.bmp");
fantomeDROITE = SDL_LoadBMP("fantomeDROITE.bmp");
Fin = SDL_LoadBMP("fin.bmp");
fantome = fantomeDROITE;
dynamite = SDL_LoadBMP("dynamite.bmp");
commandes = SDL_LoadBMP("commandes.bmp");
SDL_Init(SDL_INIT_VIDEO | SDL_DOUBLEBUF | SDL_INIT_AUDIO);
FSOUND_Init(44100, 32, 0);
FSOUND_STREAM *musique = NULL;
musique = FSOUND_Stream_Open("musique.mp3", 0, 0, 0);
FSOUND_Stream_Play(FSOUND_FREE, musique);
FSOUND_SetVolume(FSOUND_ALL, 120);
positionPersonnage.x = NB_BLOCS_LARGEUR*TAILLE_BLOC - TAILLE_BLOC;
positionPersonnage.y = NB_BLOCS_HAUTEUR*TAILLE_BLOC - TAILLE_BLOC;
while (!continuer)
{
SDL_WaitEvent (&event);
switch (event.type)
{
case SDL_QUIT:
continuer = 1;
break;
case SDL_KEYDOWN:
continuer = 1;
break;
}
SDL_BlitSurface(commandes, NULL, ecran, &positionFantome);
SDL_Flip(ecran);
}
while(continuer)
{
coupFantome--;
SDL_WaitEvent (&event);
switch (event.type)
{
case SDL_QUIT:
continuer = 0;
break;
case SDL_KEYDOWN:
switch(event.key.keysym.sym)
{
//COMMANDES DU JEU
case SDLK_SPACE:
ecran = SDL_SetVideoMode(LARGEUR_FENETRE, HAUTEUR_FENETRE, 32, SDL_HWSURFACE | SDL_FULLSCREEN);
break;
case SDLK_ESCAPE:
ecran = SDL_SetVideoMode(LARGEUR_FENETRE, HAUTEUR_FENETRE, 32, SDL_HWSURFACE );
break;
case SDLK_DELETE:
if (dedoublement)
{
coupFantome = 60;
dedoublement--;
}
break;
case SDLK_UP:
fantome = fantomeHAUT;
positionFantome.y = positionFantome.y-TAILLE_BLOC;
break;
case SDLK_DOWN:
fantome = fantomeBAS;
if(positionFantome.y < HAUTEUR_FENETRE - TAILLE_BLOC)
positionFantome.y = positionFantome.y+TAILLE_BLOC;
break;
case SDLK_RIGHT:
fantome = fantomeDROITE;
if(positionFantome.x < LARGEUR_FENETRE - TAILLE_BLOC)
positionFantome.x = positionFantome.x+TAILLE_BLOC;
break;
case SDLK_LEFT:
fantome = fantomeGAUCHE;
positionFantome.x = positionFantome.x-TAILLE_BLOC;
break;
case SDLK_q:
transphormation = transphormation - 1;
if (transphormation > 0)
{
if (personnage ==arbre)
personnage = SDL_LoadBMP("personnage.bmp");
else
{
personnage = arbre;
}
}
break;
case SDLK_TAB:
if(inverser)
{
for (j = 0; j < NB_BLOCS_HAUTEUR; j++)
{
for (i = 0; i < NB_BLOCS_LARGEUR; i++)
{
position.x = i*TAILLE_BLOC;
position.y = j*TAILLE_BLOC;
if( carte[i][j] == ARBRE )
{
carte[i][j] = VIDE;
}
else if( carte[i][j] == VIDE )
{
carte[i][j] = ARBRE;
}
}
}
inverser--;
}
break;
case SDLK_e:
bombeEnPlace++;
positionDynamite.x = positionPersonnage.x;
positionDynamite.y = positionPersonnage.y;
break;
case SDLK_w:
if (personnage ==arbre)
bouger--;
if(!bouger)
{personnage = SDL_LoadBMP("personnage.bmp");
bouger = 15;
}
positionPersonnage.y = positionPersonnage.y-TAILLE_BLOC;
break;
case SDLK_s:
if (personnage ==arbre)
bouger--;
if(!bouger)
{personnage = SDL_LoadBMP("personnage.bmp");
bouger = 15;
}
if(positionPersonnage.y < HAUTEUR_FENETRE - TAILLE_BLOC)
positionPersonnage.y = positionPersonnage.y+TAILLE_BLOC;
break;
case SDLK_d:
if (personnage ==arbre)
bouger--;
if(!bouger)
{personnage = SDL_LoadBMP("personnage.bmp");
bouger = 15;
}
if(positionPersonnage.x < LARGEUR_FENETRE - TAILLE_BLOC)
positionPersonnage.x = positionPersonnage.x+TAILLE_BLOC;
break;
case SDLK_a:
if (personnage ==arbre)
bouger--;
if(!bouger)
{personnage = SDL_LoadBMP("personnage.bmp");
bouger = 15;
}
positionPersonnage.x = positionPersonnage.x-TAILLE_BLOC;
break;
}
break;
}
positionLeurre.x = positionFantome.x + TAILLE_BLOC + TAILLE_BLOC;
positionLeurre.y = positionFantome.y + TAILLE_BLOC;
SDL_FillRect(ecran, NULL, SDL_MapRGB(ecran->format, 255, 255, 255));
SDL_BlitSurface(personnage, NULL, ecran, &positionPersonnage);
SDL_BlitSurface(dynamite, NULL, ecran, &positionDynamite);
SDL_BlitSurface(fantome, NULL, ecran, &positionFantome);
if (coupFantome >0)
SDL_BlitSurface(fantome, NULL, ecran, &positionLeurre);
for (j = 0; j < NB_BLOCS_HAUTEUR; j++)
{
for (i = 0; i < NB_BLOCS_LARGEUR; i++)
{
position.x = i*TAILLE_BLOC;
position.y = j*TAILLE_BLOC;
if (carte[j][i] == ARBRE)
{
SDL_BlitSurface(arbre, NULL, ecran, &position);
}
}
}
SDL_BlitSurface(dynamite, NULL, ecran, &positionDynamite);
SDL_BlitSurface(personnage, NULL, ecran, &positionPersonnage);
SDL_Flip(ecran);
if((positionLeurre.y == positionPersonnage.y && positionLeurre.x == positionPersonnage.x) || (positionLeurre.y == positionDynamite.y && positionLeurre.x == positionDynamite.x))
{
coupFantome = 0;
positionDynamite.x = 2000;
}
if ((positionFantome.y == positionPersonnage.y && positionFantome.x == positionPersonnage.x) || (positionDynamite.y == positionFantome.y && positionDynamite.x == positionFantome.x))
{
for (i=0; i < 500; i++)
{
SDL_FillRect(ecran, NULL, SDL_MapRGB(ecran->format, 255, 255, 255));
SDL_BlitSurface(Fin, NULL, ecran, &positionFin);
SDL_Flip(ecran);
positionPersonnage.x = NB_BLOCS_LARGEUR*TAILLE_BLOC - TAILLE_BLOC;
positionPersonnage.y = NB_BLOCS_HAUTEUR*TAILLE_BLOC - TAILLE_BLOC;
positionFantome.x = 0;
positionFantome.y = 0;
}
transphormation = 7;
bouger = 15;
inverser = 4;
coupFantome = 0;
dedoublement = 1;
positionDynamite.x = 1500;
}
}
//liberation de la memoire a faire ou pas (je viens de le voir et j'ai fait ça il y a longtemps)
SDL_Quit();
FSOUND_Close();
return EXIT_SUCCESS;
}
Conclusion
Un jeu simple mais amusant (mes amis au Lycée sont pour ainsi dire "FAN" et on délire avec ça au CDI par exemple ^^)... Plein d'amélioration possible comme un compteur, enregistrer les scores (mais je n'avais pas appris à écrire dans des fichiers et la gestion du temps à l'époque... de plus c'est la misère pour afficher du texte il faut télécharger d'autres librairies...)
remarque : (Ajoutez musique.mp3 dans le répértoire ou se trouve le .exe pour la jouer)
Sources du même auteur
Sources de la même categorie
Commentaires et avis
Discussions en rapport avec ce code source dans le forum
le dur chemin du debutant...? [ par zevince ]
Salut,je decouvre ce site.. et ca a l'air bien cool et y'a l'air d'y avoir du passage.. ca tombe bien !moi : je connais bien html, xml, xslt et j'ai d
Jeu mario avec SDL (problème) [ par dmontavon ]
bonjour, je suis en train de fair un super mario avec SDL... J'en suis qu'au début, j'ai déja réussi à le faire avancer à
[SDL - OpenGL - POO] cherche collaborateurs pour jeu 2D [ par MrdJack ]
salut, je projetes de faire un jeu 2D de type bomberman/dynablaster en SDL/OpenGL/POO, je cherche des programmeurs interressé ayant juste des not
Recrutement jeu SDL en 2D [ par toun1 ]
Bonjours nous recrutons des codeurs C/C++ pour un jeu de shoot 2D en SDL.Lien: http://www.ggame.derniersmots.comJ'en profite pour mettre le lien de mo
jeu sdl [ par cheikhouna ]
SLT je suis debutant en sdl et j'aimerai avoir un bon projet de jeu ou d'animation 2d merci
jeu SDL [ par uzixucf ]
bonjour tout le monde, je suis nouveau d'entre vousje suis entrain de developper un jeu en SDL (language C) qui se présente ainsi
Petit Probleme SDL... [ par nahoof ]
Voila, c'est le premier "vrai" programme (codé en C) que je realise et j'ai un petit problème avec la SDL : Je suis en train de creer un jeu de poke
Programme SDL qui s'arrête subitement au clic... [ par Rflx ]
Bonjour, Je programme actuellement, pour mes études, un jeu labyrinthe en C++ avec interface graphique gérée avec SDL. Parfois, je peux jouer sans
allocation dynamique d'un fichier en SDL [ par atefth ]
Salut: Mon probléme est que j'ai un programme SDL qui utilise enormement de la mémoire. Je pensais alors : D'utiliser une allocation dynamique pour me
|
Derniers Blogs
IMAGINE CUP 2012, MAKE A SIGN EN FINALEIMAGINE CUP 2012, MAKE A SIGN EN FINALE par junarnoalg
Voilà qui est fait, la nouvelle est officielle ! L'équipe belge "Make a Sign" va au pays des kangourous défendre son projet dans la catégorie Software Design. http://www.imaginecup.com/CompetitionsContent/Competition/WorldwideFinalists.aspx V...
Cliquez pour lire la suite de l'article par junarnoalg KINECT 1.5 IS OUT !KINECT 1.5 IS OUT ! par Vko
La version 1.5 du Kinect For Microsoft vient tout juste de sortir ! Plein de nouveautés: Tracking de squelette en Near Mode Détection en position assise Détection faciale avec un SDK dédié Documentation et des guideline (enfin) Un out...
Cliquez pour lire la suite de l'article par Vko LES ACTUALITéS DE LA SEMAINE SUR C2I.FR (14 MAI - 20 MAI) LES ACTUALITéS DE LA SEMAINE SUR C2I.FR (14 MAI - 20 MAI) par richardc
Mise à jour des Web API du 14 Mai
Réservez dès maintenant votre journée du 20 juin pour le Windows Azure Dev Camp 2012 à Paris
Mise à jour de Team Foundation Service
MechCommander 2 sur Windows 8
Entity Framework 5 Release Candidate e...
Cliquez pour lire la suite de l'article par richardc REACTIVE EXTENSIONS : CONSOMMER DES SERVICES AVEC RX PARTIE 3, LES PIèGES à éVITERREACTIVE EXTENSIONS : CONSOMMER DES SERVICES AVEC RX PARTIE 3, LES PIèGES à éVITER par Groc
Une mauvaise utilisation de rx lors de l'écriture d'une couche d'accès à des services peut conduire à des cas embarassants avec des erreurs mal gérées, des appels qui ne partent lorsqu'ils le devraient, et même des résultats incorrects . le tout nuis...
Cliquez pour lire la suite de l'article par Groc SHAREPOINT BLOG SITE, PROBLèME D'ARCHIVESSHAREPOINT BLOG SITE, PROBLèME D'ARCHIVES par junarnoalg
Dernièrement, nous avons migré le site
myTIC
vers un nouveau serveur SharePoint 2010. Dans les contenus que nous vouloins récupérer, nous avions un certain nombre de blogs.
Nous avons utilisé les commandes Power...
Cliquez pour lire la suite de l'article par junarnoalg
Forum
RE : SAC A DOS RE : SAC A DOS par hadjkaddour
Cliquez pour lire la suite par hadjkaddour
Logiciels
sDEVIS-FACTURES vlPRO (8.1.0.3)SDEVIS-FACTURES VLPRO (8.1.0.3)sDEVIS-FACTURES vlPRO a été mis au point pour les particuliers, créateurs, entrepreneurs, artisa... Cliquez pour télécharger sDEVIS-FACTURES vlPRO 974 Application Server (12.2.4.6)974 APPLICATION SERVER (12.2.4.6)Développez de puissantes applications dans un environnement de 'cloud computing', clusterisé, séc... Cliquez pour télécharger 974 Application Server vPicture (1.4.2.1)VPICTURE (1.4.2.1)Avec vPicture, hébergez vos images facilement et rapidement.
vPicture est un utilitaire simple, ... Cliquez pour télécharger vPicture Easy-Planning (2.2.1.6)EASY-PLANNING (2.2.1.6)Easy-Planning permet de créer des plannings sous la représentation de diagrammes et est adapté au... Cliquez pour télécharger Easy-Planning COM-BACKUP (2.0)COM-BACKUP (2.0)
COM-BACKUP est un logiciel de sauvegarde qui permet de planifier les sauvegardes de vos dossiers ...
Cliquez pour télécharger COM-BACKUP
|