-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 669f077
Showing
38 changed files
with
1,320 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
## | ||
## Makefile for mk_alum1 in /u/all/nguyen_7/cu/rendu/dirtest/alum/SDL/bin | ||
## | ||
## Made by julien nguyen-duy | ||
## Login <[email protected]> | ||
## | ||
## Started on Wed Feb 10 14:43:40 2010 julien nguyen-duy | ||
## Last update Mon Feb 14 12:21:08 2011 damien locque | ||
## | ||
|
||
NAME = alum1 | ||
SRCS = ai.c \ | ||
ai2.c \ | ||
match_func.c \ | ||
check_space.c \ | ||
static.c \ | ||
init.c \ | ||
free_all.c \ | ||
try_win.c \ | ||
affpvp.c \ | ||
aff.c \ | ||
pvp.c \ | ||
xfunc.c \ | ||
xfuncSDL.c \ | ||
main.c | ||
|
||
RM = rm -f | ||
|
||
OBJS = $(SRCS:.c=.o) | ||
CC = gcc | ||
|
||
LDFLAGS += -I/usr/local/include/SDL -I/usr/local/include -D_GNU_SOURCE=1 -D_REENTRANT -L/usr/local/lib -Wl,-rpath,/usr/local/lib -lSDL -pthread -lSDL_image | ||
CFLAGS = -I. -W -Wall -pedantic -ansi -O2 | ||
|
||
all : $(NAME) | ||
|
||
$(NAME) : $(OBJS) | ||
$(CC) $(CFLAGS) -o $(NAME) $(OBJS) $(LDFLAGS) | ||
|
||
clean : | ||
$(RM) $(OBJS) | ||
|
||
fclean : clean | ||
$(RM) $(NAME) | ||
|
||
re : fclean all | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
/* | ||
** aff.c for aff in /u/all/nguyen_7/cu/public/alum-1 | ||
** | ||
** Made by julien nguyen-duy | ||
** Login <[email protected]> | ||
** | ||
** Started on Thu Feb 11 19:06:29 2010 julien nguyen-duy | ||
** Last update Sat Feb 13 17:37:36 2010 damien locque | ||
*/ | ||
|
||
#include <SDL/SDL.h> | ||
#include "my.h" | ||
|
||
int aff_win(t_var var, int in_prog, int who_play) | ||
{ | ||
SDL_Event event; | ||
SDL_Rect pos; | ||
|
||
pos.x = 0; | ||
pos.y = 0; | ||
if (who_play != 0) | ||
xSDL_BlitSurface(var.loser, NULL, var.screen, &pos); | ||
else | ||
xSDL_BlitSurface(var.winner, NULL, var.screen, &pos); | ||
xSDL_Flip(var.screen); | ||
while (in_prog == 1) | ||
{ | ||
xSDL_WaitEvent(&event); | ||
if (event.type == SDL_KEYDOWN) | ||
if (event.key.keysym.sym == SDLK_ESCAPE) | ||
in_prog = 42; | ||
} | ||
return (42); | ||
} | ||
|
||
void aff_match(t_var *var, t_match *match) | ||
{ | ||
t_match *temp; | ||
|
||
temp = match; | ||
while (temp->next != NULL) | ||
{ | ||
if (temp->burn == 1) | ||
xSDL_BlitSurface(var->burn, NULL, var->screen, &(temp->pos)); | ||
else if (temp->select == 0) | ||
xSDL_BlitSurface(var->alum, NULL, var->screen, &(temp->pos)); | ||
else if (temp->select == 1) | ||
xSDL_BlitSurface(var->clique, NULL, var->screen, &(temp->pos)); | ||
temp = temp->next; | ||
} | ||
if (temp->burn == 1) | ||
xSDL_BlitSurface(var->burn, NULL, var->screen, &(temp->pos)); | ||
else if (temp->select == 0) | ||
xSDL_BlitSurface(var->alum, NULL, var->screen, &(temp->pos)); | ||
else | ||
xSDL_BlitSurface(var->clique, NULL, var->screen, &(temp->pos)); | ||
xSDL_Flip(var->screen); | ||
} | ||
|
||
void aff_player(t_var **var) | ||
{ | ||
if (SDL_SetColorKey((*var)->player1, SDL_SRCCOLORKEY, | ||
SDL_MapRGB((*var)->player1->format, 0, 0, 255)) == -1) | ||
{ | ||
my_puterror("Sdl Set Color Key Failed"); | ||
exit(EXIT_FAILURE); | ||
} | ||
xSDL_BlitSurface((*var)->player1, NULL, (*var)->screen, &((*var)->pos_p1)); | ||
} | ||
|
||
void aff_cpu(t_var **var) | ||
{ | ||
if (SDL_SetColorKey((*var)->cpu, SDL_SRCCOLORKEY, | ||
SDL_MapRGB((*var)->cpu->format, 0, 0, 255)) == -1) | ||
{ | ||
my_puterror("Sdl Set Color Key Failed"); | ||
exit(EXIT_FAILURE); | ||
} | ||
xSDL_BlitSurface((*var)->cpu, NULL, (*var)->screen, &((*var)->pos_cpu)); | ||
} | ||
|
||
void aff_bwall(t_var *var) | ||
{ | ||
var->pos_bwall.x = 0; | ||
var->pos_bwall.y = 0; | ||
|
||
xSDL_BlitSurface(var->bwall, NULL, var->screen, &(var->pos_bwall)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
** affpvp.c for aff pvp in /u/all/nguyen_7/public/alum-1 | ||
** | ||
** Made by damien locque | ||
** Login <[email protected]> | ||
** | ||
** Started on Sat Feb 13 16:25:43 2010 damien locque | ||
** Last update Sat Feb 13 17:37:46 2010 damien locque | ||
*/ | ||
|
||
#include <SDL/SDL.h> | ||
#include "my.h" | ||
|
||
void aff_player1_pvp(t_var **var) | ||
{ | ||
xSDL_BlitSurface((*var)->player1pvp, NULL, (*var)->screen, &((*var)->pos_p1)); | ||
} | ||
|
||
void aff_player2_pvp(t_var **var) | ||
{ | ||
xSDL_BlitSurface((*var)->player2pvp, NULL, (*var)->screen, &((*var)->pos_cpu)); | ||
} | ||
|
||
void aff_p1_p2(int who_play, t_var *var) | ||
{ | ||
if (who_play == 0) | ||
aff_player1_pvp(&var); | ||
else | ||
aff_player2_pvp(&var); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
/* | ||
** ai.c for ai_alum in /u/all/nguyen_7/cu/rendu/dirtest/alum_++/bin | ||
** | ||
** Made by julien nguyen-duy | ||
** Login <[email protected]> | ||
** | ||
** Started on Thu Feb 11 17:24:27 2010 julien nguyen-duy | ||
** Last update Thu Feb 11 18:43:02 2010 julien nguyen-duy | ||
*/ | ||
|
||
#include "my.h" | ||
#include <time.h> | ||
#include <unistd.h> | ||
|
||
t_match *play_last_line(t_match *match) | ||
{ | ||
t_match *temp; | ||
int nb_match; | ||
|
||
nb_match = match_count(match); | ||
temp = match; | ||
if (nb_match == 1) | ||
{ | ||
match = play_2match(match, nb_match); | ||
return (match); | ||
} | ||
while (temp->next != NULL && nb_match != 1) | ||
{ | ||
if (temp->burn == 0) | ||
{ | ||
temp->burn = 1; | ||
nb_match--; | ||
} | ||
temp = temp->next; | ||
} | ||
if (temp->burn == 0) | ||
{ | ||
temp->burn = 1; | ||
nb_match--; | ||
} | ||
return (match); | ||
} | ||
|
||
int search_line(t_match *match, int the_line) | ||
{ | ||
t_match *temp; | ||
int check; | ||
|
||
check = 0; | ||
temp = match; | ||
while (temp->next != NULL) | ||
{ | ||
if (temp->burn == 1) | ||
temp = temp->next; | ||
else | ||
if (temp->line != check) | ||
{ | ||
check = temp->line; | ||
the_line--; | ||
} | ||
if (the_line == 0) | ||
return (check); | ||
temp = temp->next; | ||
} | ||
check = temp->line; | ||
the_line--; | ||
if (the_line == 0) | ||
return (check); | ||
return (1); | ||
} | ||
|
||
int line_to_play(t_match *match, int nb_line) | ||
{ | ||
int the_line; | ||
int check; | ||
|
||
check = 0; | ||
the_line = 0; | ||
srand(time(NULL) * getpid()); | ||
while (the_line == 0) | ||
the_line = rand() % (nb_line); | ||
if (nb_line == 2) | ||
{ | ||
check = two_last_line(match, nb_line); | ||
return (check); | ||
} | ||
check = search_line(match, the_line); | ||
return (check); | ||
} | ||
|
||
int rand_match(t_match *match, int the_line) | ||
{ | ||
t_match *temp; | ||
int nbr; | ||
int nb_to_play; | ||
|
||
nbr = 0; | ||
nb_to_play = 0; | ||
temp = match; | ||
while (temp->next != NULL) | ||
{ | ||
if (temp->line == the_line) | ||
if (temp->burn == 0) | ||
nbr++; | ||
temp = temp->next; | ||
} | ||
if (temp->line == the_line) | ||
if (temp->burn == 0) | ||
nbr++; | ||
srand(time(NULL) * getpid()); | ||
if (nbr == 1) | ||
return (1); | ||
else | ||
while (nb_to_play == 0) | ||
nb_to_play = rand() % (nbr); | ||
return (nb_to_play); | ||
} | ||
|
||
t_match *cpu_playing(t_match *match, int line, int nb_match) | ||
{ | ||
t_match *temp; | ||
|
||
temp = match; | ||
while (nb_match > 0 && temp->next != NULL) | ||
{ | ||
if (temp->line == line) | ||
if (temp->burn == 0) | ||
{ | ||
temp->burn = 1; | ||
nb_match--; | ||
} | ||
temp = temp->next; | ||
} | ||
if (temp->line == line && nb_match > 0) | ||
if (temp->burn == 0) | ||
{ | ||
temp->burn = 1; | ||
nb_match--; | ||
} | ||
return (match); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/* | ||
** ai2.c for ai2_alum in /u/all/nguyen_7/cu/rendu/dirtest/alum_++/bin | ||
** | ||
** Made by julien nguyen-duy | ||
** Login <[email protected]> | ||
** | ||
** Started on Thu Feb 11 17:28:38 2010 julien nguyen-duy | ||
** Last update Fri Feb 12 11:24:07 2010 damien locque | ||
*/ | ||
|
||
#include "my.h" | ||
#include <unistd.h> | ||
|
||
int nbr_of_line(t_match *match) | ||
{ | ||
int nb_line; | ||
int cur_line; | ||
t_match *temp; | ||
|
||
nb_line = 0; | ||
cur_line = 0; | ||
temp = match; | ||
while (temp->next != NULL) | ||
{ | ||
if (temp->burn == 0) | ||
if (cur_line < temp->line) | ||
{ | ||
cur_line = temp->line; | ||
nb_line++; | ||
} | ||
temp = temp->next; | ||
} | ||
if (temp->burn == 0) | ||
if (cur_line < temp->line) | ||
{ | ||
cur_line = temp->line; | ||
nb_line++; | ||
} | ||
return (nb_line); | ||
} | ||
|
||
int two_last_line(t_match *match, int the_line) | ||
{ | ||
int nvoid_line; | ||
t_match *temp; | ||
int check; | ||
|
||
check = 0; | ||
nvoid_line = 0; | ||
temp = match; | ||
while (nvoid_line != the_line && temp->next != NULL) | ||
{ | ||
if (temp->burn != 1) | ||
if (check != temp->line) | ||
{ | ||
nvoid_line++; | ||
check = temp->line; | ||
} | ||
temp = temp->next; | ||
} | ||
if (nvoid_line != the_line) | ||
if (temp->burn != 1) | ||
if (check != temp->line) | ||
{ | ||
nvoid_line++; | ||
check = temp->line; | ||
} | ||
return (check); | ||
} |
Binary file not shown.
Oops, something went wrong.