当前位置: 首页>>代码示例>>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;未经允许,请勿转载。