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
3c475789
Commit
3c475789
authored
4 years ago
by
KosmX
Browse files
Options
Downloads
Patches
Plain Diff
PLEASE WORK
parent
a008538f
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
multiplatformLib.c
+2
-1
2 additions, 1 deletion
multiplatformLib.c
multiplatformLib.h
+1
-1
1 addition, 1 deletion
multiplatformLib.h
snake.c
+2
-10
2 additions, 10 deletions
snake.c
with
5 additions
and
12 deletions
multiplatformLib.c
+
2
−
1
View file @
3c475789
...
...
@@ -42,7 +42,7 @@ struct termios term_config;
/**
* Init platform dependent stuff, mostly the custom oi control
*/
int
initMultiplatform
(
void
){
int
initMultiplatform
(
int
unicode
){
#ifdef __linux__
struct
termios
info
;
tcgetattr
(
0
,
&
info
);
//get attr
...
...
@@ -52,6 +52,7 @@ int initMultiplatform(void){
tcsetattr
(
0
,
TCSANOW
,
&
info
);
//set attr
setbuf
(
stdin
,
NULL
);
//???
#else
SetConsoleOutputCP
(
65001
);
//YES YES YES UTF in WINDOWS TERMINAL!!! :D
//Enable vt100 emulation. Without this, snake is not working
HANDLE
out
=
GetStdHandle
(
STD_OUTPUT_HANDLE
);
if
(
out
==
INVALID_HANDLE_VALUE
){
...
...
This diff is collapsed.
Click to expand it.
multiplatformLib.h
+
1
−
1
View file @
3c475789
...
...
@@ -5,7 +5,7 @@
struct
Vec2i
getWindowSize
(
void
);
int
initMultiplatform
(
void
);
int
initMultiplatform
(
int
unicode
);
void
endMultiplatformLib
(
void
);
...
...
This diff is collapsed.
Click to expand it.
snake.c
+
2
−
10
View file @
3c475789
...
...
@@ -814,6 +814,7 @@ int tick(Matrix *map, screenData *scrDat, snakeChain *snake, Direction *d, int f
printf
(
blue
);
print
(
c
,
snake
->
pos
,
scrDat
,
map
->
width
,
map
->
height
);
printf
(
"\e[0m"
);
fflush
(
stdout
);
return
0
;
// waiting for user input.
}
updateFood
(
map
,
&
foodTick
,
feedAmount
,
snake
,
scrDat
);
...
...
@@ -983,15 +984,6 @@ int core(int argc, char const *argv[])
return
2
;
}
//----init tasks----
if
(
isUnicodeEncoding
(
0
)){
#ifndef __linux__
setlocale
(
LC_ALL
,
".utf-8"
);
#endif
}
//----import map----
...
...
@@ -1010,7 +1002,7 @@ int core(int argc, char const *argv[])
_testprint
(
&
map
);
#endif
if
(
!
initMultiplatform
()){
// init stuff.
if
(
!
initMultiplatform
(
isUnicodeEncoding
(
0
)
)){
// init stuff.
printf
(
"\e[7\e[?25l"
);
//save cursor state and turn invisible cursor
loop
(
&
map
,
tickspeed
,
repeatMap
,
feedAmount
,
canBite
,
foodText
,
foodLen
);
...
...
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