diff options
author | davidovski <david@davidovski.xyz> | 2024-04-21 21:49:56 +0100 |
---|---|---|
committer | davidovski <david@davidovski.xyz> | 2024-04-21 21:49:56 +0100 |
commit | 771329e12fa9327980a43ef22cb4b9b24211b0cc (patch) | |
tree | a87c4a05d2a924f4b33784b0ec3bdfdf501e2f8a /main.go | |
parent | 2d6d9f97093544e0d2faccc94f3b8bf369c03819 (diff) |
add offsets for placed items
Diffstat (limited to 'main.go')
-rw-r--r-- | main.go | 19 |
1 files changed, 12 insertions, 7 deletions
@@ -18,10 +18,11 @@ const ( screenHeight = 240 tileSize = 16 playerSpeed = 2.1 - jumpHeight = 3.2 + jumpHeight = 4 rewindSpeed = 2 gravity = 0.16 - friction = 0.9 + friction = 0.75 + airResistance = 0.98 ) var ( @@ -111,6 +112,8 @@ func (g *Game) Init() { g.toPlace = append(g.toPlace, NewBox(0, 0)) g.toPlace = append(g.toPlace, NewBox(0, 0)) g.toPlace = append(g.toPlace, NewSpring(0, 0)) + g.toPlace = append(g.toPlace, NewSpike(0, 0)) + g.toPlace = append(g.toPlace, NewLeftSpike(0, 0)) g.surface = ebiten.NewImage(screenWidth, screenHeight) g.shaderName = "none" @@ -162,9 +165,7 @@ func (g *Game) Update() error { if g.state == REVERSING { g.state = IN_GAME g.shaderName = "none" - } - - if g.state == IN_GAME { + } else if g.state == IN_GAME { g.state = REVERSING g.shaderName = "vcr" } @@ -200,12 +201,16 @@ func (g *Game) Update() error { if g.state == PLACING { if len(g.toPlace) > 0 { + placeable := g.toPlace[0] cx, cy := ebiten.CursorPosition() cx = int(math.Floor(float64(cx)/float64(g.tilemap.tileSize)))*g.tilemap.tileSize cy = int(math.Floor(float64(cy)/float64(g.tilemap.tileSize)))*g.tilemap.tileSize - g.toPlace[0].x = float32(cx) - g.toPlace[0].y = float32(cy) + cx += placeable.offsetX + cy += placeable.offsetY + + placeable.x = float32(cx) + placeable.y = float32(cy) if inpututil.IsMouseButtonJustPressed(ebiten.MouseButton0) { g.PlaceObject(cx, cy) |