Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
RogueReborn
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Analyze
Contributor analytics
Repository analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Mikhail Andrenkov
RogueReborn
Commits
5d27b504
Commit
5d27b504
authored
8 years ago
by
Ian Prins
Browse files
Options
Downloads
Plain Diff
Merge branch 'master' of
https://gitlab.cas.mcmaster.ca/andrem5/RogueReborn.git
parents
8a3912c7
0183f1d9
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main.cpp
+76
-1
76 additions, 1 deletion
src/main.cpp
terminal-large.png
+0
-0
0 additions, 0 deletions
terminal-large.png
with
76 additions
and
1 deletion
src/main.cpp
+
76
−
1
View file @
5d27b504
...
...
@@ -2,11 +2,20 @@
#include
"tcodsrc/libtcod.hpp"
#include
<random>
#include
<vector>
#include
<string>
void
putString
(
int
x
,
int
y
,
std
::
string
text
)
{
for
(
uint
i
=
0
;
i
<
text
.
size
();
i
++
){
TCODConsole
::
root
->
putChar
(
x
+
i
,
y
,
text
[
i
]);
}
}
int
main
()
{
std
::
cout
<<
"RogueReborn"
<<
std
::
endl
;
TCODConsole
::
setCustomFont
(
"terminal-large.png"
);
//Some stdlib blabber
std
::
random_device
rand_device
;
std
::
mt19937
twister
(
rand_device
());
...
...
@@ -23,7 +32,7 @@ int main() {
}
//Init console
TCODConsole
::
initRoot
(
mapx
,
mapy
,
"Rogue Reborn"
,
false
);
TCODConsole
::
initRoot
(
mapx
,
mapy
+
20
,
"Rogue Reborn"
,
false
);
//Player X and Y
int
px
=
5
,
py
=
5
;
...
...
@@ -34,6 +43,8 @@ int main() {
//Handle user input
TCOD_key_t
key
;
TCODSystem
::
checkForEvent
(
TCOD_EVENT_KEY_PRESS
,
&
key
,
NULL
);
//Arrow controls
if
(
key
.
vk
==
TCODK_UP
)
{
if
(
py
>
0
and
map
[
px
][
py
-
1
]
==
0
)
{
py
-=
1
;
...
...
@@ -52,6 +63,67 @@ int main() {
}
}
//Keypad controls
switch
(
key
.
vk
){
case
TCODK_KP1
:
if
((
py
<
mapy
-
1
and
px
>
0
)
and
map
[
px
-
1
][
py
+
1
]
==
0
)
{
py
+=
1
;
px
-=
1
;
}
break
;
case
TCODK_KP2
:
if
(
py
<
mapy
-
1
and
map
[
px
][
py
+
1
]
==
0
)
{
py
+=
1
;
}
break
;
case
TCODK_KP3
:
if
((
py
<
mapy
-
1
and
px
<
mapx
-
1
)
and
map
[
px
+
1
][
py
+
1
]
==
0
)
{
py
+=
1
;
px
+=
1
;
}
break
;
case
TCODK_KP4
:
if
(
px
>
0
and
map
[
px
-
1
][
py
]
==
0
)
{
px
-=
1
;
}
break
;
case
TCODK_KP6
:
if
(
px
<
mapx
-
1
and
map
[
px
+
1
][
py
]
==
0
)
{
px
+=
1
;
}
break
;
case
TCODK_KP7
:
if
((
py
>
0
and
px
>
0
)
and
map
[
px
-
1
][
py
-
1
]
==
0
)
{
py
-=
1
;
px
-=
1
;
}
break
;
case
TCODK_KP8
:
if
(
py
>
0
and
map
[
px
][
py
-
1
]
==
0
)
{
py
-=
1
;
}
break
;
case
TCODK_KP9
:
if
((
py
>
0
and
px
<
mapx
-
1
)
and
map
[
px
+
1
][
py
-
1
]
==
0
)
{
py
-=
1
;
px
+=
1
;
}
break
;
default
:
break
;
}
//Redraw
TCODConsole
::
root
->
clear
();
for
(
auto
x
=
0
;
x
<
mapx
;
x
++
)
{
...
...
@@ -64,6 +136,9 @@ int main() {
}
}
putString
(
0
,
40
,
"test"
);
//Place player
TCODConsole
::
root
->
putChar
(
px
,
py
,
'@'
);
...
...
This diff is collapsed.
Click to expand it.
terminal-large.png
0 → 100644
+
0
−
0
View file @
5d27b504
4.44 KiB
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