예제 #1
0
파일: tile.go 프로젝트: Wouterbeets/gomoku
func (t *tile) white() {
	c := &tl.Cell{
		Bg: tl.RgbTo256Color(60, 150, 180),
		Fg: tl.ColorWhite,
		Ch: circle,
	}
	t.entity.SetCell(2, 1, c)
	t.player = P2
}
예제 #2
0
파일: tile.go 프로젝트: Wouterbeets/gomoku
func (t *tile) black() {
	c := &tl.Cell{
		Bg: tl.RgbTo256Color(60, 150, 180),
		Fg: tl.ColorBlack,
		Ch: circle,
	}
	t.entity.SetCell(2, 1, c)
	t.player = P1
}
예제 #3
0
func buildLevel(g *tl.Game, w, h, score int) {
	maze := generateMaze(w, h)
	l := tl.NewBaseLevel(tl.Cell{})
	g.SetLevel(l)
	g.Log("Building level with width %d and height %d", w, h)
	scoretext := tl.NewText(0, 1, "Levels explored: "+strconv.Itoa(score),
		tl.ColorBlue, tl.ColorBlack)
	g.AddEntity(tl.NewText(0, 0, "Pyramid!", tl.ColorBlue, tl.ColorBlack))
	g.AddEntity(scoretext)
	for i, row := range maze {
		for j, path := range row {
			if path == '*' {
				l.AddEntity(tl.NewRectangle(i, j, 1, 1, tl.ColorWhite))
			} else if path == 'S' {
				col := tl.RgbTo256Color(0xff, 0, 0)
				l.AddEntity(NewBlock(i, j, col, g, w, h, score, scoretext))
			} else if path == 'L' {
				l.AddEntity(tl.NewRectangle(i, j, 1, 1, tl.ColorBlue))
			}
		}
	}
}
예제 #4
0
파일: game.go 프로젝트: Wouterbeets/gomoku
	tileSizeX  = 5
	tileSizeY  = 2
	boardSize  = 19
	boardTiles = 19 * 19
	tileStr    = "  |  \n--+--"
)

const (
	START = iota
	PLAY
	WINP1
	WINP2
)

var (
	Bg tl.Attr = tl.RgbTo256Color(60, 150, 180)
	Fg tl.Attr = tl.RgbTo256Color(92, 64, 51)
)

type board struct {
	tiles     [boardSize][boardSize]int8
	tilesDisp [boardSize][boardSize]*tile
	sY        int8 //selected Y
	sX        int8 //selected X
	offsetX   int
	offsetY   int
	level     *tl.BaseLevel
	turn      int8 //current turn b.player1 or b.player2
	player1   int8 // p1 or ai1
	player2   int8 // p2 or ai2
	ComOut    chan [boardSize][boardSize]int8
예제 #5
0
	experience        int
	experienceToLevel int
	level             int
	isCasting         bool
	attacker          *Enemy
	portrait          *tl.Canvas
	sprite            *Sprite
	spellCanvases     []*tl.Canvas
}

func NewPlayer(portrait *tl.Canvas, spellCanvases []*tl.Canvas, sprite *Sprite) *Player {
	p := Player{health: 100, maxHealth: 100, mana: 100, maxMana: 100, experienceToLevel: 100, portrait: portrait, level: 1, sprite: sprite, spellCanvases: spellCanvases}
	return &p
}

var StatsBG = tl.RgbTo256Color(170, 170, 170)

func (player *Player) Draw(s *tl.Screen) {
	screenWidthidth, screenh := s.Size()
	x := player.sprite.x + screenWidthidth/2 - 30
	y := player.sprite.y + screenh - 25
	bg := tl.NewRectangle(x, y, x+20, y+10, StatsBG)
	bg.Draw(s)

	health := tl.NewText(x+1, y+1, fmt.Sprintf("%3.f%% health", float32(player.health)/float32(player.maxHealth)*100), tl.ColorRed, StatsBG)
	health.Draw(s)

	mana := tl.NewText(x+27, y+1, fmt.Sprintf("%3.f%% mana", float32(player.mana)/float32(player.maxMana)*100), tl.ColorBlue, StatsBG)
	mana.Draw(s)

	gold := tl.NewText(x+1, y+12, fmt.Sprintf("%d gold", player.gold), tl.ColorYellow, StatsBG)