diff options
author | davidovski <david@davidovski.xyz> | 2024-04-21 23:16:57 +0100 |
---|---|---|
committer | davidovski <david@davidovski.xyz> | 2024-04-21 23:16:57 +0100 |
commit | 9af752349c40be745d1296d95675916f95977890 (patch) | |
tree | 326f087188c7885c0c070f656d21483a30f20680 | |
parent | cffac12303402c3bfd2d7eb8ab982bdaa86bd72d (diff) |
fix placing things on the floor
-rw-r--r-- | main.go | 4 | ||||
-rw-r--r-- | objects.go | 2 | ||||
-rw-r--r-- | shaders/vcr.kage | 5 | ||||
-rw-r--r-- | tilemap.go | 4 |
4 files changed, 6 insertions, 9 deletions
@@ -264,12 +264,10 @@ func (g *Game) Draw(screen *ebiten.Image) { } } - cx, cy := ebiten.CursorPosition() - shop := &ebiten.DrawRectShaderOptions{} shop.Uniforms = map[string]any{ "Time": float32(g.time) / 60, - "Cursor": []float32{float32(cx), float32(cy)}, + "NoiseOffset": float32(g.time) / 60, } shop.Images[0] = g.surface shop.Images[1] = g.surface @@ -213,7 +213,7 @@ func NewLeftSpike(game *Game, x, y float32) *GameObject{ spike.offsetX = 3 spike.image = tilesImage.SubImage(image.Rect(195, 16, 208, 32)).(*ebiten.Image) - spike.onCollideLeft = OnCollideSpike + spike.onCollideRight = OnCollideSpike return spike } diff --git a/shaders/vcr.kage b/shaders/vcr.kage index 3bee5cd..fd555d8 100644 --- a/shaders/vcr.kage +++ b/shaders/vcr.kage @@ -5,7 +5,7 @@ package main var Time float -var Cursor vec2 +var NoiseOffset float const noiseX = 80.0 const noiseY = 100.0 @@ -17,7 +17,6 @@ func rand(co vec2) float { } func Fragment(dstPos vec4, srcPos vec2, color vec4) vec4 { - noiseOffset := Time / 7 col := vec4(0) uv := srcPos / imageSrc0Size() @@ -25,7 +24,7 @@ func Fragment(dstPos vec4, srcPos vec2, color vec4) vec4 { uv.y = uv.y + (rand(vec2(Time))-0.5) / (noiseY); whiteNoise := rand(vec2(floor(uv.y*80.0),floor(uv.x*50.0))+vec2(Time,0)) - off := 1.0 - mod(uv.y - noiseOffset, 1) + off := 1.0 - mod(uv.y - NoiseOffset / 7, 1) if (whiteNoise > 11.5-30.0*(off)) || whiteNoise < 1.5-2.0*(off) { // Sample the texture. @@ -90,7 +90,7 @@ func (tm * Tilemap) CalculateCollisions() { func Collide(r1 image.Rectangle, r2 image.Rectangle) bool { - return ! ( r2.Min.X > r1.Max.X || r2.Max.X < r1.Min.X || r2.Min.Y > r1.Max.Y || r2.Max.Y < r1.Min.Y) + return ! ( r2.Min.X >= r1.Max.X || r2.Max.X <= r1.Min.X || r2.Min.Y >= r1.Max.Y || r2.Max.Y <= r1.Min.Y) } func (t * Tilemap) Collide(x, y, width, height int) bool { @@ -102,7 +102,7 @@ func (t * Tilemap) Collide(x, y, width, height int) bool { ) for _, r2 := range t.collisions { - if ! ( r2.Min.X > r1.Max.X || r2.Max.X < r1.Min.X || r2.Min.Y > r1.Max.Y || r2.Max.Y < r1.Min.Y) { + if ! ( r2.Min.X >= r1.Max.X || r2.Max.X <= r1.Min.X || r2.Min.Y >= r1.Max.Y || r2.Max.Y <= r1.Min.Y) { return true } |