-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvariables.go
More file actions
65 lines (53 loc) · 1.85 KB
/
variables.go
File metadata and controls
65 lines (53 loc) · 1.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package main
import "github.com/gdamore/tcell/v2"
const (
MAX_TETRIS_LEVEL = 6
MAX_TETRIS_HEIGHT = 6
MIN_TETRIS_LEVEL = 0
MIN_TETRIS_HEIGHT = 0
)
var (
DEF_SF, BLUE_SF, CYAN_SF, YELLOW_SF, GREEN_SF, MAGENTA_SF, RED_SF, WHITE_SF tcell.Style
is_end bool
term_width, term_height int
is_term_too_small bool
is_initialization = true
is_select_level = true
is_elemination_session = false
cur_level = MIN_TETRIS_LEVEL
cur_height = MIN_TETRIS_HEIGHT
is_game_over bool
is_can_hold bool
is_paused bool
cur_X, cur_Y int
predict_Y int
score int
cur_tetro Tetromino
next_tetro Tetromino
hold_tetro Tetromino
cur_board TetrisBoard
pressMoveDown = make(chan bool)
updated = make(chan bool)
)
// Initialize primary style
func initStyle() {
DEF_SF = tcell.StyleDefault.Background(tcell.ColorReset).Foreground(tcell.ColorReset)
BLUE_SF = tcell.StyleDefault.Background(tcell.ColorReset).Foreground(tcell.ColorBlue)
CYAN_SF = tcell.StyleDefault.Background(tcell.ColorReset).Foreground(tcell.ColorSkyblue)
YELLOW_SF = tcell.StyleDefault.Background(tcell.ColorReset).Foreground(tcell.ColorYellow)
GREEN_SF = tcell.StyleDefault.Background(tcell.ColorReset).Foreground(tcell.ColorGreen)
MAGENTA_SF = tcell.StyleDefault.Background(tcell.ColorReset).Foreground(tcell.ColorPurple)
RED_SF = tcell.StyleDefault.Background(tcell.ColorReset).Foreground(tcell.ColorRed)
WHITE_SF = tcell.StyleDefault.Background(tcell.ColorReset).Foreground(tcell.ColorWhite)
}
func bindTermSize(width, height int) {
term_width, term_height = width, height
}
/*
DEF_SF, BLUE_SF, CYAN_SF, YELLOW_SF, GREEN_SF, MAGENTA_SF, RED_SF, WHITE_SF
Return these style from 0 - 7
*/
func getStyleByInt(index int) tcell.Style {
styleArray := []tcell.Style{WHITE_SF, BLUE_SF, CYAN_SF, YELLOW_SF, GREEN_SF, MAGENTA_SF, RED_SF, DEF_SF}
return styleArray[index]
}