Minor Tweaks

physics
Noah 2019-06-08 17:02:28 -07:00
parent de79bde776
commit 567b3158f1
12 changed files with 115 additions and 29 deletions

View File

@ -1,6 +1,9 @@
function main() {
log.Info("Azulian '%s' initialized!", Self.Doodad.Title);
Self.Canvas.SetBackground(RGBA(0, 153, 255, 100));
var playerSpeed = 12;
var gravity = 4;
var Vx = Vy = 0;

View File

@ -2,6 +2,8 @@ function main() {
Self.AddAnimation("open", 0, [1]);
var unlocked = false;
Self.Canvas.SetBackground(RGBA(0, 255, 255, 100));
// Map our door names to key names.
var KeyMap = {
"Blue Door": "Blue Key",
@ -32,6 +34,5 @@ function main() {
});
Events.OnLeave(function(e) {
console.log("%s has stopped touching %s", e, Self.Doodad.Title)
Self.Canvas.SetBackground(RGBA(0, 0, 1, 0));
})
}

View File

@ -3,7 +3,7 @@ function main() {
var timer = 0;
Self.SetHitbox(0, 0, 72, 9);
Self.SetHitbox(0, 0, 72, 6);
var animationSpeed = 100;
var opened = false;

View File

@ -8,8 +8,9 @@ import (
// State keeps track of event states.
type State struct {
// Mouse buttons.
Button1 *BoolTick
Button2 *BoolTick
Button1 *BoolTick // left
Button2 *BoolTick // right
Button3 *BoolTick // middle
EscapeKey *BoolTick
EnterKey *BoolTick
@ -33,6 +34,7 @@ func New() *State {
return &State{
Button1: &BoolTick{},
Button2: &BoolTick{},
Button3: &BoolTick{},
EscapeKey: &BoolTick{},
EnterKey: &BoolTick{},
ShiftActive: &BoolTick{},

View File

@ -83,7 +83,7 @@ func (r *Renderer) Poll() (*events.State, error) {
return false
}
if checkDown(1, s.Button1) || checkDown(3, s.Button2) {
if checkDown(1, s.Button1) || checkDown(3, s.Button2) || checkDown(2, s.Button3) {
// Return the event immediately.
return s, nil
}

View File

@ -17,8 +17,8 @@ type Actor interface {
SetGrounded(bool)
// Actor's elected hitbox set by their script.
SetHitbox(x, y, w, h int)
Hitbox() render.Rect
// SetHitbox(x, y, w, h int)
// Hitbox() render.Rect
// Movement commands.
MoveBy(render.Point) // Add {X,Y} to current Position.
@ -39,3 +39,12 @@ func GetBoundingRect(d Actor) render.Rect {
H: S.H,
}
}
// GetBoundingRectWithHitbox is like GetBoundingRect but adjusts it for the
// relative hitbox of the actor.
// func GetBoundingRectWithHitbox(d Actor, hitbox render.Rect) render.Rect {
// rect := GetBoundingRect(d)
// rect.W = hitbox.W
// rect.H = hitbox.H
// return rect
// }

View File

@ -76,20 +76,20 @@ func (d *Drawing) SetGrounded(v bool) {
d.grounded = v
}
// SetHitbox sets the actor's elected hitbox.
func (d *Drawing) SetHitbox(x, y, w, h int) {
d.hitbox = render.Rect{
X: int32(x),
Y: int32(y),
W: int32(w),
H: int32(h),
}
}
// Hitbox returns the actor's elected hitbox.
func (d *Drawing) Hitbox() render.Rect {
return d.hitbox
}
// // SetHitbox sets the actor's elected hitbox.
// func (d *Drawing) SetHitbox(x, y, w, h int) {
// d.hitbox = render.Rect{
// X: int32(x),
// Y: int32(y),
// W: int32(w),
// H: int32(h),
// }
// }
//
// // Hitbox returns the actor's elected hitbox.
// func (d *Drawing) Hitbox() render.Rect {
// return d.hitbox
// }
// MoveBy a relative value.
func (d *Drawing) MoveBy(by render.Point) {

View File

@ -548,9 +548,12 @@ func (u *EditorUI) SetupStatusBar(d *Doodle) *ui.Frame {
}
}
// TODO: right-aligned labels clip out of bounds
var shareware string
if balance.FreeVersion {
shareware = " (shareware)"
}
extraLabel := ui.NewLabel(ui.Label{
Text: "blah",
Text: "Doodle v" + Version + shareware,
Font: balance.StatusFont,
})
extraLabel.Configure(ui.Config{

View File

@ -49,6 +49,68 @@ func (u *EditorUI) setupDoodadFrame(e render.Engine, window *ui.Window) (*ui.Fra
perRow = balance.UIDoodadsPerRow
)
frame.SetBackground(render.RGBA(0, 153, 255, 153))
// Toolbar on top of the Doodad panel.
toolbar := ui.NewFrame("Doodad Palette Toolbar")
toolbar.Configure(ui.Config{
Background: render.Grey,
BorderSize: 2,
BorderStyle: ui.BorderRaised,
Height: 20,
})
{
// Link button.
linkButton := ui.NewButton("Link", ui.NewLabel(ui.Label{
Text: "Link Doodads",
}))
linkButton.Handle(ui.Click, func(p render.Point) {
u.d.Flash("Hello world")
})
u.Supervisor.Add(linkButton)
toolbar.Pack(linkButton, ui.Pack{
Anchor: ui.N,
FillX: true,
})
}
frame.Pack(toolbar, ui.Pack{
Anchor: ui.N,
Fill: true,
})
// Pager buttons on top of the doodad list.
pager := ui.NewFrame("Doodad Pager")
{
leftBtn := ui.NewButton("Prev Page", ui.NewLabel(ui.Label{
Text: "<",
}))
u.Supervisor.Add(leftBtn)
pager.Pack(leftBtn, ui.Pack{
Anchor: ui.W,
})
pageLabel := ui.NewLabel(ui.Label{
Text: " Page 1 of 20",
})
pager.Pack(pageLabel, ui.Pack{
Anchor: ui.W,
Expand: true,
})
rightBtn := ui.NewButton("Next Page", ui.NewLabel(ui.Label{
Text: ">",
}))
u.Supervisor.Add(rightBtn)
pager.Pack(rightBtn, ui.Pack{
Anchor: ui.W,
})
}
frame.Pack(pager, ui.Pack{
Anchor: ui.N,
Fill: true,
})
doodadsAvailable, err := doodads.ListDoodads()
if err != nil {
return frame, fmt.Errorf(

View File

@ -65,6 +65,10 @@ type Canvas struct {
OnDeleteActors func([]*level.Actor)
OnDragStart func(filename string)
// When the Canvas wants to link two actors together. Arguments are the IDs
// of the two actors.
OnLinkActors func(a, b string)
// Tracking pixels while editing. TODO: get rid of pixelHistory?
pixelHistory []*level.Pixel
lastPixel *level.Pixel

View File

@ -88,19 +88,19 @@ func (w *Canvas) PresentWallpaper(e render.Engine, p render.Point) error {
// 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
if origin.X > 0 {
for origin.X > 0 && origin.X > size.W {
if origin.X > p.X {
for origin.X > p.X && origin.X > size.W {
origin.X -= size.W
}
dx = origin.X
origin.X = 0
origin.X = p.X
}
if origin.Y > 0 {
for origin.Y > 0 && origin.Y > size.H {
if origin.Y > p.Y {
for origin.Y > p.Y && origin.Y > size.H {
origin.Y -= size.H
}
dy = origin.Y
origin.Y = 0
origin.Y = p.Y
}
// And capping the scroll delta in the other direction.

View File

@ -7,11 +7,13 @@ type Tool int
const (
PencilTool Tool = iota // draw pixels where the mouse clicks
ActorTool // drag and move actors
LinkTool
)
var toolNames = []string{
"Pencil",
"Doodad", // readable name for ActorTool
"Link",
}
func (t Tool) String() string {