Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
Snake
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
KosmX
Snake
Commits
e28910fd
Commit
e28910fd
authored
4 years ago
by
KosmX
Browse files
Options
Downloads
Patches
Plain Diff
fix it - debug with an usable terminal....
parent
42ecf56a
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
snake.c
+13
-8
13 additions, 8 deletions
snake.c
tests/jumpto.c
+10
-0
10 additions, 0 deletions
tests/jumpto.c
with
23 additions
and
8 deletions
snake.c
+
13
−
8
View file @
e28910fd
...
...
@@ -170,7 +170,7 @@ void printChunk(chunk ch, Pos pos, screenData *scrDat){
if
(
pos
.
x
<
0
||
pos
.
y
<
0
||
pos
.
x
>=
scrDat
->
size
.
x
||
pos
.
y
>=
scrDat
->
size
.
y
){
return
;
//if pos is not on the screen, just do nothing.
}
printf
(
"\e[%d;%dH"
,
pos
.
x
*
2
,
pos
.
y
);
printf
(
"\e[%d;%dH"
,
pos
.
y
,
pos
.
x
*
2
);
for
(
int
i
=
0
;
i
<
2
;
i
++
){
printChar
(
ch
.
chars
[
i
]);
}
...
...
@@ -201,7 +201,7 @@ void print(chunk ch, Pos pos, screenData *scrDat, int width, int height){
int
updateScreenSize
(
Matrix
*
map
,
screenData
*
scrDat
){
struct
Vec2i
size
=
getWindowSize
();
size
.
x
=
size
.
x
/
2
;
size
.
y
=
size
.
y
/
2
;
size
.
y
=
size
.
y
;
//
/ 2;
//Why half?
if
(
size
.
x
==
scrDat
->
size
.
x
&&
size
.
y
==
scrDat
->
size
.
y
){
return
0
;
//no change happened
}
...
...
@@ -271,13 +271,13 @@ void updateScreen(Matrix *map, screenData *scrDat, snakeChain *head, Direction d
if
(
do_update
){
Pos
pos
;
for
(
pos
.
y
=
scrDat
->
pos
.
y
;
pos
.
y
<
scrDat
->
pos
.
y
+
scrDat
->
size
.
y
;
pos
.
y
++
){
printf
(
"\e[%d
;0
H\e[
K"
,
pos
.
y
);
//Clear the screen line
for
(
pos
.
x
=
scrDat
->
pos
.
x
;
pos
.
x
<
scrDat
->
pos
.
x
+
scrDat
->
size
.
x
;
pos
.
x
+=
2
){
if
(
pos
.
x
<
scrDat
->
size
.
x
+
map
->
width
||
scrDat
->
isXRepeat
){
print
(
map
->
matrix
[
pos
.
x
%
map
->
width
][
pos
.
y
&
map
->
height
],
pos
,
scrDat
,
map
->
width
,
map
->
height
);
printf
(
"\e[
0;
%dH\e[K"
,
pos
.
y
-
scrDat
->
pos
.
y
);
//Clear the screen line
for
(
pos
.
x
=
scrDat
->
pos
.
x
;
pos
.
x
<
scrDat
->
pos
.
x
+
scrDat
->
size
.
x
;
pos
.
x
++
){
if
(
pos
.
x
<
map
->
width
||
scrDat
->
isXRepeat
){
print
(
map
->
matrix
[
pos
.
x
%
map
->
width
][
pos
.
y
%
map
->
height
],
pos
,
scrDat
,
map
->
width
,
map
->
height
);
}
}
if
(
pos
.
y
>=
scrDat
->
size
.
y
&&
!
scrDat
->
isYRepeat
){
if
(
pos
.
y
>=
map
->
height
&&
!
scrDat
->
isYRepeat
){
break
;
}
}
...
...
@@ -729,14 +729,19 @@ int core(int argc, char const *argv[])
//----start game----
_testprint
(
&
map
);
loop
(
&
map
,
tickspeed
,
repeatMap
,
feedAmount
,
canBite
);
//test code
//printf("map:\n");
//_testprint(&map);
//_print1char(&map);
/* code */
//free stuff
rmMatrix
(
&
map
);
return
0
;
...
...
This diff is collapsed.
Click to expand it.
tests/jumpto.c
0 → 100644
+
10
−
0
View file @
e28910fd
#include
<stdio.h>
int
main
(
int
argc
,
char
const
*
argv
[])
{
int
x
,
y
;
while
(
scanf
(
" %d%d"
,
&
x
,
&
y
)
==
2
){
printf
(
"\e[%d;%dH"
,
y
,
x
);
}
return
0
;
}
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