Commit 9d30446a authored by Achraf BOUJIDA's avatar Achraf BOUJIDA
Browse files

organisation + makefile

parent ff507fb7
This diff is collapsed.
#include <math.h>
#include <stdio.h>
#include <SDL2/SDL.h>
#include <string.h>
#include <SDL2/SDL_image.h>
#include <stdbool.h>
#define BAS 1
#define HAUT 2
void end_sdl(char ok,char const* msg,SDL_Window* window,SDL_Renderer* renderer);
SDL_Texture* load_texture_from_image(char * file_image_name, SDL_Window *window, SDL_Renderer *renderer);
void play_with_texture_1(SDL_Texture *my_texture, SDL_Window*window,SDL_Renderer *renderer);
void animation_run(SDL_Texture* my_texture,
SDL_Window* window,
SDL_Renderer* renderer,int i);
void animation_attack(SDL_Texture* my_texture,
SDL_Window* window,
SDL_Renderer* renderer,int i,int j);
void animation_climb(SDL_Texture* my_texture,
SDL_Window* window,
SDL_Renderer* renderer,int i, int mouvement);
void animation_climb_haut(SDL_Texture* my_texture,
SDL_Window* window,
SDL_Renderer* renderer,int i);
#include <math.h>
#include <stdio.h>
#include <SDL2/SDL.h>
#include <string.h>
#include <SDL2/SDL_image.h>
#include <stdbool.h>
#include "animationperso.h"
int main(int argc, char* argv[])
{
if(SDL_Init(SDL_INIT_VIDEO) < 0)
{
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "[DEBUG] > %s", SDL_GetError());
return EXIT_FAILURE;
}
SDL_Texture * texture1 = NULL;
SDL_Texture * texture3 = NULL;
SDL_Texture * texture2 = NULL;
SDL_Window * pWindow;
SDL_Renderer * pRenderer;
pWindow = SDL_CreateWindow("rendu",SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 20*32, 20*32, SDL_WINDOW_SHOWN);
if (pWindow == NULL)
{
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "[DEBUG] > %s", SDL_GetError());
SDL_Quit();
return EXIT_FAILURE;
}
pRenderer = SDL_CreateRenderer(pWindow, -1, SDL_RENDERER_ACCELERATED);
if (pRenderer == NULL)
{
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "[DEBUG] > %s", SDL_GetError());
SDL_Quit();
return EXIT_FAILURE;
}
texture3=load_texture_from_image("Punk_climb.png",pWindow,pRenderer);
texture1=load_texture_from_image("Punk_run.png",pWindow, pRenderer); /* creation de la texture qui contient l'image */
texture2=load_texture_from_image("Punk_attack3.png",pWindow, pRenderer);
animation_climb(texture3,pWindow,pRenderer,8, BAS);
SDL_Delay(5000);
//SDL_RenderCopy(pRenderer,texture,NULL,NULL); /* On copie la texture dans le render */
//SDL_RenderPresent(pRenderer); /* On affiche le render */
//SDL_Delay(5000);
// SDL_bool on=SDL_TRUE;
// SDL_bool start=SDL_FALSE;
// while(on)
// {
// SDL_Event event;
// while(on && SDL_PollEvent(&event))
// {
// switch (event.type)
// {
// case SDL_QUIT:
// on=SDL_FALSE;
// break;
// case SDL_KEYDOWN :
// switch (event.key.keysym.sym)
// {
// case SDLK_SPACE:
// start=SDL_TRUE;
// break;
// default:
// break;
// }
// default:
// break;
// }
// if (!start)
// {
// animation_attack(texture2,pWindow,pRenderer,2,15);
// }
// }
// }
SDL_DestroyRenderer(pRenderer);
SDL_DestroyWindow(pWindow);
SDL_Quit();
return EXIT_SUCCESS;
}
// #include <math.h>
// #include <stdio.h>
// #include <SDL2/SDL.h>
// #include <string.h>
// #include <SDL2/SDL_image.h>
// #include <stdbool.h>
// #include "image.h"
// #include "matrice.h"
// #include "animationperso.h"
// // gcc *.c -o jeu -lSDL2 -lSDL2_gfx -lSDL2_image -lSDL2_ttf -lSDL2_mixer -lSDL2_net -lm
// int main(int argc, char* argv[])
// {
// if(SDL_Init(SDL_INIT_VIDEO) < 0)
// {
// SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "[DEBUG] > %s", SDL_GetError());
// return EXIT_FAILURE;
// }
// SDL_Texture * texture = NULL;
// SDL_Texture * texture_fond = NULL;
// SDL_Window * pWindow;
// SDL_Renderer * pRenderer;
// pWindow = SDL_CreateWindow("rendu",SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 20*32, 20*32, SDL_WINDOW_SHOWN);
// if (pWindow == NULL)
// {
// SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "[DEBUG] > %s", SDL_GetError());
// SDL_Quit();
// return EXIT_FAILURE;
// }
// pRenderer = SDL_CreateRenderer(pWindow, -1, SDL_RENDERER_ACCELERATED);
// if (pRenderer == NULL)
// {
// SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "[DEBUG] > %s", SDL_GetError());
// SDL_Quit();
// return EXIT_FAILURE;
// }
// texture=load_texture_from_image("mur.png",pWindow, pRenderer); /* creation de la texture qui contient l'image */
// texture_fond=load_texture_from_image("Back.png",pWindow, pRenderer);
// int** matrice =cree(20,20);
// fill_matrix(matrice,20,20);
// insert(matrice,1,1);
// insert(matrice,2,2);
// insert(matrice,3,1);
// insert(matrice,3,2);
// insert(matrice,3,3);
// play_with_texture_2(texture,texture_fond, pWindow,
// pRenderer, matrice);
// SDL_Delay(2000);
// insert(matrice,20,20);
// matrice[0][0]=0;
// play_with_texture_2(texture,texture_fond, pWindow,
// pRenderer, matrice);
// SDL_Delay(2000);
// // SDL_RenderCopy(pRenderer,texture,NULL,NULL); /* On copie la texture dans le render */
// //SDL_RenderPresent(pRenderer); /* On affiche le render */
// //SDL_Delay(5000);
// SDL_DestroyRenderer(pRenderer);
// SDL_DestroyWindow(pWindow);
// SDL_Quit();
// return EXIT_SUCCESS;
// }
This diff is collapsed.
#ifndef ANIMATION
#define ANIMATION
#include <math.h>
#include <stdio.h>
#include <SDL2/SDL.h>
#include <string.h>
#include <SDL2/SDL_image.h>
#include <stdbool.h>
#include "image.h"
#include "matrice.h"
#include "animationperso.h"
#define BAS 1
#define HAUT 2
SDL_Texture* load_texture_from_image(char * file_image_name, SDL_Window *window, SDL_Renderer *renderer);
// void play_with_texture_1(SDL_Texture *my_texture, SDL_Window*window,SDL_Renderer *renderer);
void animation_run(SDL_Texture* my_texture,SDL_Texture* mure,SDL_Texture* fond,
SDL_Window* window,
SDL_Renderer* renderer,int i,int j,int ** matrice);
void animation_attack(SDL_Texture* my_texture,SDL_Texture* mure,SDL_Texture* fond,
SDL_Window* window,
SDL_Renderer* renderer,int i,int j,int ** matrice);
void play_with_texture_1_1(SDL_Texture *my_texture, SDL_Window *window,
SDL_Renderer *renderer);
void animation_climb(SDL_Texture* my_texture,SDL_Texture* mure,SDL_Texture* fond,
SDL_Window* window,
SDL_Renderer* renderer,int i,int j,int ** matrice,int mouvement);
void animation_run_back(SDL_Texture* my_texture,SDL_Texture* mure,SDL_Texture* fond,
SDL_Window* window,
SDL_Renderer* renderer,int i,int j,int ** matrice);
void afficher_perso(SDL_Texture* my_texture,SDL_Texture* mure,SDL_Texture* fond,
SDL_Window* window,
SDL_Renderer* renderer,int i,int j,int ** matrice);
void animation_attack_gauche(SDL_Texture* my_texture,SDL_Texture* mure,SDL_Texture* fond,
SDL_Window* window,
SDL_Renderer* renderer,int i,int j,int ** matrice) ;
void afficher_marto(SDL_Texture* my_texture,
SDL_Window* window,
SDL_Renderer* renderer,int i,int j,int** matrice);
#endif
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment