updates
This commit is contained in:
43
ui/mainwindow/camera.go
Normal file
43
ui/mainwindow/camera.go
Normal file
@ -0,0 +1,43 @@
|
||||
package mainwindow
|
||||
|
||||
type GameCamera struct {
|
||||
X int
|
||||
Y int
|
||||
Width int
|
||||
Height int
|
||||
}
|
||||
|
||||
func (c *GameCamera) MoveCamera(targetX int, targetY int, mapWidth int, mapHeight int) {
|
||||
// Update the camera coordinates to the target coordinates
|
||||
x := targetX - c.Width/2
|
||||
y := targetY - c.Height/2
|
||||
|
||||
if x < 0 {
|
||||
x = 0
|
||||
}
|
||||
|
||||
if y < 0 {
|
||||
y = 0
|
||||
}
|
||||
|
||||
if x > mapWidth - c.Width {
|
||||
x = mapWidth - c.Width
|
||||
}
|
||||
|
||||
if y > mapHeight - c.Height {
|
||||
y = mapHeight - c.Height
|
||||
}
|
||||
|
||||
c.X, c.Y = x, y
|
||||
}
|
||||
|
||||
func (c *GameCamera) ToCameraCoordinates(mapX int, mapY int) (cameraX int, cameraY int) {
|
||||
// Convert coordinates on the gamemap, to coordinates on the viewport
|
||||
x, y := mapX-c.X, mapY-c.Y
|
||||
|
||||
if x < 0 || y < 0 || x >= c.Width || y >= c.Height {
|
||||
return -1, -1
|
||||
}
|
||||
|
||||
return x, y
|
||||
}
|
@ -1,12 +0,0 @@
|
||||
package mainwindow
|
||||
|
||||
//Console is a pair of layers (BG and FG) used to render something
|
||||
// All because of lack of background colors in libbearterminal
|
||||
|
||||
type Console struct {
|
||||
x,y,w,h int
|
||||
FgLayer *Layer
|
||||
BgLayer *Layer
|
||||
}
|
||||
|
||||
func NewConsole
|
@ -26,6 +26,7 @@ func (mw *MainWindow) Open() {
|
||||
fmt.Sprintf(
|
||||
//"window: size=%dx%d, title='%s v%s'; font: ./resources/fonts-bitmap/ibmnew8x12.png, size=8x12;",
|
||||
"window: size=%dx%d, title='%s v%s'; font: %s, size=8x16;",
|
||||
//"window: size=%dx%d, title='%s v%s'",
|
||||
config.MainWindowSizeX,
|
||||
config.MainWindowSizeY,
|
||||
config.Title,
|
||||
|
Reference in New Issue
Block a user