Change types int32 -> int per upstream render and ui library
This commit is contained in:
parent
c1353d1c0f
commit
0437adfbf8
|
@ -7,7 +7,7 @@ var (
|
|||
Height = 768
|
||||
|
||||
// Speed to scroll a canvas with arrow keys in Edit Mode.
|
||||
CanvasScrollSpeed int32 = 8
|
||||
CanvasScrollSpeed = 8
|
||||
|
||||
// Window scrolling behavior in Play Mode.
|
||||
ScrollboxHoz = 256 // horizontal px from window border to start scrol
|
||||
|
|
|
@ -8,7 +8,7 @@ var (
|
|||
ShellBackgroundColor = render.RGBA(0, 20, 40, 200)
|
||||
ShellForegroundColor = render.RGBA(0, 153, 255, 255)
|
||||
ShellPromptColor = render.White
|
||||
ShellPadding int32 = 8
|
||||
ShellPadding = 8
|
||||
ShellFontSize = 16
|
||||
ShellFontSizeSmall = 10
|
||||
ShellCursorBlinkRate uint64 = 20
|
||||
|
|
|
@ -102,11 +102,11 @@ The returned CollisionBox uses absolute coordinates in the same space
|
|||
as the passed-in rects.
|
||||
*/
|
||||
func Overlap(a, b render.Rect) CollisionBox {
|
||||
max := func(x, y int32) int32 {
|
||||
return int32(math.Max(float64(x), float64(y)))
|
||||
max := func(x, y int) int {
|
||||
return int(math.Max(float64(x), float64(y)))
|
||||
}
|
||||
min := func(x, y int32) int32 {
|
||||
return int32(math.Min(float64(x), float64(y)))
|
||||
min := func(x, y int) int {
|
||||
return int(math.Min(float64(x), float64(y)))
|
||||
}
|
||||
|
||||
var (
|
||||
|
|
|
@ -3,9 +3,9 @@ package collision
|
|||
import (
|
||||
"sync"
|
||||
|
||||
"git.kirsle.net/go/render"
|
||||
"git.kirsle.net/apps/doodle/pkg/doodads"
|
||||
"git.kirsle.net/apps/doodle/pkg/level"
|
||||
"git.kirsle.net/go/render"
|
||||
)
|
||||
|
||||
// Collide describes how a collision occurred.
|
||||
|
@ -61,13 +61,13 @@ func CollidesWithGrid(d doodads.Actor, grid *level.Chunker, target render.Point)
|
|||
result = &Collide{
|
||||
MoveTo: P,
|
||||
}
|
||||
ceiling bool // Has hit a ceiling?
|
||||
capHeight int32 // Stop vertical movement thru a ceiling
|
||||
capLeft int32 // Stop movement thru a wall
|
||||
capRight int32
|
||||
capFloor int32 // Stop movement thru the floor
|
||||
hitLeft bool // Has hit an obstacle on the left
|
||||
hitRight bool // or right
|
||||
ceiling bool // Has hit a ceiling?
|
||||
capHeight int // Stop vertical movement thru a ceiling
|
||||
capLeft int // Stop movement thru a wall
|
||||
capRight int
|
||||
capFloor int // Stop movement thru the floor
|
||||
hitLeft bool // Has hit an obstacle on the left
|
||||
hitRight bool // or right
|
||||
hitFloor bool
|
||||
)
|
||||
|
||||
|
|
|
@ -4,10 +4,10 @@ import (
|
|||
"fmt"
|
||||
"testing"
|
||||
|
||||
"git.kirsle.net/go/render"
|
||||
"git.kirsle.net/apps/doodle/pkg/collision"
|
||||
"git.kirsle.net/apps/doodle/pkg/doodads/dummy"
|
||||
"git.kirsle.net/apps/doodle/pkg/level"
|
||||
"git.kirsle.net/go/render"
|
||||
)
|
||||
|
||||
func TestCollisionFunctions(t *testing.T) {
|
||||
|
@ -21,12 +21,12 @@ func TestCollisionFunctions(t *testing.T) {
|
|||
|
||||
// with a solid platform at y=500 and x=0..1000
|
||||
for i := 0; i < 1000; i++ {
|
||||
grid.Set(render.NewPoint(int32(i), 500), solid)
|
||||
grid.Set(render.NewPoint(i, 500), solid)
|
||||
}
|
||||
|
||||
// and a short wall in the middle of the platform
|
||||
for i := 480; i < 500; i++ {
|
||||
grid.Set(render.NewPoint(500, int32(i)), solid)
|
||||
grid.Set(render.NewPoint(500, i), solid)
|
||||
}
|
||||
|
||||
// Make a dummy player character.
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
package doodads
|
||||
|
||||
import (
|
||||
"git.kirsle.net/go/render"
|
||||
"git.kirsle.net/apps/doodle/pkg/balance"
|
||||
"git.kirsle.net/apps/doodle/pkg/level"
|
||||
"git.kirsle.net/go/render"
|
||||
)
|
||||
|
||||
// Doodad is a reusable component for Levels that have scripts and graphics.
|
||||
|
@ -53,8 +53,8 @@ func (d *Doodad) ChunkSize() int {
|
|||
func (d *Doodad) Rect() render.Rect {
|
||||
var size = d.ChunkSize()
|
||||
return render.Rect{
|
||||
W: int32(size),
|
||||
H: int32(size),
|
||||
W: size,
|
||||
H: size,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package doodads
|
||||
|
||||
import (
|
||||
"git.kirsle.net/go/render"
|
||||
"git.kirsle.net/apps/doodle/pkg/level"
|
||||
"git.kirsle.net/go/render"
|
||||
)
|
||||
|
||||
// NewDummy creates a placeholder dummy doodad with a giant "X" across it.
|
||||
|
@ -16,8 +16,8 @@ func NewDummy(size int) *Doodad {
|
|||
dummy.Palette.Swatches = []*level.Swatch{red}
|
||||
|
||||
for i := 0; i < size; i++ {
|
||||
left := render.NewPoint(int32(i), int32(i))
|
||||
right := render.NewPoint(int32(size-i), int32(i))
|
||||
left := render.NewPoint(i, i)
|
||||
right := render.NewPoint(size-i, i)
|
||||
|
||||
// Draw the stroke 2 pixels thick
|
||||
dummy.Layers[0].Chunker.Set(left, red)
|
||||
|
|
|
@ -114,7 +114,7 @@ func (d *Doodle) Run() error {
|
|||
// Poll for events.
|
||||
ev, err := d.Engine.Poll()
|
||||
// log.Error("Button1 is: %+v", ev.Button1)
|
||||
shmem.Cursor = render.NewPoint(int32(ev.CursorX), int32(ev.CursorY))
|
||||
shmem.Cursor = render.NewPoint(ev.CursorX, ev.CursorY)
|
||||
if err != nil {
|
||||
log.Error("event poll error: %s", err)
|
||||
d.running = false
|
||||
|
|
|
@ -111,10 +111,10 @@ func (s *Stroke) IterThickPoints() chan render.Rect {
|
|||
go func() {
|
||||
for pt := range s.IterPoints() {
|
||||
ch <- render.Rect{
|
||||
X: pt.X - int32(s.Thickness),
|
||||
Y: pt.Y - int32(s.Thickness),
|
||||
W: int32(s.Thickness) * 2,
|
||||
H: int32(s.Thickness) * 2,
|
||||
X: pt.X - s.Thickness,
|
||||
Y: pt.Y - s.Thickness,
|
||||
W: s.Thickness * 2,
|
||||
H: s.Thickness * 2,
|
||||
}
|
||||
}
|
||||
close(ch)
|
||||
|
|
|
@ -6,8 +6,6 @@ import (
|
|||
"os"
|
||||
"strings"
|
||||
|
||||
"git.kirsle.net/go/render"
|
||||
"git.kirsle.net/go/render/event"
|
||||
"git.kirsle.net/apps/doodle/pkg/balance"
|
||||
"git.kirsle.net/apps/doodle/pkg/doodads"
|
||||
"git.kirsle.net/apps/doodle/pkg/drawtool"
|
||||
|
@ -15,6 +13,8 @@ import (
|
|||
"git.kirsle.net/apps/doodle/pkg/level"
|
||||
"git.kirsle.net/apps/doodle/pkg/log"
|
||||
"git.kirsle.net/apps/doodle/pkg/userdir"
|
||||
"git.kirsle.net/go/render"
|
||||
"git.kirsle.net/go/render/event"
|
||||
)
|
||||
|
||||
// EditorScene manages the "Edit Level" game mode.
|
||||
|
@ -136,7 +136,7 @@ func (s *EditorScene) Setup(d *Doodle) error {
|
|||
}
|
||||
|
||||
// TODO: move inside the UI. Just an approximate position for now.
|
||||
s.UI.Canvas.Resize(render.NewRect(int32(s.DoodadSize), int32(s.DoodadSize)))
|
||||
s.UI.Canvas.Resize(render.NewRect(s.DoodadSize, s.DoodadSize))
|
||||
s.UI.Canvas.ScrollTo(render.Origin)
|
||||
s.UI.Canvas.Scrollable = false
|
||||
s.UI.Workspace.Compute(d.Engine)
|
||||
|
|
|
@ -5,9 +5,6 @@ import (
|
|||
"path/filepath"
|
||||
"strconv"
|
||||
|
||||
"git.kirsle.net/go/render"
|
||||
"git.kirsle.net/go/render/event"
|
||||
"git.kirsle.net/go/ui"
|
||||
"git.kirsle.net/apps/doodle/pkg/balance"
|
||||
"git.kirsle.net/apps/doodle/pkg/branding"
|
||||
"git.kirsle.net/apps/doodle/pkg/drawtool"
|
||||
|
@ -15,10 +12,13 @@ import (
|
|||
"git.kirsle.net/apps/doodle/pkg/level"
|
||||
"git.kirsle.net/apps/doodle/pkg/log"
|
||||
"git.kirsle.net/apps/doodle/pkg/uix"
|
||||
"git.kirsle.net/go/render"
|
||||
"git.kirsle.net/go/render/event"
|
||||
"git.kirsle.net/go/ui"
|
||||
)
|
||||
|
||||
// Width of the panel frame.
|
||||
var paletteWidth int32 = 160
|
||||
var paletteWidth = 160
|
||||
|
||||
// EditorUI manages the user interface for the Editor Scene.
|
||||
type EditorUI struct {
|
||||
|
@ -52,7 +52,7 @@ type EditorUI struct {
|
|||
doodadSkip int
|
||||
doodadRows []*ui.Frame
|
||||
doodadPager *ui.Frame
|
||||
doodadButtonSize int32
|
||||
doodadButtonSize int
|
||||
doodadScroller *ui.Frame
|
||||
|
||||
// ToolBar window.
|
||||
|
@ -130,7 +130,7 @@ func (u *EditorUI) Resized(d *Doodle) {
|
|||
// Menu Bar frame.
|
||||
{
|
||||
u.MenuBar.Configure(ui.Config{
|
||||
Width: int32(d.width),
|
||||
Width: d.width,
|
||||
Background: render.Black,
|
||||
})
|
||||
u.MenuBar.Compute(d.Engine)
|
||||
|
@ -139,11 +139,11 @@ func (u *EditorUI) Resized(d *Doodle) {
|
|||
// Status Bar.
|
||||
{
|
||||
u.StatusBar.Configure(ui.Config{
|
||||
Width: int32(d.width),
|
||||
Width: d.width,
|
||||
})
|
||||
u.StatusBar.MoveTo(render.Point{
|
||||
X: 0,
|
||||
Y: int32(d.height) - u.StatusBar.Size().H,
|
||||
Y: d.height - u.StatusBar.Size().H,
|
||||
})
|
||||
u.StatusBar.Compute(d.Engine)
|
||||
}
|
||||
|
@ -152,10 +152,10 @@ func (u *EditorUI) Resized(d *Doodle) {
|
|||
{
|
||||
u.Palette.Configure(ui.Config{
|
||||
Width: paletteWidth,
|
||||
Height: int32(u.d.height) - u.StatusBar.Size().H,
|
||||
Height: u.d.height - u.StatusBar.Size().H,
|
||||
})
|
||||
u.Palette.MoveTo(render.NewPoint(
|
||||
int32(u.d.width)-u.Palette.BoxSize().W,
|
||||
u.d.width-u.Palette.BoxSize().W,
|
||||
u.MenuBar.BoxSize().H,
|
||||
))
|
||||
u.Palette.Compute(d.Engine)
|
||||
|
@ -163,7 +163,7 @@ func (u *EditorUI) Resized(d *Doodle) {
|
|||
u.scrollDoodadFrame(0)
|
||||
}
|
||||
|
||||
var innerHeight = int32(u.d.height) - u.MenuBar.Size().H - u.StatusBar.Size().H
|
||||
var innerHeight = u.d.height - u.MenuBar.Size().H - u.StatusBar.Size().H
|
||||
|
||||
// Tool Bar.
|
||||
{
|
||||
|
@ -187,8 +187,8 @@ func (u *EditorUI) Resized(d *Doodle) {
|
|||
u.MenuBar.Size().H,
|
||||
))
|
||||
frame.Resize(render.NewRect(
|
||||
int32(d.width)-u.Palette.Size().W-u.ToolBar.Size().W,
|
||||
int32(d.height)-u.MenuBar.Size().H-u.StatusBar.Size().H,
|
||||
d.width-u.Palette.Size().W-u.ToolBar.Size().W,
|
||||
d.height-u.MenuBar.Size().H-u.StatusBar.Size().H,
|
||||
))
|
||||
frame.Compute(d.Engine)
|
||||
|
||||
|
@ -201,10 +201,10 @@ func (u *EditorUI) Resized(d *Doodle) {
|
|||
btn.Compute(d.Engine)
|
||||
|
||||
var (
|
||||
wsP = u.Workspace.Point()
|
||||
wsSize = u.Workspace.Size()
|
||||
btnSize = btn.Size()
|
||||
padding int32 = 8
|
||||
wsP = u.Workspace.Point()
|
||||
wsSize = u.Workspace.Size()
|
||||
btnSize = btn.Size()
|
||||
padding = 8
|
||||
)
|
||||
btn.MoveTo(render.NewPoint(
|
||||
wsP.X+wsSize.W-btnSize.W-padding,
|
||||
|
@ -215,7 +215,7 @@ func (u *EditorUI) Resized(d *Doodle) {
|
|||
|
||||
// Loop to process events and update the UI.
|
||||
func (u *EditorUI) Loop(ev *event.State) error {
|
||||
u.cursor = render.NewPoint(int32(ev.CursorX), int32(ev.CursorY))
|
||||
u.cursor = render.NewPoint(ev.CursorX, ev.CursorY)
|
||||
|
||||
// Loop the UI and see whether we're told to stop event propagation.
|
||||
var stopPropagation bool
|
||||
|
@ -537,7 +537,7 @@ func (u *EditorUI) SetupStatusBar(d *Doodle) *ui.Frame {
|
|||
BorderSize: 1,
|
||||
}
|
||||
|
||||
var labelHeight int32
|
||||
var labelHeight int
|
||||
for _, variable := range u.StatusBoxes {
|
||||
label := ui.NewLabel(ui.Label{
|
||||
TextVariable: variable,
|
||||
|
@ -577,7 +577,7 @@ func (u *EditorUI) SetupStatusBar(d *Doodle) *ui.Frame {
|
|||
// Set the initial good frame size to have the height secured,
|
||||
// so when resizing the application window we can just adjust for width.
|
||||
frame.Resize(render.Rect{
|
||||
W: int32(d.width),
|
||||
W: d.width,
|
||||
H: labelHeight + frame.BoxThickness(1),
|
||||
})
|
||||
frame.Compute(d.Engine)
|
||||
|
|
|
@ -7,13 +7,13 @@ package doodle
|
|||
import (
|
||||
"fmt"
|
||||
|
||||
"git.kirsle.net/go/render"
|
||||
"git.kirsle.net/go/ui"
|
||||
"git.kirsle.net/apps/doodle/pkg/balance"
|
||||
"git.kirsle.net/apps/doodle/pkg/doodads"
|
||||
"git.kirsle.net/apps/doodle/pkg/level"
|
||||
"git.kirsle.net/apps/doodle/pkg/log"
|
||||
"git.kirsle.net/apps/doodle/pkg/uix"
|
||||
"git.kirsle.net/go/render"
|
||||
"git.kirsle.net/go/ui"
|
||||
)
|
||||
|
||||
// DraggableActor is a Doodad being dragged from the Doodad palette.
|
||||
|
@ -123,7 +123,7 @@ func (u *EditorUI) setupDoodadFrame(e render.Engine, window *ui.Window) (*ui.Fra
|
|||
)
|
||||
}
|
||||
|
||||
var buttonSize = (paletteWidth - window.BoxThickness(2)) / int32(perRow)
|
||||
var buttonSize = (paletteWidth - window.BoxThickness(2)) / perRow
|
||||
u.doodadButtonSize = buttonSize
|
||||
|
||||
// Load all the doodads, skip hidden ones.
|
||||
|
@ -218,8 +218,8 @@ func (u *EditorUI) scrollDoodadFrame(rows int) {
|
|||
|
||||
// Calculate about how many rows we can see given our current window size.
|
||||
var (
|
||||
maxVisibleHeight = int32(u.d.height - 86)
|
||||
calculatedHeight int32
|
||||
maxVisibleHeight = u.d.height - 86
|
||||
calculatedHeight int
|
||||
rowsBefore int // count of rows hidden before
|
||||
rowsVisible int
|
||||
rowsAfter int // count of rows hidden after
|
||||
|
@ -263,7 +263,7 @@ func (u *EditorUI) scrollDoodadFrame(rows int) {
|
|||
|
||||
var viewPercent = float64(rowsBefore+rowsVisible) / float64(len(u.doodadRows))
|
||||
u.doodadScroller.Configure(ui.Config{
|
||||
Width: int32(float64(paletteWidth-50) * viewPercent), // TODO: hacky magic number
|
||||
Width: int(float64(paletteWidth-50) * viewPercent), // TODO: hacky magic number
|
||||
})
|
||||
|
||||
}
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
package doodle
|
||||
|
||||
import (
|
||||
"git.kirsle.net/go/render"
|
||||
"git.kirsle.net/go/ui"
|
||||
"git.kirsle.net/apps/doodle/pkg/balance"
|
||||
"git.kirsle.net/apps/doodle/pkg/drawtool"
|
||||
"git.kirsle.net/apps/doodle/pkg/sprites"
|
||||
"git.kirsle.net/go/render"
|
||||
"git.kirsle.net/go/ui"
|
||||
)
|
||||
|
||||
// Width of the toolbar frame.
|
||||
var toolbarWidth int32 = 44 // 38px button (32px sprite + borders) + padding
|
||||
var toolbarSpriteSize int32 = 32 // 32x32 sprites.
|
||||
var toolbarWidth = 44 // 38px button (32px sprite + borders) + padding
|
||||
var toolbarSpriteSize = 32 // 32x32 sprites.
|
||||
|
||||
// SetupToolbar configures the UI for the Tools panel.
|
||||
func (u *EditorUI) SetupToolbar(d *Doodle) *ui.Frame {
|
||||
|
@ -137,7 +137,7 @@ func (u *EditorUI) SetupToolbar(d *Doodle) *ui.Frame {
|
|||
image,
|
||||
)
|
||||
|
||||
var btnSize int32 = btn.BoxThickness(2) + toolbarSpriteSize
|
||||
var btnSize = btn.BoxThickness(2) + toolbarSpriteSize
|
||||
btn.Resize(render.NewRect(btnSize, btnSize))
|
||||
|
||||
btn.Handle(ui.Click, func(p render.Point) {
|
||||
|
|
22
pkg/fps.go
22
pkg/fps.go
|
@ -4,11 +4,11 @@ import (
|
|||
"fmt"
|
||||
"strings"
|
||||
|
||||
"git.kirsle.net/go/render"
|
||||
"git.kirsle.net/go/ui"
|
||||
"git.kirsle.net/apps/doodle/pkg/balance"
|
||||
"git.kirsle.net/apps/doodle/pkg/collision"
|
||||
"git.kirsle.net/apps/doodle/pkg/doodads"
|
||||
"git.kirsle.net/go/render"
|
||||
"git.kirsle.net/go/ui"
|
||||
)
|
||||
|
||||
// Frames to cache for FPS calculation.
|
||||
|
@ -20,11 +20,11 @@ var (
|
|||
DebugOverlay = false
|
||||
DebugCollision = false
|
||||
|
||||
DebugTextPadding int32 = 8
|
||||
DebugTextSize = 24
|
||||
DebugTextColor = render.SkyBlue
|
||||
DebugTextStroke = render.Grey
|
||||
DebugTextShadow = render.Black
|
||||
DebugTextPadding = 8
|
||||
DebugTextSize = 24
|
||||
DebugTextColor = render.SkyBlue
|
||||
DebugTextStroke = render.Grey
|
||||
DebugTextShadow = render.Black
|
||||
)
|
||||
|
||||
var (
|
||||
|
@ -57,10 +57,10 @@ func (d *Doodle) DrawDebugOverlay() {
|
|||
}
|
||||
|
||||
var (
|
||||
darken = balance.DebugStrokeDarken
|
||||
Yoffset int32 = 20 // leave room for the menu bar
|
||||
Xoffset int32 = 20
|
||||
keys = []string{
|
||||
darken = balance.DebugStrokeDarken
|
||||
Yoffset = 20 // leave room for the menu bar
|
||||
Xoffset = 20
|
||||
keys = []string{
|
||||
"FPS:",
|
||||
"Scene:",
|
||||
"Mouse:",
|
||||
|
|
|
@ -3,12 +3,12 @@ package doodle
|
|||
import (
|
||||
"fmt"
|
||||
|
||||
"git.kirsle.net/go/render"
|
||||
"git.kirsle.net/go/render/event"
|
||||
"git.kirsle.net/go/ui"
|
||||
"git.kirsle.net/apps/doodle/pkg/balance"
|
||||
"git.kirsle.net/apps/doodle/pkg/branding"
|
||||
"git.kirsle.net/apps/doodle/pkg/log"
|
||||
"git.kirsle.net/go/render"
|
||||
"git.kirsle.net/go/render/event"
|
||||
"git.kirsle.net/go/ui"
|
||||
)
|
||||
|
||||
// GUITestScene implements the main menu of Doodle.
|
||||
|
@ -269,14 +269,14 @@ func (s *GUITestScene) Draw(d *Doodle) error {
|
|||
})
|
||||
label.Compute(d.Engine)
|
||||
label.MoveTo(render.Point{
|
||||
X: (int32(d.width) / 2) - (label.Size().W / 2),
|
||||
X: (d.width / 2) - (label.Size().W / 2),
|
||||
Y: 40,
|
||||
})
|
||||
label.Present(d.Engine, label.Point())
|
||||
|
||||
s.Window.Compute(d.Engine)
|
||||
s.Window.MoveTo(render.Point{
|
||||
X: (int32(d.width) / 2) - (s.Window.Size().W / 2),
|
||||
X: (d.width / 2) - (s.Window.Size().W / 2),
|
||||
Y: 100,
|
||||
})
|
||||
s.Window.Present(d.Engine, s.Window.Point())
|
||||
|
|
|
@ -6,10 +6,10 @@ import (
|
|||
"image"
|
||||
"math"
|
||||
|
||||
"git.kirsle.net/go/render"
|
||||
"git.kirsle.net/apps/doodle/pkg/balance"
|
||||
"git.kirsle.net/apps/doodle/pkg/log"
|
||||
"git.kirsle.net/apps/doodle/pkg/shmem"
|
||||
"git.kirsle.net/go/render"
|
||||
"github.com/google/uuid"
|
||||
"github.com/vmihailenco/msgpack"
|
||||
)
|
||||
|
@ -153,8 +153,8 @@ func (c *Chunk) ToBitmap(filename string, mask render.Color) (render.Texturer, e
|
|||
// Pixel coordinate offset to map the Chunk World Position to the
|
||||
// smaller image boundaries.
|
||||
pointOffset := render.Point{
|
||||
X: int32(c.Point.X * int32(c.Size)),
|
||||
Y: int32(c.Point.Y * int32(c.Size)),
|
||||
X: c.Point.X * c.Size,
|
||||
Y: c.Point.Y * c.Size,
|
||||
}
|
||||
|
||||
// Blot all the pixels onto it.
|
||||
|
@ -169,8 +169,8 @@ func (c *Chunk) ToBitmap(filename string, mask render.Color) (render.Texturer, e
|
|||
}
|
||||
}
|
||||
img.Set(
|
||||
int(px.X-pointOffset.X),
|
||||
int(px.Y-pointOffset.Y),
|
||||
px.X-pointOffset.X,
|
||||
px.Y-pointOffset.Y,
|
||||
color.ToColor(),
|
||||
)
|
||||
}
|
||||
|
@ -229,8 +229,8 @@ func (c *Chunk) Rect() render.Rect {
|
|||
func (c *Chunk) SizePositive() render.Rect {
|
||||
S := c.Rect()
|
||||
return render.Rect{
|
||||
W: int32(math.Abs(float64(S.X))) + S.W,
|
||||
H: int32(math.Abs(float64(S.Y))) + S.H,
|
||||
W: int(math.Abs(float64(S.X))) + S.W,
|
||||
H: int(math.Abs(float64(S.Y))) + S.H,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -5,8 +5,8 @@ import (
|
|||
"fmt"
|
||||
"math"
|
||||
|
||||
"git.kirsle.net/go/render"
|
||||
"git.kirsle.net/apps/doodle/pkg/log"
|
||||
"git.kirsle.net/go/render"
|
||||
"github.com/vmihailenco/msgpack"
|
||||
)
|
||||
|
||||
|
@ -76,8 +76,8 @@ func (c *Chunker) IterViewportChunks(viewport render.Rect) <-chan render.Point {
|
|||
go func() {
|
||||
sent := make(map[render.Point]interface{})
|
||||
|
||||
for x := viewport.X; x < viewport.W; x += int32(c.Size / 4) {
|
||||
for y := viewport.Y; y < viewport.H; y += int32(c.Size / 4) {
|
||||
for x := viewport.X; x < viewport.W; x += (c.Size / 4) {
|
||||
for y := viewport.Y; y < viewport.H; y += (c.Size / 4) {
|
||||
|
||||
// Constrain this chunksize step to a point within the bounds
|
||||
// of the viewport. This can yield partial chunks on the edges
|
||||
|
@ -135,7 +135,7 @@ func (c *Chunker) WorldSize() render.Rect {
|
|||
var (
|
||||
chunkLowest render.Point
|
||||
chunkHighest render.Point
|
||||
size = int32(c.Size)
|
||||
size = c.Size
|
||||
)
|
||||
|
||||
for coord := range c.Chunks {
|
||||
|
@ -169,8 +169,8 @@ func (c *Chunker) WorldSizePositive() render.Rect {
|
|||
return render.Rect{
|
||||
X: 0,
|
||||
Y: 0,
|
||||
W: int32(math.Abs(float64(S.X))) + S.W,
|
||||
H: int32(math.Abs(float64(S.Y))) + S.H,
|
||||
W: int(math.Abs(float64(S.X))) + S.W,
|
||||
H: int(math.Abs(float64(S.Y))) + S.H,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -271,8 +271,8 @@ func (c *Chunker) ChunkCoordinate(abs render.Point) render.Point {
|
|||
|
||||
size := float64(c.Size)
|
||||
return render.NewPoint(
|
||||
int32(math.Floor(float64(abs.X)/size)),
|
||||
int32(math.Floor(float64(abs.Y)/size)),
|
||||
int(math.Floor(float64(abs.X)/size)),
|
||||
int(math.Floor(float64(abs.Y)/size)),
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -4,8 +4,8 @@ import (
|
|||
"fmt"
|
||||
"testing"
|
||||
|
||||
"git.kirsle.net/go/render"
|
||||
"git.kirsle.net/apps/doodle/pkg/level"
|
||||
"git.kirsle.net/go/render"
|
||||
)
|
||||
|
||||
func TestWorldSize(t *testing.T) {
|
||||
|
@ -86,8 +86,8 @@ func TestWorldSize(t *testing.T) {
|
|||
|
||||
func TestViewportChunks(t *testing.T) {
|
||||
// Initialize a 100 chunk image with 5x5 chunks.
|
||||
var ChunkSize int32 = 100
|
||||
var Offset int32 = 50
|
||||
var ChunkSize int = 100
|
||||
var Offset int = 50
|
||||
c := level.NewChunker(int(ChunkSize))
|
||||
sw := &level.Swatch{
|
||||
Name: "solid",
|
||||
|
@ -103,8 +103,8 @@ func TestViewportChunks(t *testing.T) {
|
|||
// The chunk size is 100px so place a single pixel in each
|
||||
// 100px quadrant.
|
||||
fmt.Printf("size=%d offset=%d\n", ChunkSize, Offset)
|
||||
for x := int32(-2); x <= 2; x++ {
|
||||
for y := int32(-2); y <= 2; y++ {
|
||||
for x := -2; x <= 2; x++ {
|
||||
for y := -2; y <= 2; y++ {
|
||||
point := render.NewPoint(
|
||||
x*ChunkSize+Offset,
|
||||
y*ChunkSize+Offset,
|
||||
|
|
|
@ -4,9 +4,9 @@ import (
|
|||
"encoding/json"
|
||||
"fmt"
|
||||
|
||||
"git.kirsle.net/go/render"
|
||||
"git.kirsle.net/apps/doodle/pkg/balance"
|
||||
"git.kirsle.net/apps/doodle/pkg/drawtool"
|
||||
"git.kirsle.net/go/render"
|
||||
)
|
||||
|
||||
// Useful variables.
|
||||
|
@ -73,9 +73,9 @@ func New() *Level {
|
|||
|
||||
// Pixel associates a coordinate with a palette index.
|
||||
type Pixel struct {
|
||||
X int32 `json:"x"`
|
||||
Y int32 `json:"y"`
|
||||
PaletteIndex int32 `json:"p"`
|
||||
X int `json:"x"`
|
||||
Y int `json:"y"`
|
||||
PaletteIndex int `json:"p"`
|
||||
|
||||
// Private runtime values.
|
||||
Swatch *Swatch `json:"-"` // pointer to its swatch, for when rendered.
|
||||
|
@ -103,7 +103,7 @@ func (p Pixel) MarshalJSON() ([]byte, error) {
|
|||
|
||||
// UnmarshalJSON loads a Pixel from JSON again.
|
||||
func (p *Pixel) UnmarshalJSON(text []byte) error {
|
||||
var triplet []int32
|
||||
var triplet []int
|
||||
err := json.Unmarshal(text, &triplet)
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
package doodle
|
||||
|
||||
import (
|
||||
"git.kirsle.net/go/render"
|
||||
"git.kirsle.net/go/render/event"
|
||||
"git.kirsle.net/go/ui"
|
||||
"git.kirsle.net/apps/doodle/pkg/balance"
|
||||
"git.kirsle.net/apps/doodle/pkg/branding"
|
||||
"git.kirsle.net/apps/doodle/pkg/level"
|
||||
"git.kirsle.net/apps/doodle/pkg/log"
|
||||
"git.kirsle.net/apps/doodle/pkg/scripting"
|
||||
"git.kirsle.net/apps/doodle/pkg/uix"
|
||||
"git.kirsle.net/go/render"
|
||||
"git.kirsle.net/go/render/event"
|
||||
"git.kirsle.net/go/ui"
|
||||
)
|
||||
|
||||
// MainScene implements the main menu of Doodle.
|
||||
|
@ -84,8 +84,8 @@ func (s *MainScene) SetupDemoLevel(d *Doodle) error {
|
|||
s.canvas = uix.NewCanvas(100, false)
|
||||
s.canvas.Scrollable = true
|
||||
s.canvas.Resize(render.Rect{
|
||||
W: int32(d.width),
|
||||
H: int32(d.height),
|
||||
W: d.width,
|
||||
H: d.height,
|
||||
})
|
||||
|
||||
s.scripting = scripting.NewSupervisor()
|
||||
|
@ -128,8 +128,8 @@ func (s *MainScene) Loop(d *Doodle, ev *event.State) error {
|
|||
d.height = h
|
||||
log.Info("Resized to %dx%d", d.width, d.height)
|
||||
s.canvas.Resize(render.Rect{
|
||||
W: int32(d.width),
|
||||
H: int32(d.height),
|
||||
W: d.width,
|
||||
H: d.height,
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -147,8 +147,8 @@ func (s *MainScene) Draw(d *Doodle) error {
|
|||
d.Engine.DrawBox(render.RGBA(255, 255, 254, 128), render.Rect{
|
||||
X: 0,
|
||||
Y: 0,
|
||||
W: int32(d.width),
|
||||
H: int32(d.height),
|
||||
W: d.width,
|
||||
H: d.height,
|
||||
})
|
||||
|
||||
label := ui.NewLabel(ui.Label{
|
||||
|
@ -162,14 +162,14 @@ func (s *MainScene) Draw(d *Doodle) error {
|
|||
})
|
||||
label.Compute(d.Engine)
|
||||
label.MoveTo(render.Point{
|
||||
X: (int32(d.width) / 2) - (label.Size().W / 2),
|
||||
X: (d.width / 2) - (label.Size().W / 2),
|
||||
Y: 120,
|
||||
})
|
||||
label.Present(d.Engine, label.Point())
|
||||
|
||||
s.frame.Compute(d.Engine)
|
||||
s.frame.MoveTo(render.Point{
|
||||
X: (int32(d.width) / 2) - (s.frame.Size().W / 2),
|
||||
X: (d.width / 2) - (s.frame.Size().W / 2),
|
||||
Y: 260,
|
||||
})
|
||||
s.frame.Present(d.Engine, s.frame.Point())
|
||||
|
|
|
@ -3,15 +3,15 @@ package doodle
|
|||
import (
|
||||
"fmt"
|
||||
|
||||
"git.kirsle.net/go/render"
|
||||
"git.kirsle.net/go/render/event"
|
||||
"git.kirsle.net/go/ui"
|
||||
"git.kirsle.net/apps/doodle/pkg/balance"
|
||||
"git.kirsle.net/apps/doodle/pkg/enum"
|
||||
"git.kirsle.net/apps/doodle/pkg/level"
|
||||
"git.kirsle.net/apps/doodle/pkg/log"
|
||||
"git.kirsle.net/apps/doodle/pkg/uix"
|
||||
"git.kirsle.net/apps/doodle/pkg/userdir"
|
||||
"git.kirsle.net/go/render"
|
||||
"git.kirsle.net/go/render/event"
|
||||
"git.kirsle.net/go/ui"
|
||||
)
|
||||
|
||||
/*
|
||||
|
@ -82,8 +82,8 @@ func (s *MenuScene) Setup(d *Doodle) error {
|
|||
// Set up the background wallpaper canvas.
|
||||
s.canvas = uix.NewCanvas(100, false)
|
||||
s.canvas.Resize(render.Rect{
|
||||
W: int32(d.width),
|
||||
H: int32(d.height),
|
||||
W: d.width,
|
||||
H: d.height,
|
||||
})
|
||||
s.canvas.LoadLevel(d.Engine, &level.Level{
|
||||
Chunker: level.NewChunker(100),
|
||||
|
@ -127,8 +127,8 @@ func (s *MenuScene) setupNewWindow(d *Doodle) error {
|
|||
|
||||
window := ui.NewWindow("New Drawing")
|
||||
window.Configure(ui.Config{
|
||||
Width: int32(float64(d.width) * 0.75),
|
||||
Height: int32(float64(d.height) * 0.75),
|
||||
Width: int(float64(d.width) * 0.75),
|
||||
Height: int(float64(d.height) * 0.75),
|
||||
Background: render.Grey,
|
||||
})
|
||||
window.Compute(d.Engine)
|
||||
|
@ -324,8 +324,8 @@ func (s *MenuScene) setupNewWindow(d *Doodle) error {
|
|||
func (s *MenuScene) setupLoadWindow(d *Doodle) error {
|
||||
window := ui.NewWindow("Open Drawing")
|
||||
window.Configure(ui.Config{
|
||||
Width: int32(float64(d.width) * 0.75),
|
||||
Height: int32(float64(d.height) * 0.75),
|
||||
Width: int(float64(d.width) * 0.75),
|
||||
Height: int(float64(d.height) * 0.75),
|
||||
Background: render.Grey,
|
||||
})
|
||||
window.Compute(d.Engine)
|
||||
|
@ -508,7 +508,7 @@ func (s *MenuScene) Draw(d *Doodle) error {
|
|||
|
||||
s.window.Compute(d.Engine)
|
||||
s.window.MoveTo(render.Point{
|
||||
X: (int32(d.width) / 2) - (s.window.Size().W / 2),
|
||||
X: (d.width / 2) - (s.window.Size().W / 2),
|
||||
Y: 60,
|
||||
})
|
||||
s.window.Present(d.Engine, s.window.Point())
|
||||
|
|
|
@ -3,9 +3,6 @@ package doodle
|
|||
import (
|
||||
"fmt"
|
||||
|
||||
"git.kirsle.net/go/render"
|
||||
"git.kirsle.net/go/render/event"
|
||||
"git.kirsle.net/go/ui"
|
||||
"git.kirsle.net/apps/doodle/pkg/balance"
|
||||
"git.kirsle.net/apps/doodle/pkg/collision"
|
||||
"git.kirsle.net/apps/doodle/pkg/doodads"
|
||||
|
@ -13,6 +10,9 @@ import (
|
|||
"git.kirsle.net/apps/doodle/pkg/log"
|
||||
"git.kirsle.net/apps/doodle/pkg/scripting"
|
||||
"git.kirsle.net/apps/doodle/pkg/uix"
|
||||
"git.kirsle.net/go/render"
|
||||
"git.kirsle.net/go/render/event"
|
||||
"git.kirsle.net/go/ui"
|
||||
)
|
||||
|
||||
// PlayScene manages the "Edit Level" game mode.
|
||||
|
@ -114,7 +114,7 @@ func (s *PlayScene) Setup(d *Doodle) error {
|
|||
s.drawing = uix.NewCanvas(balance.ChunkSize, false)
|
||||
s.drawing.Name = "play-canvas"
|
||||
s.drawing.MoveTo(render.Origin)
|
||||
s.drawing.Resize(render.NewRect(int32(d.width), int32(d.height)))
|
||||
s.drawing.Resize(render.NewRect(d.width, d.height))
|
||||
s.drawing.Compute(d.Engine)
|
||||
|
||||
// Handler when an actor touches water or fire.
|
||||
|
@ -305,7 +305,7 @@ func (s *PlayScene) DieByFire() {
|
|||
// Loop the editor scene.
|
||||
func (s *PlayScene) Loop(d *Doodle, ev *event.State) error {
|
||||
// Update debug overlay values.
|
||||
*s.debWorldIndex = s.drawing.WorldIndexAt(render.NewPoint(int32(ev.CursorX), int32(ev.CursorY))).String()
|
||||
*s.debWorldIndex = s.drawing.WorldIndexAt(render.NewPoint(ev.CursorX, ev.CursorY)).String()
|
||||
*s.debPosition = s.Player.Position().String() + " vel " + s.Player.Velocity().String()
|
||||
*s.debViewport = s.drawing.Viewport().String()
|
||||
*s.debScroll = s.drawing.Scroll.String()
|
||||
|
@ -318,7 +318,7 @@ func (s *PlayScene) Loop(d *Doodle, ev *event.State) error {
|
|||
if w != d.width || h != d.height {
|
||||
d.width = w
|
||||
d.height = h
|
||||
s.drawing.Resize(render.NewRect(int32(d.width), int32(d.height)))
|
||||
s.drawing.Resize(render.NewRect(d.width, d.height))
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
@ -358,9 +358,9 @@ func (s *PlayScene) Draw(d *Doodle) error {
|
|||
|
||||
// Draw the Edit button.
|
||||
var (
|
||||
canSize = s.drawing.Size()
|
||||
size = s.editButton.Size()
|
||||
padding int32 = 8
|
||||
canSize = s.drawing.Size()
|
||||
size = s.editButton.Size()
|
||||
padding = 8
|
||||
)
|
||||
s.editButton.Present(d.Engine, render.Point{
|
||||
X: canSize.W - size.W - padding,
|
||||
|
@ -371,8 +371,8 @@ func (s *PlayScene) Draw(d *Doodle) error {
|
|||
if !s.alertBox.Hidden() {
|
||||
s.alertBox.Compute(d.Engine)
|
||||
s.alertBox.MoveTo(render.Point{
|
||||
X: int32(d.width/2) - (s.alertBox.Size().W / 2),
|
||||
Y: int32(d.height/2) - (s.alertBox.Size().H / 2),
|
||||
X: (d.width / 2) - (s.alertBox.Size().W / 2),
|
||||
Y: (d.height / 2) - (s.alertBox.Size().H / 2),
|
||||
})
|
||||
s.alertBox.Present(d.Engine, s.alertBox.Point())
|
||||
}
|
||||
|
@ -382,8 +382,7 @@ func (s *PlayScene) Draw(d *Doodle) error {
|
|||
|
||||
// movePlayer updates the player's X,Y coordinate based on key pressed.
|
||||
func (s *PlayScene) movePlayer(ev *event.State) {
|
||||
var playerSpeed = int32(balance.PlayerMaxVelocity)
|
||||
// var gravity = int32(balance.Gravity)
|
||||
var playerSpeed = balance.PlayerMaxVelocity
|
||||
|
||||
var velocity render.Point
|
||||
|
||||
|
|
22
pkg/shell.go
22
pkg/shell.go
|
@ -5,12 +5,12 @@ import (
|
|||
"fmt"
|
||||
"strings"
|
||||
|
||||
"git.kirsle.net/go/render"
|
||||
"git.kirsle.net/go/render/event"
|
||||
"git.kirsle.net/go/ui"
|
||||
"git.kirsle.net/apps/doodle/pkg/balance"
|
||||
"git.kirsle.net/apps/doodle/pkg/log"
|
||||
"git.kirsle.net/apps/doodle/pkg/shmem"
|
||||
"git.kirsle.net/go/render"
|
||||
"git.kirsle.net/go/render/event"
|
||||
"git.kirsle.net/go/ui"
|
||||
"github.com/robertkrimen/otto"
|
||||
)
|
||||
|
||||
|
@ -278,21 +278,21 @@ func (s *Shell) Draw(d *Doodle, ev *event.State) error {
|
|||
}
|
||||
|
||||
// How tall is the box?
|
||||
boxHeight := int32(lineHeight*(balance.ShellHistoryLineCount+1)) + balance.ShellPadding
|
||||
boxHeight := (lineHeight * (balance.ShellHistoryLineCount + 1)) + balance.ShellPadding
|
||||
|
||||
// Draw the background color.
|
||||
d.Engine.DrawBox(
|
||||
balance.ShellBackgroundColor,
|
||||
render.Rect{
|
||||
X: 0,
|
||||
Y: int32(d.height) - boxHeight,
|
||||
W: int32(d.width),
|
||||
Y: d.height - boxHeight,
|
||||
W: d.width,
|
||||
H: boxHeight,
|
||||
},
|
||||
)
|
||||
|
||||
// Draw the recent commands.
|
||||
outputY := int32(d.height - (lineHeight * 2))
|
||||
outputY := d.height - (lineHeight * 2)
|
||||
for i := 0; i < balance.ShellHistoryLineCount; i++ {
|
||||
if len(s.Output) > i {
|
||||
line := s.Output[len(s.Output)-1-i]
|
||||
|
@ -309,7 +309,7 @@ func (s *Shell) Draw(d *Doodle, ev *event.State) error {
|
|||
},
|
||||
)
|
||||
}
|
||||
outputY -= int32(lineHeight)
|
||||
outputY -= lineHeight
|
||||
}
|
||||
|
||||
// Draw the command prompt.
|
||||
|
@ -322,14 +322,14 @@ func (s *Shell) Draw(d *Doodle, ev *event.State) error {
|
|||
},
|
||||
render.Point{
|
||||
X: balance.ShellPadding,
|
||||
Y: int32(d.height-balance.ShellFontSize) - balance.ShellPadding,
|
||||
Y: d.height - balance.ShellFontSize - balance.ShellPadding,
|
||||
},
|
||||
)
|
||||
} else if len(s.Flashes) > 0 {
|
||||
// Otherwise, just draw flashed messages.
|
||||
valid := false // Did we actually draw any?
|
||||
|
||||
outputY := int32(d.height - (lineHeight * 2) - 16)
|
||||
outputY := d.height - (lineHeight * 2) - 16
|
||||
for i := len(s.Flashes); i > 0; i-- {
|
||||
flash := s.Flashes[i-1]
|
||||
if shmem.Tick >= flash.Expires {
|
||||
|
@ -349,7 +349,7 @@ func (s *Shell) Draw(d *Doodle, ev *event.State) error {
|
|||
Y: outputY,
|
||||
},
|
||||
)
|
||||
outputY -= int32(lineHeight)
|
||||
outputY -= lineHeight
|
||||
valid = true
|
||||
}
|
||||
|
||||
|
|
|
@ -4,9 +4,9 @@ import (
|
|||
"errors"
|
||||
"fmt"
|
||||
|
||||
"git.kirsle.net/go/render"
|
||||
"git.kirsle.net/apps/doodle/pkg/doodads"
|
||||
"git.kirsle.net/apps/doodle/pkg/level"
|
||||
"git.kirsle.net/go/render"
|
||||
"github.com/google/uuid"
|
||||
"github.com/robertkrimen/otto"
|
||||
)
|
||||
|
@ -45,7 +45,7 @@ func NewActor(id string, levelActor *level.Actor, doodad *doodads.Doodad) *Actor
|
|||
id = uuid.Must(uuid.NewRandom()).String()
|
||||
}
|
||||
|
||||
size := int32(doodad.Layers[0].Chunker.Size)
|
||||
size := doodad.Layers[0].Chunker.Size
|
||||
can := NewCanvas(int(size), false)
|
||||
can.Name = id
|
||||
|
||||
|
@ -83,10 +83,10 @@ func (a *Actor) GetBoundingRect() render.Rect {
|
|||
// SetHitbox sets the actor's elected hitbox.
|
||||
func (a *Actor) SetHitbox(x, y, w, h int) {
|
||||
a.hitbox = render.Rect{
|
||||
X: int32(x),
|
||||
Y: int32(y),
|
||||
W: int32(w),
|
||||
H: int32(h),
|
||||
X: x,
|
||||
Y: y,
|
||||
W: w,
|
||||
H: h,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -5,12 +5,12 @@ import (
|
|||
"sync"
|
||||
"time"
|
||||
|
||||
"git.kirsle.net/go/render"
|
||||
"git.kirsle.net/apps/doodle/pkg/balance"
|
||||
"git.kirsle.net/apps/doodle/pkg/collision"
|
||||
"git.kirsle.net/apps/doodle/pkg/doodads"
|
||||
"git.kirsle.net/apps/doodle/pkg/log"
|
||||
"git.kirsle.net/apps/doodle/pkg/scripting"
|
||||
"git.kirsle.net/go/render"
|
||||
"github.com/robertkrimen/otto"
|
||||
)
|
||||
|
||||
|
@ -59,7 +59,7 @@ func (w *Canvas) loopActorCollision() error {
|
|||
// Get the actor's velocity to see if it's moving this tick.
|
||||
v := a.Velocity()
|
||||
if a.hasGravity {
|
||||
v.Y += int32(balance.Gravity)
|
||||
v.Y += balance.Gravity
|
||||
}
|
||||
|
||||
// If not moving, grab the bounding box right now.
|
||||
|
@ -162,7 +162,7 @@ func (w *Canvas) loopActorCollision() error {
|
|||
// he'd continue falling, so I had to move him up to stop it,
|
||||
// turns out moving up by the -gravity is exactly the distance
|
||||
// to go. Don't know why.
|
||||
b.MoveBy(render.NewPoint(0, int32(-balance.Gravity)))
|
||||
b.MoveBy(render.NewPoint(0, -balance.Gravity))
|
||||
} else {
|
||||
b.MoveTo(lastGoodBox.Point())
|
||||
}
|
||||
|
|
|
@ -6,9 +6,6 @@ import (
|
|||
"runtime"
|
||||
"strings"
|
||||
|
||||
"git.kirsle.net/go/render"
|
||||
"git.kirsle.net/go/render/event"
|
||||
"git.kirsle.net/go/ui"
|
||||
"git.kirsle.net/apps/doodle/pkg/balance"
|
||||
"git.kirsle.net/apps/doodle/pkg/bindata"
|
||||
"git.kirsle.net/apps/doodle/pkg/collision"
|
||||
|
@ -18,6 +15,9 @@ import (
|
|||
"git.kirsle.net/apps/doodle/pkg/log"
|
||||
"git.kirsle.net/apps/doodle/pkg/scripting"
|
||||
"git.kirsle.net/apps/doodle/pkg/wallpaper"
|
||||
"git.kirsle.net/go/render"
|
||||
"git.kirsle.net/go/render/event"
|
||||
"git.kirsle.net/go/ui"
|
||||
)
|
||||
|
||||
// Canvas is a custom ui.Widget that manages a single drawing.
|
||||
|
@ -225,7 +225,7 @@ func (w *Canvas) Loop(ev *event.State) error {
|
|||
|
||||
// If the canvas is editable, only care if it's over our space.
|
||||
if w.Editable {
|
||||
cursor := render.NewPoint(int32(ev.CursorX), int32(ev.CursorY))
|
||||
cursor := render.NewPoint(ev.CursorX, ev.CursorY)
|
||||
if cursor.Inside(ui.AbsoluteRect(w)) {
|
||||
return w.loopEditable(ev)
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
package uix
|
||||
|
||||
import (
|
||||
"git.kirsle.net/apps/doodle/pkg/shmem"
|
||||
"git.kirsle.net/go/render"
|
||||
"git.kirsle.net/go/ui"
|
||||
"git.kirsle.net/apps/doodle/pkg/shmem"
|
||||
)
|
||||
|
||||
// IsCursorOver returns true if the mouse cursor is physically over top
|
||||
|
@ -33,7 +33,7 @@ func (w *Canvas) presentCursor(e render.Engine) {
|
|||
|
||||
// Are we editing with a thick brush?
|
||||
if w.BrushSize > 0 {
|
||||
var r = int32(w.BrushSize)
|
||||
var r = w.BrushSize
|
||||
rect := render.Rect{
|
||||
X: shmem.Cursor.X - r,
|
||||
Y: shmem.Cursor.Y - r,
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
package uix
|
||||
|
||||
import (
|
||||
"git.kirsle.net/apps/doodle/pkg/drawtool"
|
||||
"git.kirsle.net/apps/doodle/pkg/level"
|
||||
"git.kirsle.net/go/render"
|
||||
"git.kirsle.net/go/render/event"
|
||||
"git.kirsle.net/go/ui"
|
||||
"git.kirsle.net/apps/doodle/pkg/drawtool"
|
||||
"git.kirsle.net/apps/doodle/pkg/level"
|
||||
)
|
||||
|
||||
// commitStroke is the common function that applies a stroke the user is
|
||||
|
@ -102,8 +102,8 @@ func (w *Canvas) loopEditable(ev *event.State) error {
|
|||
var (
|
||||
P = ui.AbsolutePosition(w)
|
||||
cursor = render.Point{
|
||||
X: int32(ev.CursorX) - P.X - w.Scroll.X,
|
||||
Y: int32(ev.CursorY) - P.Y - w.Scroll.Y,
|
||||
X: ev.CursorX - P.X - w.Scroll.X,
|
||||
Y: ev.CursorY - P.Y - w.Scroll.Y,
|
||||
}
|
||||
)
|
||||
|
||||
|
|
|
@ -4,10 +4,10 @@ import (
|
|||
"fmt"
|
||||
"strings"
|
||||
|
||||
"git.kirsle.net/go/render"
|
||||
"git.kirsle.net/go/ui"
|
||||
"git.kirsle.net/apps/doodle/pkg/balance"
|
||||
"git.kirsle.net/apps/doodle/pkg/log"
|
||||
"git.kirsle.net/go/render"
|
||||
"git.kirsle.net/go/ui"
|
||||
)
|
||||
|
||||
// Present the canvas.
|
||||
|
@ -59,8 +59,8 @@ func (w *Canvas) Present(e render.Engine, p render.Point) {
|
|||
}
|
||||
|
||||
dst := render.Rect{
|
||||
X: p.X + w.Scroll.X + w.BoxThickness(1) + (coord.X * int32(chunk.Size)),
|
||||
Y: p.Y + w.Scroll.Y + w.BoxThickness(1) + (coord.Y * int32(chunk.Size)),
|
||||
X: p.X + w.Scroll.X + w.BoxThickness(1) + (coord.X * chunk.Size),
|
||||
Y: p.Y + w.Scroll.Y + w.BoxThickness(1) + (coord.Y * chunk.Size),
|
||||
|
||||
// src.W and src.H will be AT MOST the full width and height of
|
||||
// a Canvas widget. Subtract the scroll offset to keep it bounded
|
||||
|
|
|
@ -4,10 +4,10 @@ import (
|
|||
"errors"
|
||||
"fmt"
|
||||
|
||||
"git.kirsle.net/go/render"
|
||||
"git.kirsle.net/go/render/event"
|
||||
"git.kirsle.net/apps/doodle/pkg/balance"
|
||||
"git.kirsle.net/apps/doodle/pkg/level"
|
||||
"git.kirsle.net/go/render"
|
||||
"git.kirsle.net/go/render/event"
|
||||
)
|
||||
|
||||
/*
|
||||
|
@ -73,8 +73,8 @@ func (w *Canvas) loopConstrainScroll() error {
|
|||
w.wallpaper.maxWidth+w.wallpaper.maxHeight > 0 {
|
||||
var (
|
||||
// TODO: downcast from int64!
|
||||
mw = int32(w.wallpaper.maxWidth)
|
||||
mh = int32(w.wallpaper.maxHeight)
|
||||
mw = int(w.wallpaper.maxWidth)
|
||||
mh = int(w.wallpaper.maxHeight)
|
||||
Viewport = w.Viewport()
|
||||
)
|
||||
if Viewport.W > mw {
|
||||
|
@ -126,10 +126,10 @@ func (w *Canvas) loopFollowActor(ev *event.State) error {
|
|||
)
|
||||
|
||||
// Scroll left
|
||||
if APosition.X-VP.X <= int32(balance.ScrollboxHoz) {
|
||||
if APosition.X-VP.X <= balance.ScrollboxHoz {
|
||||
var delta = APosition.X - VP.X
|
||||
if delta > int32(balance.ScrollMaxVelocity) {
|
||||
delta = int32(balance.ScrollMaxVelocity)
|
||||
if delta > balance.ScrollMaxVelocity {
|
||||
delta = balance.ScrollMaxVelocity
|
||||
}
|
||||
|
||||
if delta < 0 {
|
||||
|
@ -140,23 +140,23 @@ func (w *Canvas) loopFollowActor(ev *event.State) error {
|
|||
}
|
||||
|
||||
// Scroll right
|
||||
if APosition.X >= VP.W-ASize.W-int32(balance.ScrollboxHoz) {
|
||||
var delta = VP.W - ASize.W - int32(balance.ScrollboxHoz)
|
||||
if delta > int32(balance.ScrollMaxVelocity) {
|
||||
delta = int32(balance.ScrollMaxVelocity)
|
||||
if APosition.X >= VP.W-ASize.W-balance.ScrollboxHoz {
|
||||
var delta = VP.W - ASize.W - balance.ScrollboxHoz
|
||||
if delta > balance.ScrollMaxVelocity {
|
||||
delta = balance.ScrollMaxVelocity
|
||||
}
|
||||
scrollBy.X = -delta
|
||||
}
|
||||
|
||||
// Scroll up
|
||||
if APosition.Y-VP.Y <= int32(balance.ScrollboxVert) {
|
||||
if APosition.Y-VP.Y <= balance.ScrollboxVert {
|
||||
var delta = APosition.Y - VP.Y
|
||||
if delta > int32(balance.ScrollMaxVelocity) {
|
||||
delta = int32(balance.ScrollMaxVelocity)
|
||||
if delta > balance.ScrollMaxVelocity {
|
||||
delta = balance.ScrollMaxVelocity
|
||||
}
|
||||
|
||||
// TODO: add gravity to counteract jitters on scrolling vertically
|
||||
scrollBy.Y -= int32(balance.Gravity)
|
||||
scrollBy.Y -= balance.Gravity
|
||||
|
||||
if delta < 0 {
|
||||
delta = -delta
|
||||
|
@ -165,15 +165,15 @@ func (w *Canvas) loopFollowActor(ev *event.State) error {
|
|||
}
|
||||
|
||||
// Scroll down
|
||||
if APosition.Y >= VP.H-ASize.H-int32(balance.ScrollboxVert) {
|
||||
var delta = VP.H - ASize.H - int32(balance.ScrollboxVert)
|
||||
if delta > int32(balance.ScrollMaxVelocity) {
|
||||
delta = int32(balance.ScrollMaxVelocity)
|
||||
if APosition.Y >= VP.H-ASize.H-balance.ScrollboxVert {
|
||||
var delta = VP.H - ASize.H - balance.ScrollboxVert
|
||||
if delta > balance.ScrollMaxVelocity {
|
||||
delta = balance.ScrollMaxVelocity
|
||||
}
|
||||
scrollBy.Y = -delta
|
||||
|
||||
// TODO: add gravity to counteract jitters on scrolling vertically
|
||||
scrollBy.Y += int32(balance.Gravity * 3)
|
||||
scrollBy.Y += balance.Gravity * 3
|
||||
}
|
||||
|
||||
if scrollBy != render.Origin {
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
package uix
|
||||
|
||||
import (
|
||||
"git.kirsle.net/go/render"
|
||||
"git.kirsle.net/apps/doodle/pkg/level"
|
||||
"git.kirsle.net/apps/doodle/pkg/wallpaper"
|
||||
"git.kirsle.net/go/render"
|
||||
)
|
||||
|
||||
// Wallpaper configures the wallpaper in a Canvas.
|
||||
|
@ -49,14 +49,14 @@ func (w *Canvas) loopContainActorsInsideLevel(a *Actor) {
|
|||
if w.wallpaper.pageType >= level.Bounded {
|
||||
if w.wallpaper.maxWidth > 0 {
|
||||
if int64(orig.X+size.W) > w.wallpaper.maxWidth {
|
||||
var delta = int32(w.wallpaper.maxWidth - int64(orig.X+size.W))
|
||||
moveBy.X = delta
|
||||
var delta = w.wallpaper.maxWidth - int64(orig.X+size.W)
|
||||
moveBy.X = int(delta)
|
||||
}
|
||||
}
|
||||
if w.wallpaper.maxHeight > 0 {
|
||||
if int64(orig.Y+size.H) > w.wallpaper.maxHeight {
|
||||
var delta = int32(w.wallpaper.maxHeight - int64(orig.Y+size.H))
|
||||
moveBy.Y = delta
|
||||
var delta = w.wallpaper.maxHeight - int64(orig.Y+size.H)
|
||||
moveBy.Y = int(delta)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -89,7 +89,7 @@ func (w *Canvas) PresentWallpaper(e render.Engine, p render.Point) error {
|
|||
// For tiled textures, compute the offset amount. If we are scrolled away
|
||||
// from the Origin (0,0) we find out by how far (subtract full tile sizes)
|
||||
// and use the remainder as an offset for drawing the tiles.
|
||||
var dx, dy int32
|
||||
var dx, dy int
|
||||
if origin.X > p.X {
|
||||
for origin.X > p.X && origin.X > size.W {
|
||||
origin.X -= size.W
|
||||
|
|
Loading…
Reference in New Issue
Block a user