當前位置: 首頁>>代碼示例>>Golang>>正文


Golang termloop.NewGame函數代碼示例

本文整理匯總了Golang中github.com/JoelOtter/termloop.NewGame函數的典型用法代碼示例。如果您正苦於以下問題:Golang NewGame函數的具體用法?Golang NewGame怎麽用?Golang NewGame使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了NewGame函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: main

func main() {
	// create game object
	game := tl.NewGame()

	// create cell
	cell := tl.Cell{
		Bg: tl.ColorGreen,
		Fg: tl.ColorBlack,
		Ch: 'v',
	}

	// create level filled with cell
	level := tl.NewBaseLevel(cell)
	// create body of water
	level.AddEntity(tl.NewRectangle(10, 10, 50, 20, tl.ColorBlue))

	// create player
	player := Player{
		entity: tl.NewEntity(1, 1, 1, 1),
		level:  level,
	}
	player.entity.SetCell(0, 0, &tl.Cell{Fg: tl.ColorRed, Ch: '@'})

	// add player to level
	level.AddEntity(&player)

	// set level of screen
	game.Screen().SetLevel(level)

	// start the game
	game.Start()
}
開發者ID:kaibacorp,項目名稱:roguelike,代碼行數:32,代碼來源:dodgeballRL.go

示例2: main

func main() {
	g := tl.NewGame()
	sound := CreateSoundCtrl(os.Args[1], true)
	defer sound.audio.Stop()
	g.Screen().AddEntity(sound)
	g.Start()
}
開發者ID:XQYCHJ,項目名稱:termloop,代碼行數:7,代碼來源:audio.go

示例3: main

func main() {
	rand.Seed(time.Now().UTC().UnixNano())
	game := tl.NewGame()
	level := tl.NewBaseLevel(tl.Cell{
		Bg: tl.ColorWhite,
	})
	for i := 0; i < 4; i++ {
		TilePos[i] = rand.Intn(4)
		level.AddEntity(&Tile{
			r: tl.NewRectangle(X+TilePos[i]*(TileWidth+BorderWidth), Y-i*(TileHeight+BorderHeight), TileWidth, TileHeight, tl.ColorBlack),
		})
	}
	level.AddEntity(tl.NewText(X+TileWidth/2-1, Y+TileHeight, "←", tl.ColorBlack, tl.ColorWhite))
	level.AddEntity(tl.NewText(X+(TileWidth+BorderWidth)+TileWidth/2-1, Y+TileHeight, "↓", tl.ColorBlack, tl.ColorWhite))
	level.AddEntity(tl.NewText(X+2*(TileWidth+BorderWidth)+TileWidth/2-1, Y+TileHeight, "↑", tl.ColorBlack, tl.ColorWhite))
	level.AddEntity(tl.NewText(X+3*(TileWidth+BorderWidth)+TileWidth/2-1, Y+TileHeight, "→", tl.ColorBlack, tl.ColorWhite))
	level.AddEntity(&RemainingTime{
		r: tl.NewText(X+4*(TileWidth+BorderWidth), 0, fmt.Sprintf("%.3f", Time), tl.ColorRed, tl.ColorDefault),
		s: tl.NewText(0, 0, "0", tl.ColorRed, tl.ColorDefault),
		t: Time,
		m: tl.NewText(0, Y+TileHeight+1, "", tl.ColorRed, tl.ColorDefault),
		e: tl.NewText(X+4*(TileWidth+BorderWidth), Y+TileHeight+1, "", tl.ColorRed, tl.ColorDefault),
	})
	game.Screen().SetLevel(level)
	game.Start()
}
開發者ID:swapagarwal,項目名稱:gotapper,代碼行數:26,代碼來源:main.go

示例4: world

func world() {
	game := tl.NewGame()
	level := tl.NewBaseLevel(tl.Cell{
		Bg: tl.ColorWhite,
		Fg: tl.ColorWhite,
		Ch: '_',
	})
	for i := -1000; i < 1000; i = i + 40 {
		if i == 0 {
			continue
		}
		for j := -1000; j < 1000; j = j + 40 {
			level.AddEntity(tl.NewRectangle(i, j, 20, 10, tl.ColorBlue))
		}
	}
	player := Player{
		entity: tl.NewEntity(1, 1, 1, 1),
		level:  level,
	}

	player.entity.SetCell(0, 0, &tl.Cell{Fg: tl.ColorBlack, Ch: '옷'})
	level.AddEntity(&player)
	game.Screen().SetLevel(level)
	go func() {
		for {
			player.Tick(tl.Event{})
			time.Sleep(200 * time.Millisecond)
		}
	}()
	game.Start()
}
開發者ID:jackdoe,項目名稱:frankenworms,代碼行數:31,代碼來源:world.go

示例5: main

func main() {
	g := tl.NewGame()
	dat, err := ioutil.ReadFile("lorry.txt")
	check(err)
	e := tl.NewEntityFromCanvas(1, 1, tl.CanvasFromString(string(dat)))
	g.Screen().AddEntity(e)
	g.Start()
}
開發者ID:XQYCHJ,項目名稱:termloop,代碼行數:8,代碼來源:entityfromfile.go

示例6: main

func main() {
	game := tl.NewGame()

	snake := NewSnake(game)

	game.Screen().SetLevel(snake.Level())
	game.Start()
}
開發者ID:towry,項目名稱:snakego,代碼行數:8,代碼來源:main.go

示例7: main

func main() {
	g := tl.NewGame()
	g.Screen().SetFps(30)

	gamelevel.TheGameState.StartLevel(1, g.Screen())

	//	g.Screen().AddEntity(tl.NewFpsText(0, 0, tl.ColorRed, tl.ColorDefault, 0.5))
	g.Start()
}
開發者ID:pandoragabor,項目名稱:letty,代碼行數:9,代碼來源:letty.go

示例8: main

func main() {
	if len(os.Args) < 2 {
		fmt.Println("Please provide a string as first argument")
		return
	}
	g := tl.NewGame()
	g.AddEntity(&MovingText{
		text: tl.NewText(0, 0, os.Args[1], tl.ColorWhite, tl.ColorBlue),
	})
	g.Start()
}
開發者ID:oscillatingworks,項目名稱:termloop,代碼行數:11,代碼來源:movingtext.go

示例9: main

func main() {
	if len(os.Args) < 2 {
		fmt.Println("Please provide a filepath to open")
		return
	}

	g := tl.NewGame()
	c := tl.BackgroundCanvasFromFile(os.Args[1])
	g.AddEntity(NewImage(c))
	g.Start()
}
開發者ID:gandilong,項目名稱:termloop,代碼行數:11,代碼來源:image.go

示例10: NewGame

func NewGame() *Game {
	game := &Game{
		level:  startLevel,
		game:   tl.NewGame(),
		board:  NewBoard(),
		status: tl.NewText(19, 0, "", tl.ColorWhite, tl.ColorBlack),
	}
	game.player = NewPlayer(game)
	game.updateStatus()
	return game
}
開發者ID:aquilax,項目名稱:number_crusher,代碼行數:11,代碼來源:game.go

示例11: main

func main() {
	g := tl.NewGame()

	for i := 0; i < 40; i++ {
		for j := 0; j < 20; j++ {
			g.Screen().AddEntity(NewClickable(i, j, 1, 1, tl.ColorWhite))
		}
	}

	g.Start()
}
開發者ID:XQYCHJ,項目名稱:termloop,代碼行數:11,代碼來源:click.go

示例12: main

func main() {

	game := tl.NewGame()

	// pengo default maze size is 13x15
	BuildLevel(game, 15, 17, 0)

	game.SetDebugOn(false)

	game.Start()

}
開發者ID:fergstar,項目名稱:pen.go,代碼行數:12,代碼來源:main.go

示例13: main

func main() {
	g := tl.NewGame()
	l := tl.NewBaseLevel(tl.Cell{Bg: 76, Fg: 1})
	lmap, err := ioutil.ReadFile("level.json")
	checkErr(err)
	parsers := make(map[string]tl.EntityParser)
	parsers["Player"] = parsePlayer
	err = tl.LoadLevelFromMap(string(lmap), parsers, l)
	checkErr(err)
	g.Screen().SetLevel(l)
	g.Start()
}
開發者ID:XQYCHJ,項目名稱:termloop,代碼行數:12,代碼來源:levelmap.go

示例14: main

func main() {
	b := NewGame()
	board := &Board{b, &[13][13]point{}, Point{5, 2}, false,
		&[]Point{}, false, []*termloop.Text{}}

	board.build()

	game := termloop.NewGame()

	level = termloop.NewBaseLevel(termloop.Cell{})
	game.Screen().SetLevel(level)

	level.AddEntity(board)

	game.Start()
}
開發者ID:roonyh,項目名稱:go_game_jam,代碼行數:16,代碼來源:main.go

示例15: main

func main() {
	g := tl.NewGame()
	l := tl.NewBaseLevel(tl.Cell{
		Bg: tl.ColorWhite,
	})
	l.AddEntity(&CollRec{
		r:    tl.NewRectangle(3, 3, 3, 3, tl.ColorRed),
		move: true,
	})
	l.AddEntity(&CollRec{
		r:    tl.NewRectangle(7, 4, 3, 3, tl.ColorGreen),
		move: false,
	})
	g.SetLevel(l)
	g.Start()
}
開發者ID:gitter-badger,項目名稱:termloop,代碼行數:16,代碼來源:collision.go


注:本文中的github.com/JoelOtter/termloop.NewGame函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。