Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
neon
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Cristian Weiland
neon
Commits
b02d7d11
There was a problem fetching the pipeline summary.
Commit
b02d7d11
authored
Jun 3, 2016
by
Cristian Weiland
Browse files
Options
Downloads
Patches
Plain Diff
Create init_sprites function
Signed-off-by:
Cristian Weiland
<
cw14@inf.ufpr.br
>
parent
85b4b6d1
No related branches found
No related tags found
3 merge requests
!12
Improving menu
,
!9
Develop
,
!7
Create init_sprites function
Pipeline
#
Changes
5
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
Fase1.h
+1
-1
1 addition, 1 deletion
Fase1.h
grafico.c
+123
-0
123 additions, 0 deletions
grafico.c
grafico.h
+4
-0
4 additions, 0 deletions
grafico.h
neon.c
+9
-182
9 additions, 182 deletions
neon.c
neon.h
+1
-4
1 addition, 4 deletions
neon.h
with
138 additions
and
187 deletions
Fase1.h
+
1
−
1
View file @
b02d7d11
...
...
@@ -8,7 +8,7 @@
#include
<allegro5/allegro_ttf.h>
#endif
void
fase1
(
Window
win
,
Magia
fireball
[
4
][
2
],
ALLEGRO_FONT
*
font
5
,
int
explox
[
4
][
2
],
int
exploy
[
4
][
2
],
Pessoa
*
p
,
Sprite
s
)
void
fase1
(
Window
win
,
Magia
fireball
[
4
][
2
],
ALLEGRO_FONT
*
font
,
int
explox
[
4
][
2
],
int
exploy
[
4
][
2
],
Pessoa
*
p
,
Sprite
s
)
{
int
njogadores
=
4
;
...
...
This diff is collapsed.
Click to expand it.
grafico.c
+
123
−
0
View file @
b02d7d11
...
...
@@ -83,3 +83,126 @@ bool is_inside_bitmap (BITMAP2 img, int x, int y)
return
(
x
>=
img
.
x
&&
x
<
img
.
x
+
img
.
w
&&
y
>=
img
.
y
&&
y
<
img
.
y
+
img
.
h
);
}
Sprite
init_sprites
(
FILE
*
errext
)
{
int
i
;
Sprite
s
;
s
.
neons
=
(
ALLEGRO_BITMAP
**
)
malloc
(
4
*
sizeof
(
ALLEGRO_BITMAP
*
));
s
.
fireballs
=
(
ALLEGRO_BITMAP
**
)
malloc
(
4
*
sizeof
(
ALLEGRO_BITMAP
*
));
s
.
chars
=
al_load_bitmap
(
"Imgs/chars.bmp"
);
// Obs: Cada imagem de cada char eh 32x32
if
(
!
(
s
.
chars
))
{
fprintf
(
errext
,
"Falha ao abrir a imagem chars."
);
fclose
(
errext
);
exit
(
1
);
}
s
.
tiles
=
al_load_bitmap
(
"Imgs/tiles.bmp"
);
if
(
!
(
s
.
tiles
))
{
fprintf
(
errext
,
"Falha ao abrir a imagem tiles."
);
fclose
(
errext
);
exit
(
1
);
}
s
.
bar
=
al_load_bitmap
(
"Imgs/bar.bmp"
);
if
(
!
(
s
.
bar
))
{
printf
(
"Falha ao abrir a imagem bar! O problema foi: %s
\n
"
,
strerror
(
errno
));
exit
(
1
);
}
s
.
healthbar
=
al_load_bitmap
(
"Imgs/healthbar.bmp"
);
if
(
!
(
s
.
healthbar
))
{
printf
(
"Falha ao abrir a imagem healthbar! O problema foi: %s
\n
"
,
strerror
(
errno
));
exit
(
1
);
}
s
.
energybar
=
al_load_bitmap
(
"Imgs/energybar.bmp"
);
if
(
!
(
s
.
energybar
))
{
printf
(
"Falha ao abrir a imagem energybar! O problema foi: %s
\n
"
,
strerror
(
errno
));
exit
(
1
);
}
s
.
dead
=
al_load_bitmap
(
"Imgs/dead.bmp"
);
if
(
!
(
s
.
dead
))
{
printf
(
"Falha ao abrir a imagem dead! O problema foi: %s
\n
"
,
strerror
(
errno
));
exit
(
1
);
}
s
.
explosion
=
al_load_bitmap
(
"Imgs/Explo.bmp"
);
if
(
!
(
s
.
explosion
))
{
fprintf
(
errext
,
"Falha ao abrir a imagem explo."
);
fclose
(
errext
);
exit
(
1
);
}
s
.
neons
[
0
]
=
al_load_bitmap
(
"Imgs/neonamarelo.bmp"
);
if
(
!
s
.
neons
[
0
])
{
fprintf
(
errext
,
"Falha ao abrir a imagem s.neons[0]."
);
fclose
(
errext
);
exit
(
1
);
}
s
.
neons
[
1
]
=
al_load_bitmap
(
"Imgs/neonazul.bmp"
);
if
(
!
s
.
neons
[
1
])
{
fprintf
(
errext
,
"Falha ao abrir a imagem s.neons[1]."
);
fclose
(
errext
);
exit
(
1
);
}
s
.
neons
[
2
]
=
al_load_bitmap
(
"Imgs/neonverde.bmp"
);
if
(
!
s
.
neons
[
2
])
{
fprintf
(
errext
,
"Falha ao abrir a imagem s.neons[2]."
);
fclose
(
errext
);
exit
(
1
);
}
s
.
neons
[
3
]
=
al_load_bitmap
(
"Imgs/neonvermelho.bmp"
);
if
(
!
s
.
neons
[
3
])
{
fprintf
(
errext
,
"Falha ao abrir a imagem s.neons[3]."
);
fclose
(
errext
);
exit
(
1
);
}
s
.
fireballs
[
0
]
=
al_load_bitmap
(
"Imgs/Fireballc.bmp"
);
if
(
!
s
.
fireballs
[
0
])
{
fprintf
(
errext
,
"Falha ao abrir a imagem s.fireballs[0]."
);
fclose
(
errext
);
exit
(
1
);
}
s
.
fireballs
[
1
]
=
al_load_bitmap
(
"Imgs/Fireballd.bmp"
);
if
(
!
s
.
fireballs
[
1
])
{
fprintf
(
errext
,
"Falha ao abrir a imagem s.fireballs[1]."
);
fclose
(
errext
);
exit
(
1
);
}
s
.
fireballs
[
2
]
=
al_load_bitmap
(
"Imgs/Fireballe.bmp"
);
if
(
!
s
.
fireballs
[
2
])
{
fprintf
(
errext
,
"Falha ao abrir a imagem s.fireballs[2]."
);
fclose
(
errext
);
exit
(
1
);
}
s
.
fireballs
[
3
]
=
al_load_bitmap
(
"Imgs/Fireballb.bmp"
);
if
(
!
s
.
fireballs
[
3
])
{
fprintf
(
errext
,
"Falha ao abrir a imagem s.fireballs[3]."
);
fclose
(
errext
);
exit
(
1
);
}
al_convert_mask_to_alpha
(
s
.
bar
,
al_map_rgb
(
255
,
0
,
255
));
al_convert_mask_to_alpha
(
s
.
dead
,
al_map_rgb
(
255
,
0
,
255
));
al_convert_mask_to_alpha
(
s
.
tiles
,
al_map_rgb
(
255
,
0
,
255
));
al_convert_mask_to_alpha
(
s
.
chars
,
al_map_rgb
(
255
,
0
,
255
));
al_convert_mask_to_alpha
(
s
.
explosion
,
al_map_rgb
(
255
,
0
,
255
));
al_convert_mask_to_alpha
(
s
.
healthbar
,
al_map_rgb
(
255
,
0
,
255
));
al_convert_mask_to_alpha
(
s
.
energybar
,
al_map_rgb
(
255
,
0
,
255
));
for
(
i
=
0
;
i
<
4
;
i
++
)
{
al_convert_mask_to_alpha
(
s
.
neons
[
i
],
al_map_rgb
(
255
,
0
,
255
));
al_convert_mask_to_alpha
(
s
.
fireballs
[
i
],
al_map_rgb
(
255
,
0
,
255
));
}
return
s
;
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
grafico.h
+
4
−
0
View file @
b02d7d11
...
...
@@ -11,6 +11,8 @@
#include
<allegro5/allegro_primitives.h>
#include
<allegro5/allegro_ttf.h>
#include
"colisao.h"
#ifndef GRAFICO_H
#define GRAFICO_H
...
...
@@ -40,6 +42,8 @@ void graphdeinit(Window win);
/* Retorna 1 se as coordenadas x,y estão dentro da imagem, 0 caso contrário. */
bool
is_inside_bitmap
(
BITMAP2
img
,
int
x
,
int
y
);
Sprite
init_sprites
(
FILE
*
errext
);
#define ACAFRAO PIXEL(244,196,48)
#define AGUA_MARINHA PIXEL(127,255,212)
#define AGUA_MARINHA_MEDIA PIXEL(102,205,170)
...
...
This diff is collapsed.
Click to expand it.
neon.c
+
9
−
182
View file @
b02d7d11
...
...
@@ -23,12 +23,7 @@ Problemas:
int
main
()
{
/* Coisas relacionadas aos chars */
int
i
,
j
,
x
,
y
;
/* Coisas relacioinadas ao mapa */
int
mapsize
,
xtile
[
TAM
],
ytile
[
TAM
],
xcorte
[
TAM
],
ycorte
[
TAM
];
/* Coisas relacionadas aos neons */
//int xneon[NJOGADORES],yneon[NJOGADORES],direcao=0,cor[4]={1,2,3,4};
int
direcao
=
0
;
int
i
,
j
;
/* Coisas relacionadas as tecnicas/magias */
int
explox
[
4
][
2
],
exploy
[
4
][
2
];
/* Pessoas, que contem quase todos os dados (ver colisao.h) */
...
...
@@ -46,20 +41,11 @@ int main()
p
[
i
].
andou_b
=
p
[
i
].
andou_c
=
p
[
i
].
andou_d
=
p
[
i
].
andou_e
=
0
;
}
//desx = (int*) malloc (NJOGADORES * sizeof(int)); --> Virou p.selx!
//desy = (int*) malloc (NJOGADORES * sizeof(int)); --> Virou p.sely!
Window
win
;
FILE
*
mapa
,
*
errext
;
// errext = error exit (ou saida de erros)
/* Magias */
Magia
fireball
[
4
][
2
];
/* Declaracao de estrtuturas do Allegro. Obs: Neons vai ser um vetor de imagens, na ordem amarelo - azul - verde - vermelho. */
//ALLEGRO_FONT *font;
//font5 = al_load_font("Fonts/fixed_font.tga", 0, 0);
//ALLEGRO_BITMAP *tiles,*chars,*map,*frente,**neons,**fireballs,*explosion;
Sprite
s
;
/* Inicializacao dos arquivos. */
errext
=
fopen
(
"lago.txt"
,
"w"
);
fclose
(
errext
);
errext
=
fopen
(
"err.txt"
,
"w"
);
if
(
!
errext
)
{
...
...
@@ -69,115 +55,9 @@ int main()
/* Inicializaoes do Allegro */
win
=
graphinit
(
errext
);
/* Inicializacao da Fonte */
//font = al_load_font("Fonts/fixed_font.tga", 0, 0);
//if(!font) {
// fprintf(errext,"Falha ao abrir a imagem tiles.");fclose(errext);exit(1); }
/* Inicializacao dos Bitmaps */
s
.
neons
=
(
ALLEGRO_BITMAP
**
)
malloc
(
4
*
sizeof
(
ALLEGRO_BITMAP
*
));
s
.
fireballs
=
(
ALLEGRO_BITMAP
**
)
malloc
(
4
*
sizeof
(
ALLEGRO_BITMAP
*
));
s
.
chars
=
al_load_bitmap
(
"Imgs/chars.bmp"
);
// Obs: Cada imagem de cada char eh 32x32
if
(
!
(
s
.
chars
))
{
fprintf
(
errext
,
"Falha ao abrir a imagem chars."
);
fclose
(
errext
);
exit
(
1
);
}
s
.
tiles
=
al_load_bitmap
(
"Imgs/tiles.bmp"
);
if
(
!
(
s
.
tiles
))
{
fprintf
(
errext
,
"Falha ao abrir a imagem tiles."
);
fclose
(
errext
);
exit
(
1
);
}
s
.
bar
=
al_load_bitmap
(
"Imgs/bar.bmp"
);
if
(
!
(
s
.
bar
))
{
printf
(
"Falha ao abrir a imagem bar! O problema foi: %s
\n
"
,
strerror
(
errno
));
exit
(
1
);
}
s
.
healthbar
=
al_load_bitmap
(
"Imgs/healthbar.bmp"
);
if
(
!
(
s
.
healthbar
))
{
printf
(
"Falha ao abrir a imagem healthbar! O problema foi: %s
\n
"
,
strerror
(
errno
));
exit
(
1
);
}
s
.
energybar
=
al_load_bitmap
(
"Imgs/energybar.bmp"
);
if
(
!
(
s
.
energybar
))
{
printf
(
"Falha ao abrir a imagem energybar! O problema foi: %s
\n
"
,
strerror
(
errno
));
exit
(
1
);
}
s
.
dead
=
al_load_bitmap
(
"Imgs/dead.bmp"
);
if
(
!
(
s
.
dead
))
{
printf
(
"Falha ao abrir a imagem dead! O problema foi: %s
\n
"
,
strerror
(
errno
));
exit
(
1
);
}
s
.
explosion
=
al_load_bitmap
(
"Imgs/Explo.bmp"
);
if
(
!
(
s
.
explosion
))
{
fprintf
(
errext
,
"Falha ao abrir a imagem explo."
);
fclose
(
errext
);
exit
(
1
);
}
s
.
neons
[
0
]
=
al_load_bitmap
(
"Imgs/neonamarelo.bmp"
);
if
(
!
s
.
neons
[
0
])
{
fprintf
(
errext
,
"Falha ao abrir a imagem s.neons[0]."
);
fclose
(
errext
);
exit
(
1
);
}
s
.
neons
[
1
]
=
al_load_bitmap
(
"Imgs/neonazul.bmp"
);
if
(
!
s
.
neons
[
1
])
{
fprintf
(
errext
,
"Falha ao abrir a imagem s.neons[1]."
);
fclose
(
errext
);
exit
(
1
);
}
s
.
neons
[
2
]
=
al_load_bitmap
(
"Imgs/neonverde.bmp"
);
if
(
!
s
.
neons
[
2
])
{
fprintf
(
errext
,
"Falha ao abrir a imagem s.neons[2]."
);
fclose
(
errext
);
exit
(
1
);
}
s
.
neons
[
3
]
=
al_load_bitmap
(
"Imgs/neonvermelho.bmp"
);
if
(
!
s
.
neons
[
3
])
{
fprintf
(
errext
,
"Falha ao abrir a imagem s.neons[3]."
);
fclose
(
errext
);
exit
(
1
);
}
s
.
fireballs
[
0
]
=
al_load_bitmap
(
"Imgs/Fireballc.bmp"
);
if
(
!
s
.
fireballs
[
0
])
{
fprintf
(
errext
,
"Falha ao abrir a imagem s.fireballs[0]."
);
fclose
(
errext
);
exit
(
1
);
}
s
.
fireballs
[
1
]
=
al_load_bitmap
(
"Imgs/Fireballd.bmp"
);
if
(
!
s
.
fireballs
[
1
])
{
fprintf
(
errext
,
"Falha ao abrir a imagem s.fireballs[1]."
);
fclose
(
errext
);
exit
(
1
);
}
s
.
fireballs
[
2
]
=
al_load_bitmap
(
"Imgs/Fireballe.bmp"
);
if
(
!
s
.
fireballs
[
2
])
{
fprintf
(
errext
,
"Falha ao abrir a imagem s.fireballs[2]."
);
fclose
(
errext
);
exit
(
1
);
}
s
.
fireballs
[
3
]
=
al_load_bitmap
(
"Imgs/Fireballb.bmp"
);
if
(
!
s
.
fireballs
[
3
])
{
fprintf
(
errext
,
"Falha ao abrir a imagem s.fireballs[3]."
);
fclose
(
errext
);
exit
(
1
);
}
Sprite
s
=
init_sprites
(
errext
);
for
(
i
=
0
;
i
<
4
;
++
i
)
{
for
(
j
=
0
;
j
<
2
;
++
j
)
{
...
...
@@ -192,57 +72,8 @@ int main()
}
}
al_convert_mask_to_alpha
(
s
.
bar
,
al_map_rgb
(
255
,
0
,
255
));
al_convert_mask_to_alpha
(
s
.
dead
,
al_map_rgb
(
255
,
0
,
255
));
al_convert_mask_to_alpha
(
s
.
tiles
,
al_map_rgb
(
255
,
0
,
255
));
al_convert_mask_to_alpha
(
s
.
chars
,
al_map_rgb
(
255
,
0
,
255
));
al_convert_mask_to_alpha
(
s
.
explosion
,
al_map_rgb
(
255
,
0
,
255
));
al_convert_mask_to_alpha
(
s
.
healthbar
,
al_map_rgb
(
255
,
0
,
255
));
al_convert_mask_to_alpha
(
s
.
energybar
,
al_map_rgb
(
255
,
0
,
255
));
for
(
i
=
0
;
i
<
4
;
i
++
)
{
al_convert_mask_to_alpha
(
s
.
neons
[
i
],
al_map_rgb
(
255
,
0
,
255
));
al_convert_mask_to_alpha
(
s
.
fireballs
[
i
],
al_map_rgb
(
255
,
0
,
255
));
}
al_register_event_source
(
win
.
event_queue
,
al_get_display_event_source
(
win
.
display
));
/* Tentativa de otimizar - se o proximo 'for' nao for equivalente a esse, deu errado!
for(i=0; i<4; ++i) {
p[i].botao_char[0]=(char*) malloc(30*sizeof(char)); sprintf(p[i].botao_char[0],"%c",98);
if(!p[i].botao_char[0]) {
fprintf(errext,"Falha ao alocar memoria para p[%d].botao_char[0]",i);fclose(errext);exit(1);
}
p[i].botao_char[1]=(char*) malloc(30*sizeof(char)); sprintf(p[i].botao_char[1],"%c",99);
if(!p[i].botao_char[1]) {
fprintf(errext,"Falha ao alocar memoria para p[%d].botao_char[1]",i);fclose(errext);exit(1);
}
p[i].botao_char[2]=(char*) malloc(30*sizeof(char)); sprintf(p[i].botao_char[2],"%c",100);
if(!p[i].botao_char[2]) {
fprintf(errext,"Falha ao alocar memoria para p[%d].botao_char[2]",i);fclose(errext);exit(1);
}
p[i].botao_char[3]=(char*) malloc(30*sizeof(char)); sprintf(p[i].botao_char[3],"%c",101);
if(!p[i].botao_char[3]) {
fprintf(errext,"Falha ao alocar memoria para p[%d].botao_char[3]",i);fclose(errext);exit(1);
}
p[i].botao_char[4]=(char*) malloc(30*sizeof(char)); sprintf(p[0].botao_char[4],"%c",97);
if(!p[i].botao_char[4]) {
fprintf(errext,"Falha ao alocar memoria para p[%d].botao_char[4]",i);fclose(errext);exit(1);
}
p[i].botao_char[5]=(char*) malloc(30*sizeof(char)); sprintf(p[0].botao_char[5],"%c",97);
if(!p[i].botao_char[5]) {
fprintf(errext,"Falha ao alocar memoria para p[%d].botao_char[5]",i);fclose(errext);exit(1);
}
p[i].botao_char[6]=(char*) malloc(30*sizeof(char)); sprintf(p[0].botao_char[6],"%c",97);
if(!p[i].botao_char[6]) {
fprintf(errext,"Falha ao alocar memoria para p[%d].botao_char[6]",i);fclose(errext);exit(1);
}
p[i].nome =(char*) malloc(30*sizeof(char)); sprintf(p[i].nome,"player %d",i+1);
if(!p[i].nome) {
fprintf(errext,"Falha ao alocar memoria para p[%d].nome",i);fclose(errext);exit(1);
}
p[i].time = 1;
}
*/
// Comentei isso sem saber exatamente porque. Pode dar ruim.
for
(
i
=
0
;
i
<
4
;
++
i
)
{
for
(
j
=
0
;
j
<
7
;
++
j
)
{
p
[
i
].
botao_char
[
j
]
=
(
char
*
)
malloc
(
30
*
sizeof
(
char
));
...
...
@@ -256,9 +87,9 @@ int main()
sprintf
(
p
[
i
].
botao_char
[
1
],
"%c"
,
99
);
sprintf
(
p
[
i
].
botao_char
[
2
],
"%c"
,
100
);
sprintf
(
p
[
i
].
botao_char
[
3
],
"%c"
,
101
);
sprintf
(
p
[
0
].
botao_char
[
4
],
"%c"
,
97
);
sprintf
(
p
[
0
].
botao_char
[
5
],
"%c"
,
97
);
sprintf
(
p
[
0
].
botao_char
[
6
],
"%c"
,
97
);
sprintf
(
p
[
i
].
botao_char
[
4
],
"%c"
,
97
);
sprintf
(
p
[
i
].
botao_char
[
5
],
"%c"
,
97
);
sprintf
(
p
[
i
].
botao_char
[
6
],
"%c"
,
97
);
p
[
i
].
nome
=
(
char
*
)
malloc
(
30
*
sizeof
(
char
));
if
(
!
p
[
i
].
nome
)
{
fprintf
(
errext
,
"Falha ao alocar memoria para p[%d].nome"
,
i
);
...
...
@@ -270,12 +101,8 @@ int main()
teclas_iniciais
(
p
);
for
(
i
=
0
;
i
<
4
;
i
++
)
for
(
j
=
0
;
j
<
2
;
j
++
)
fireball
[
i
][
j
].
explosao
=
0
;
ALLEGRO_FONT
*
font5
;
font5
=
al_load_font
(
"Fonts/fixed_font.tga"
,
0
,
0
);
ALLEGRO_FONT
*
font
;
font
=
al_load_font
(
"Fonts/fixed_font.tga"
,
0
,
0
);
/*
if( access( Comandos/cmd.txt, F_OK ) != -1 ) {
FILE *cmd = fopen("Comandos/cmd.txt","r");
...
...
@@ -294,7 +121,7 @@ int main()
/* Opera o jogo */
if
(
abremenu
(
win
,
p
,
s
)
==
1
)
{
fase1
(
win
,
fireball
,
font
5
,
explox
,
exploy
,
p
,
s
);
fase1
(
win
,
fireball
,
font
,
explox
,
exploy
,
p
,
s
);
}
graphdeinit
(
win
);
exit
(
1
);
...
...
This diff is collapsed.
Click to expand it.
neon.h
+
1
−
4
View file @
b02d7d11
...
...
@@ -18,6 +18,3 @@
#include
"ia.h"
#include
"magia.h"
#include
"map.h"
\ No newline at end of file
//Pessoa pessoa[4];
//Magia fireball[4][2]; // 4 chars, cada um pode usar ateh 2 fireballs simultaneas.
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment