Beispiel #1
0
func main() {
	rog.Open(40, 20, 1, false, "pathfinding", nil)
	for rog.Running() {
		if rog.Mouse().Left.Released {
			limit := image.Rect(0, 0, 40, 20)
			target := image.Pt(rog.Mouse().Cell.X, rog.Mouse().Cell.Y)
			path = rog.Path(level, limit, level.player, target)
		}

		for y := 0; y < 20; y++ {
			for x := 0; x < 40; x++ {
				rog.Set(x, y, nil, nil, string(level.data[y][x]))
			}
		}

		rog.Set(level.player.X, level.player.Y, nil, nil, "@")

		for _, p := range path {
			if p.X != level.player.X || p.Y != level.player.Y {
				rog.Set(p.X, p.Y, rog.Red, nil, "*")
			}
		}

		if rog.Key() == rog.Esc {
			rog.Close()
		}
		rog.Flush()
	}
}
Beispiel #2
0
func main() {
	rog.Open(20, 10, 2, false, "scales", nil)
	rog.Set(0, 3, rog.Burn(rog.Grey), drainbow, "   Discrete Scale   ")
	rog.Set(0, 6, rog.Burn(rog.Grey), lrainbow, "    Linear Scale    ")
	for rog.Running() {
		rog.Set(0, 9, nil, nil, "%v", rog.Fps())
		if rog.Key() == rog.Esc {
			rog.Close()
		}
		rog.Flush()
	}
}
Beispiel #3
0
func render() {
	base_x += 1.0
	base_y += 1.0

	alpha = alpha_lerp()
	beta = beta_lerp()

	r := uint8(r_lerp())
	g := uint8(g_lerp())
	b := uint8(b_lerp())

	for x := 0.0; x < width; x++ {
		for y := 0.0; y < height; y++ {
			px := base_x + x
			py := base_y + y

			perlin := perlin.Noise2D(px, py, int64(seed), alpha, beta, octaves)
			perlin = (perlin * .5) + .5
			perlin = math.Max(0.0, perlin)
			perlin = math.Min(1.0, perlin)

			color := rog.RGB{r, g, b}
			result := rog.Black.Alpha(color, perlin)

			rog.Set(int(x), int(y)+1, nil, result, "")
		}
	}

}
Beispiel #4
0
Datei: main.go Projekt: uriel/rog
func movePlayer(xx, yy int) {
	if xx >= 0 && yy > 0 && xx < width && yy < height-1 && tmap[yy][xx] == ' ' {
		rog.Set(x, y, white, nil, " ")
		x = xx
		y = yy
		pmap.Fov(x, y, 20, true, rog.FOVCircular)
	}
}
Beispiel #5
0
func render() {
	for c := 0; c < 4; c++ {
		switch rand.Int31n(3) {
		case 0:
			colors[c].R += uint8(5 * dirR[c])
			if colors[c].R == 255 {
				dirR[c] = -1
			} else if colors[c].R == 0 {
				dirR[c] = 1
			}
		case 1:
			colors[c].G += uint8(5 * dirG[c])
			if colors[c].G == 255 {
				dirG[c] = -1
			} else if colors[c].G == 0 {
				dirG[c] = 1
			}
		case 2:
			colors[c].B += uint8(5 * dirB[c])
			if colors[c].B == 255 {
				dirB[c] = -1
			} else if colors[c].B == 0 {
				dirB[c] = 1
			}
		}
	}

	for x := 0; x < width; x++ {
		xcoef := float64(x) / float64(width-1)
		top := colors[topLeft].Alpha(colors[topRight], xcoef)
		bot := colors[botLeft].Alpha(colors[botRight], xcoef)
		for y := 0; y < height; y++ {
			ycoef := float64(y) / float64(height-1)
			cur := top.Alpha(bot, ycoef)
			rog.Set(x, y+1, nil, cur, "")
		}
	}

	for x := 0; x < width; x++ {
		for y := 0; y < height; y++ {
			_, col, _ := rog.Get(x, y+1)
			col = col.Alpha(rog.Black, .5)
			rog.Set(x, y+1, col, nil, string(rand.Int31n(26)+97))
		}
	}
}
Beispiel #6
0
Datei: main.go Projekt: uriel/rog
func example() {
	if first {
		first = false
		for y := 0; y < height; y++ {
			for x := 0; x < width; x++ {
				if tmap[y][x] == '#' {
					pmap.Block(x, y, true)
				}
			}
		}
		movePlayer(27, 16)
	}

	if rog.Mouse.Left.Released {
		path = pmap.Path(x, y, rog.Mouse.Cell.X, rog.Mouse.Cell.Y)
	}

	switch rog.Key {
	case rog.K:
		movePlayer(x, y-1)
	case rog.J:
		movePlayer(x, y+1)
	case rog.H:
		movePlayer(x-1, y)
	case rog.L:
		movePlayer(x+1, y)
	case rog.P:
		rog.Screenshot("test")
	case rog.Escape:
		rog.Close()
	}

	for cy := 0; cy < pmap.Height(); cy++ {
		for cx := 0; cx < pmap.Width(); cx++ {
			rog.Set(cx, cy, nil, black, " ")
			if pmap.Look(cx, cy) {
				i := intensity(x, y, cx, cy, 20)
				if tmap[cy][cx] == '#' {
					rog.Set(cx, cy, nil, wall.Scale(i), "")
				} else {
					rog.Set(cx, cy, rog.Scale(1.5), floorc.Scale(i), "✵")
				}
			}
		}
	}
	rog.Set(x, y, lgrey, nil, "웃")

	for _, p := range path {
		if p.X != x || p.Y != y {
			rog.Set(p.X, p.Y, lgrey, nil, "*")
		}
	}

	runtime.ReadMemStats(&stats)
	rog.Fill(0, 0, rog.Width(), 1, lgrey, rog.Dodge(dgrey), ' ')
	rog.Set(0, 0, nil, nil, "%vFPS %vMB %vGC %vGR", rog.Fps(), stats.HeapAlloc/1000000, stats.NumGC, runtime.NumGoroutine())
	rog.Fill(0, 31, rog.Width(), 1, lgrey, rog.Dodge(dgrey), ' ')
	rog.Set(0, 31, nil, nil, "Pos: %v %v Cell: %v %v", rog.Mouse.Pos.X, rog.Mouse.Pos.Y, rog.Mouse.Cell.X, rog.Mouse.Cell.Y)
}
Beispiel #7
0
func example() {
	if first {
		first = false
		for y := 0; y < height; y++ {
			for x := 0; x < width; x++ {
				if tmap[y][x] == '#' {
					pmap.Block(x, y, true)
				}
			}
		}
		movePlayer(23, 9)
	}

	if rog.Mouse().Left.Released {
		limit := image.Rect(0, 0, 40, 20)
		target := image.Pt(rog.Mouse().Cell.X, rog.Mouse().Cell.Y)
		path = rog.Path(level, limit, image.Pt(x, y), target)
	}

	switch rog.Key() {
	case 'k':
		movePlayer(x, y-1)
	case 'j':
		movePlayer(x, y+1)
	case 'h':
		movePlayer(x-1, y)
	case 'l':
		movePlayer(x+1, y)
	case rog.Esc:
		rog.Close()
	}

	for cy := 0; cy < pmap.Height(); cy++ {
		for cx := 0; cx < pmap.Width(); cx++ {
			rog.Set(cx, cy, nil, rog.Black, " ")
			if pmap.Look(cx, cy) {
				i := intensity(x, y, cx, cy, 20)
				if tmap[cy][cx] == '#' {
					rog.Set(cx, cy, nil, wall.Scale(i), "")
				} else {
					rog.Set(cx, cy, rog.Scale(1.5), floorc.Scale(i), "✵")
				}
			}
		}
	}
	rog.Set(x, y, lgrey, nil, "웃")

	for _, p := range path {
		if p.X != x || p.Y != y {
			rog.Set(p.X, p.Y, lgrey, nil, "*")
		}
	}

	runtime.ReadMemStats(&stats)
	rog.Fill(0, 0, rog.Width(), 1, lgrey, rog.Dodge(dgrey), ' ')
	rog.Set(0, 0, nil, nil, "%vFPS %vMB %vGC %vGR", rog.Fps(), stats.HeapAlloc/1000000, stats.NumGC, runtime.NumGoroutine())
	rog.Fill(0, height-1, rog.Width(), 1, lgrey, rog.Dodge(dgrey), ' ')
	rog.Set(0, height-1, nil, nil, "Pos: %v %v Cell: %v %v", rog.Mouse().Pos.X, rog.Mouse().Pos.Y, rog.Mouse().Cell.X, rog.Mouse().Cell.Y)
}
Beispiel #8
0
func main() {
	rog.Open(20, 11, 1, false, "rog", nil)
	for rog.Running() {
		rog.Set(5, 5, nil, nil, "Hello, 世界!")
		if rog.Key() == rog.Esc {
			rog.Close()
		}
		rog.Flush()
	}
}
Beispiel #9
0
func main() {
	rog.Open(width, height+2, 1, false, "Perlin-noise Test", nil)
	for rog.Running() {
		render()
		rog.Set(0, height+1, nil, nil, "%v", rog.Fps())
		if rog.Key() == rog.Esc {
			rog.Close()
		}
		rog.Flush()
	}
}
Beispiel #10
0
func main() {
	rog.Open(width, height+2, 1, false, "tcod true color", nil)
	for rog.Running() {
		render()
		rog.Set(0, height+1, nil, nil, "%v", rog.Fps())
		if rog.Key() == rog.Esc {
			rog.Close()
		}
		rog.Flush()
	}
}
Beispiel #11
0
func main() {
	font := rog.Font("terminal1-2.png", 8, 16, "!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~ ✵웃世界¢¥¤§©¨«¬£ª±²³´¶·¸¹º»¼½¾¿☐☑═║╔╗╚╝╠╣╦╩╬░▒▓☺☻☼♀♂▀▁▂▃▄▅▆▇█ÐÑÒÓÔÕÖÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏØÙÚÛÜÝàáâãäåèéêëìíîïðñòóôõö÷ùúûüýÿ♥♦♣♠♪♬æçø←↑→↓↔↕®‼ꀥ")
	rog.Open(80, 20, 2, false, "font", font)
	for i := 0; i < 20; i++ {
		rog.Set(30, i, rog.Black, rog.White, "12345abcdeABCDE!\"#$%")
	}
	for rog.Running() {
		if rog.Key() == rog.Esc {
			rog.Close()
		}
		rog.Flush()
	}
}