Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Bruno Freitas Tissei
boulder-dash-ASCII
Commits
82e9573b
Commit
82e9573b
authored
9 years ago
by
Bruno Freitas Tissei
Browse files
Options
Download
Plain Diff
Merge conflict
parents
a63a1a51
bb49a196
develop
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
run
+1
-0
run
src/game.c
+1
-1
src/game.c
src/maps.c
+68
-9
src/maps.c
src/timehelper.h
+1
-1
src/timehelper.h
with
71 additions
and
11 deletions
+71
-11
run
+
1
-
0
View file @
82e9573b
#!/bin/bash
export
TERM
=
xterm-256color
gcc src/
*
.c
-Wall
-o
temp
-l
curses
./temp
rm
temp
This diff is collapsed.
Click to expand it.
src/game.c
+
1
-
1
View file @
82e9573b
...
...
@@ -49,7 +49,7 @@ void update(int action) {
}
void
render
()
{
clear
();
erase
();
renderMap
(
&
level
);
refresh
();
}
This diff is collapsed.
Click to expand it.
src/maps.c
+
68
-
9
View file @
82e9573b
#include "maps.h"
char
steel
[
2
][
3
]
=
{
"
ETE
"
,
"
ETE
"
};
char
steel
[
2
][
3
]
=
{
"
# #
"
,
"
# #
"
};
char
dirt
[
2
][
3
]
=
{
"-_-"
,
"-_-"
};
char
wall
[
2
][
3
]
=
{
"
#H#
"
,
"H
#
H"
};
char
ext
[
2
][
3
]
=
{
"
ETE
"
,
"
ETE
"
};
char
wall
[
2
][
3
]
=
{
"
HHH
"
,
"H
H
H"
};
char
ext
[
2
][
3
]
=
{
"
# #
"
,
"
# #
"
};
char
rockf
[
2
][
3
]
=
{
" o "
,
"'M'"
};
char
bould
[
2
][
3
]
=
{
"
0@O"
,
"O0@
"
};
char
diamond
[
2
][
3
]
=
{
"/
-
\\
"
,
"
\\
-
/"
};
char
butterfly
[
2
][
3
]
=
{
"
\\
_
/"
,
"/
\\
"
};
char
bould
[
2
][
3
]
=
{
"
/
\\
"
,
"
\\
/
"
};
char
diamond
[
2
][
3
]
=
{
"/
=
\\
"
,
"
\\
=
/"
};
char
butterfly
[
2
][
3
]
=
{
"
\\
/
/"
,
"/
\\
\\
"
};
char
input
[
WIDTH
];
rockford
player
;
...
...
@@ -25,24 +25,58 @@ void readFileMap(map *m, char *path) {
m
->
grid
[
i
][
j
]
=
input
[
i
];
}
}
init_pair
(
1
,
COLOR_RED
,
COLOR_BLACK
);
start_color
();
init_color
(
COLOR_WHITE
,
700
,
700
,
700
);
init_color
(
COLOR_BLACK
,
0
,
0
,
0
);
init_color
(
COLOR_RED
,
556
,
276
,
76
);
init_color
(
COLOR_YELLOW
,
980
,
888
,
716
);
init_color
(
COLOR_GREEN
,
400
,
400
,
400
);
init_color
(
COLOR_BLUE
,
300
,
300
,
300
);
init_color
(
COLOR_MAGENTA
,
600
,
0
,
600
);
// dirt color
init_pair
(
1
,
COLOR_BLACK
,
COLOR_RED
);
// rock yellow color 1
init_pair
(
2
,
COLOR_YELLOW
,
COLOR_BLACK
);
// rock gray color 1
init_pair
(
3
,
COLOR_GREEN
,
COLOR_BLACK
);
// rock gray color 2
init_pair
(
9
,
COLOR_BLACK
,
COLOR_GREEN
);
// wall color
init_pair
(
4
,
COLOR_BLACK
,
COLOR_WHITE
);
// steel color
init_pair
(
5
,
COLOR_WHITE
,
COLOR_BLUE
);
// rockford color
init_pair
(
6
,
COLOR_MAGENTA
,
COLOR_BLACK
);
// diamond color
init_pair
(
7
,
COLOR_CYAN
,
COLOR_BLACK
);
fclose
(
m
->
sprite
);
}
int
x
=
0
,
d
=
0
;
void
updateMap
(
map
*
m
,
int
action
)
{
updateRockford
(
&
player
,
m
,
action
);
}
void
renderMap
(
map
*
m
)
{
int
i
,
j
,
k
,
l
;
mvprintw
(
0
,
x
,
"%c"
,
'a'
);
if
(
x
==
0
)
d
=
1
;
else
if
(
x
==
100
)
d
=
-
1
;
x
+=
d
;
for
(
j
=
0
;
j
<
HEIGHT
;
j
++
)
{
for
(
i
=
0
;
i
<
WIDTH
;
i
++
)
{
switch
(
m
->
grid
[
i
][
j
])
{
case
(
'1'
):
attron
(
COLOR_PAIR
(
5
));
for
(
k
=
0
;
k
<
2
;
k
++
)
for
(
l
=
0
;
l
<
3
;
l
++
)
mvprintw
(
2
*
j
+
k
+
1
,
3
*
i
+
l
+
1
,
"%c"
,
steel
[
k
][
l
]);
attroff
(
COLOR_PAIR
(
5
));
break
;
case
(
'2'
):
attron
(
COLOR_PAIR
(
1
));
...
...
@@ -52,29 +86,54 @@ void renderMap(map *m) {
attroff
(
COLOR_PAIR
(
1
));
break
;
case
(
'3'
):
attron
(
COLOR_PAIR
(
4
));
for
(
k
=
0
;
k
<
2
;
k
++
)
for
(
l
=
0
;
l
<
3
;
l
++
)
mvprintw
(
2
*
j
+
k
+
1
,
3
*
i
+
l
+
1
,
"%c"
,
wall
[
k
][
l
]);
attroff
(
COLOR_PAIR
(
4
));
break
;
case
(
'4'
):
attron
(
COLOR_PAIR
(
5
));
for
(
k
=
0
;
k
<
2
;
k
++
)
for
(
l
=
0
;
l
<
3
;
l
++
)
mvprintw
(
2
*
j
+
k
+
1
,
3
*
i
+
l
+
1
,
"%c"
,
ext
[
k
][
l
]);
attroff
(
COLOR_PAIR
(
5
));
break
;
case
(
'5'
):
attron
(
COLOR_PAIR
(
6
));
for
(
k
=
0
;
k
<
2
;
k
++
)
for
(
l
=
0
;
l
<
3
;
l
++
)
mvprintw
(
2
*
j
+
k
+
1
,
3
*
i
+
l
+
1
,
"%c"
,
rockf
[
k
][
l
]);
attroff
(
COLOR_PAIR
(
6
));
break
;
case
(
'6'
):
for
(
k
=
0
;
k
<
2
;
k
++
)
for
(
l
=
0
;
l
<
3
;
l
++
)
mvprintw
(
2
*
j
+
k
+
1
,
3
*
i
+
l
+
1
,
"%c"
,
bould
[
k
][
l
]);
for
(
l
=
0
;
l
<
3
;
l
++
)
{
if
(
l
==
2
&&
k
==
0
)
{
attron
(
COLOR_PAIR
(
2
));
mvprintw
(
2
*
j
+
k
+
1
,
3
*
i
+
l
+
1
,
"%c"
,
bould
[
k
][
l
]);
attroff
(
COLOR_PAIR
(
1
));
}
else
if
(
l
==
1
&&
k
==
0
)
{
attron
(
COLOR_PAIR
(
9
));
mvprintw
(
2
*
j
+
k
+
1
,
3
*
i
+
l
+
1
,
"%c"
,
bould
[
k
][
l
]);
attroff
(
COLOR_PAIR
(
9
));
}
else
if
(
l
==
1
&&
k
==
1
)
{
attron
(
COLOR_PAIR
(
9
));
mvprintw
(
2
*
j
+
k
+
1
,
3
*
i
+
l
+
1
,
"%c"
,
bould
[
k
][
l
]);
attroff
(
COLOR_PAIR
(
9
));
}
else
{
attron
(
COLOR_PAIR
(
3
));
mvprintw
(
2
*
j
+
k
+
1
,
3
*
i
+
l
+
1
,
"%c"
,
bould
[
k
][
l
]);
attroff
(
COLOR_PAIR
(
3
));
}
}
break
;
case
(
'7'
):
attron
(
COLOR_PAIR
(
7
));
for
(
k
=
0
;
k
<
2
;
k
++
)
for
(
l
=
0
;
l
<
3
;
l
++
)
mvprintw
(
2
*
j
+
k
+
1
,
3
*
i
+
l
+
1
,
"%c"
,
diamond
[
k
][
l
]);
attroff
(
COLOR_PAIR
(
7
));
break
;
case
(
'8'
):
for
(
k
=
0
;
k
<
2
;
k
++
)
...
...
This diff is collapsed.
Click to expand it.
src/timehelper.h
+
1
-
1
View file @
82e9573b
...
...
@@ -3,7 +3,7 @@
#include "utils.h"
#include <sys/time.h>
#define NANO 1000000000.0
#define FPS 1.0/
1
6.0
#define FPS 1.0/6
0
.0
double
getTime
();
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help