Compare commits
2 Commits
f23bdaf121
...
dd25d217dc
| Author | SHA1 | Date | |
|---|---|---|---|
| dd25d217dc | |||
| a84b8b58e1 |
37
TODO.md
37
TODO.md
@ -1,22 +1,8 @@
|
|||||||
## Levels:
|
## Levels:
|
||||||
|
|
||||||
- Add shaders for animation (player destruction etc)
|
|
||||||
|
|
||||||
- Start New game starts with last played level, better add a Resume
|
- Start New game starts with last played level, better add a Resume
|
||||||
Game menu item for this and use Start New always for level 1.
|
Game menu item for this and use Start New always for level 1.
|
||||||
|
|
||||||
- for finding caller:
|
|
||||||
pc := make([]uintptr, 10)
|
|
||||||
n := runtime.Callers(0, pc)
|
|
||||||
pc = pc[:n]
|
|
||||||
fs := runtime.CallersFrames(pc)
|
|
||||||
source, _ := fs.Next()
|
|
||||||
source, _ = fs.Next()
|
|
||||||
source, _ = fs.Next()
|
|
||||||
|
|
||||||
slog.Debug("get observer", "minmoves", observer.LevelScore,
|
|
||||||
"file", source.File, "line", source.Line)
|
|
||||||
|
|
||||||
- Turn menu button in hud_system (events in level_scene!) into ebitenui button
|
- Turn menu button in hud_system (events in level_scene!) into ebitenui button
|
||||||
|
|
||||||
- Obstacle don't stop at collectibles
|
- Obstacle don't stop at collectibles
|
||||||
@ -47,19 +33,10 @@
|
|||||||
- Add save to disk feature including settings and player
|
- Add save to disk feature including settings and player
|
||||||
accomplishements (FIXME: find the lib, asked in Discord)
|
accomplishements (FIXME: find the lib, asked in Discord)
|
||||||
|
|
||||||
- Add coded animated background like in https://github.com/tinne26/bindless/tree/main/src/misc/background
|
|
||||||
|
|
||||||
- Rework sprites (again!) to match stellar background: maybe more
|
- Rework sprites (again!) to match stellar background: maybe more
|
||||||
technical tiles and items? Like some robotic setup?
|
technical tiles and items? Like some robotic setup?
|
||||||
|
|
||||||
- Fix collision snapin: sometimes, when an entity moves to the right
|
|
||||||
or south (NOT left or north!) it snaps in visibly, so a short wobble
|
|
||||||
can be seen.
|
|
||||||
|
|
||||||
- Rework animation system: since it is impossible to assign multiple
|
|
||||||
animation types to an entity via LDTK, hard code it in Tiles. Keep
|
|
||||||
implementation though. CAUTION: last time I changed this, the
|
|
||||||
collectible detonation didn't work anymore!
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -82,3 +59,17 @@
|
|||||||
Collider.IntersectResolve => func(newpos) {player.pos = newpos; player.vel = stop}
|
Collider.IntersectResolve => func(newpos) {player.pos = newpos; player.vel = stop}
|
||||||
- in the end it must be possible to add new entities without the need
|
- in the end it must be possible to add new entities without the need
|
||||||
to write a collision check for them, but have collision detection anyway!
|
to write a collision check for them, but have collision detection anyway!
|
||||||
|
|
||||||
|
## Just in case stuff
|
||||||
|
|
||||||
|
- for finding caller:
|
||||||
|
pc := make([]uintptr, 10)
|
||||||
|
n := runtime.Callers(0, pc)
|
||||||
|
pc = pc[:n]
|
||||||
|
fs := runtime.CallersFrames(pc)
|
||||||
|
source, _ := fs.Next()
|
||||||
|
source, _ = fs.Next()
|
||||||
|
source, _ = fs.Next()
|
||||||
|
|
||||||
|
slog.Debug("get observer", "minmoves", observer.LevelScore,
|
||||||
|
"file", source.File, "line", source.Line)
|
||||||
|
|||||||
42
assets/space/space.pal
Normal file
42
assets/space/space.pal
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
JASC-PAL
|
||||||
|
0100
|
||||||
|
39
|
||||||
|
32 0 59
|
||||||
|
63 0 83
|
||||||
|
108 0 108
|
||||||
|
146 0 124
|
||||||
|
187 0 151
|
||||||
|
236 0 178
|
||||||
|
255 19 186
|
||||||
|
255 64 190
|
||||||
|
255 113 213
|
||||||
|
255 147 231
|
||||||
|
255 186 253
|
||||||
|
245 220 255
|
||||||
|
255 255 255
|
||||||
|
0 0 0
|
||||||
|
12 12 12
|
||||||
|
26 26 26
|
||||||
|
39 39 39
|
||||||
|
54 54 54
|
||||||
|
71 71 71
|
||||||
|
86 86 86
|
||||||
|
99 99 99
|
||||||
|
118 118 118
|
||||||
|
133 133 133
|
||||||
|
153 153 153
|
||||||
|
177 177 177
|
||||||
|
205 205 205
|
||||||
|
42 2 0
|
||||||
|
52 9 0
|
||||||
|
71 24 0
|
||||||
|
94 46 0
|
||||||
|
131 71 0
|
||||||
|
165 96 0
|
||||||
|
201 106 0
|
||||||
|
243 119 0
|
||||||
|
255 165 41
|
||||||
|
255 186 82
|
||||||
|
255 239 169
|
||||||
|
255 250 211
|
||||||
|
255 255 247
|
||||||
BIN
assets/space/tilemap-oil.ase
Normal file
BIN
assets/space/tilemap-oil.ase
Normal file
Binary file not shown.
BIN
assets/space/tilemap-oil.png
Normal file
BIN
assets/space/tilemap-oil.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 12 KiB |
@ -115,3 +115,8 @@ func (tile *Position) Intersects(moving *Position, velocity *Velocity) (bool, *P
|
|||||||
|
|
||||||
return false, nil
|
return false, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (tile *Position) Intersecting(position *Position, velocity *Velocity) bool {
|
||||||
|
is := tile.Rect.Bounds().Intersect(position.Rect.Bounds())
|
||||||
|
return is != image.ZR
|
||||||
|
}
|
||||||
|
|||||||
@ -3,6 +3,8 @@ package grid
|
|||||||
import (
|
import (
|
||||||
"openquell/components"
|
"openquell/components"
|
||||||
. "openquell/config"
|
. "openquell/config"
|
||||||
|
|
||||||
|
"log/slog"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Check a collision on the grid. We check if the entity in question
|
// Check a collision on the grid. We check if the entity in question
|
||||||
@ -24,8 +26,8 @@ func (grid *Grid) CheckGridCollision(
|
|||||||
} else {
|
} else {
|
||||||
ok, tilepos := grid.GetSolidNeighborPosition(position, velocity, true)
|
ok, tilepos := grid.GetSolidNeighborPosition(position, velocity, true)
|
||||||
if ok {
|
if ok {
|
||||||
// slog.Debug("HaveSolidNeighbor", "ok", ok, "tilepos",
|
slog.Debug("(3) HaveSolidNeighbor", "tilepos",
|
||||||
// tilepos.Point(), "playerpos", playerposition)
|
tilepos.String(), "playpos", position.String())
|
||||||
intersects, newpos := tilepos.Intersects(position, velocity)
|
intersects, newpos := tilepos.Intersects(position, velocity)
|
||||||
if intersects {
|
if intersects {
|
||||||
respond_solid(position, velocity, newpos)
|
respond_solid(position, velocity, newpos)
|
||||||
@ -44,6 +46,66 @@ func (grid *Grid) GetSolidNeighborPosition(
|
|||||||
return false, nil
|
return false, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// set to true if we are already on the last tile in the current
|
||||||
|
// direction, i.e. on the edge of the grid
|
||||||
|
edge := true
|
||||||
|
moving := position.GetMoved(velocity)
|
||||||
|
|
||||||
|
neighborpos := position.Point()
|
||||||
|
if velocity.Direction == East || velocity.Direction == South {
|
||||||
|
// FIXES snapin to down+right, but now top+left fail. Only in
|
||||||
|
// these cases we need to look at the neighbor in the future
|
||||||
|
// position where we will be when we move forward. I don't
|
||||||
|
// know why it is like this, in fact it doesn't really make
|
||||||
|
// any sense. But it works, so I'll keep it that way for the
|
||||||
|
// moment.
|
||||||
|
neighborpos = moving.Point()
|
||||||
|
}
|
||||||
|
|
||||||
|
switch velocity.Direction {
|
||||||
|
case East:
|
||||||
|
if neighborpos.X < grid.TilesX {
|
||||||
|
neighborpos.X++
|
||||||
|
edge = false
|
||||||
|
}
|
||||||
|
case West:
|
||||||
|
if neighborpos.X > 0 {
|
||||||
|
neighborpos.X--
|
||||||
|
edge = false
|
||||||
|
}
|
||||||
|
case South:
|
||||||
|
if neighborpos.Y < grid.TilesY {
|
||||||
|
neighborpos.Y++
|
||||||
|
edge = false
|
||||||
|
}
|
||||||
|
case North:
|
||||||
|
if neighborpos.Y > 0 {
|
||||||
|
neighborpos.Y--
|
||||||
|
edge = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
newpos := components.NewPosition(neighborpos, grid.Tilesize)
|
||||||
|
|
||||||
|
slog.Debug("SolidNeighbor?", "player", position.Point(),
|
||||||
|
"neighbor", neighborpos, "edge", edge, "neighbor-solid",
|
||||||
|
grid.Map[neighborpos].Solid, "newpos", newpos.Point())
|
||||||
|
if !edge && grid.Map[neighborpos].Solid {
|
||||||
|
return true, newpos
|
||||||
|
}
|
||||||
|
|
||||||
|
return false, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (grid *Grid) OrigGetSolidNeighborPosition(
|
||||||
|
position *components.Position,
|
||||||
|
velocity *components.Velocity,
|
||||||
|
solid bool) (bool, *components.Position) {
|
||||||
|
|
||||||
|
if !solid {
|
||||||
|
return false, nil
|
||||||
|
}
|
||||||
|
|
||||||
// set to true if we are already on the last tile in the current
|
// set to true if we are already on the last tile in the current
|
||||||
// direction, i.e. on the edge of the grid
|
// direction, i.e. on the edge of the grid
|
||||||
edge := true
|
edge := true
|
||||||
@ -74,9 +136,9 @@ func (grid *Grid) GetSolidNeighborPosition(
|
|||||||
|
|
||||||
newpos := components.NewPosition(neighborpos, grid.Tilesize)
|
newpos := components.NewPosition(neighborpos, grid.Tilesize)
|
||||||
|
|
||||||
// slog.Debug("SolidNeighbor?", "player", position.Point(),
|
slog.Debug("SolidNeighbor?", "player", position.Point(),
|
||||||
// "neighbor", neighborpos, "edge", edge, "neighbor-solid",
|
"neighbor", neighborpos, "edge", edge, "neighbor-solid",
|
||||||
// grid.Map[neighborpos].Solid, "newpos", newpos.Point())
|
grid.Map[neighborpos].Solid, "newpos", newpos.Point())
|
||||||
if !edge && grid.Map[neighborpos].Solid {
|
if !edge && grid.Map[neighborpos].Solid {
|
||||||
return true, newpos
|
return true, newpos
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
package systems
|
package systems
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"log/slog"
|
"log/slog"
|
||||||
"openquell/components"
|
"openquell/components"
|
||||||
. "openquell/components"
|
. "openquell/components"
|
||||||
@ -9,6 +10,7 @@ import (
|
|||||||
"openquell/observers"
|
"openquell/observers"
|
||||||
|
|
||||||
"github.com/hajimehoshi/ebiten/v2"
|
"github.com/hajimehoshi/ebiten/v2"
|
||||||
|
"github.com/hajimehoshi/ebiten/v2/ebitenutil"
|
||||||
"github.com/hajimehoshi/ebiten/v2/inpututil"
|
"github.com/hajimehoshi/ebiten/v2/inpututil"
|
||||||
"github.com/mlange-42/arche/ecs"
|
"github.com/mlange-42/arche/ecs"
|
||||||
"github.com/mlange-42/arche/generic"
|
"github.com/mlange-42/arche/generic"
|
||||||
@ -46,6 +48,7 @@ func PlayerBumpWallResponder(
|
|||||||
vel *components.Velocity,
|
vel *components.Velocity,
|
||||||
newpos *components.Position) {
|
newpos *components.Position) {
|
||||||
|
|
||||||
|
slog.Debug("(2) PlayerBumpWallResponder", "old", pos.String(), "new", newpos.String())
|
||||||
pos.Set(newpos)
|
pos.Set(newpos)
|
||||||
vel.Change(Stop)
|
vel.Change(Stop)
|
||||||
}
|
}
|
||||||
@ -67,12 +70,16 @@ func (system PlayerSystem) Update() error {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
// check if the user alters or initiates movement
|
// check if the user alters or initiates movement, only
|
||||||
|
// changes player direction
|
||||||
system.CheckMovement(playerposition, velocity, player)
|
system.CheckMovement(playerposition, velocity, player)
|
||||||
|
|
||||||
// check if player collides with walls or edges
|
// check if player collides with walls or edges
|
||||||
|
if velocity.Moving() {
|
||||||
|
slog.Debug("(2) checking grid collision")
|
||||||
system.GridContainer.Grid.CheckGridCollision(
|
system.GridContainer.Grid.CheckGridCollision(
|
||||||
playerposition, velocity, PlayerBumpEdgeResponder, PlayerBumpWallResponder)
|
playerposition, velocity, PlayerBumpEdgeResponder, PlayerBumpWallResponder)
|
||||||
|
}
|
||||||
|
|
||||||
if count > 1 {
|
if count > 1 {
|
||||||
// check if player collides with another player, fuse them if any
|
// check if player collides with another player, fuse them if any
|
||||||
@ -99,7 +106,11 @@ func (system PlayerSystem) Update() error {
|
|||||||
query = system.Selector.Query(system.World)
|
query = system.Selector.Query(system.World)
|
||||||
for query.Next() {
|
for query.Next() {
|
||||||
playerposition, velocity, _, _ := query.Get()
|
playerposition, velocity, _, _ := query.Get()
|
||||||
|
oldpos := playerposition.String()
|
||||||
|
if velocity.Moving() {
|
||||||
playerposition.Move(velocity)
|
playerposition.Move(velocity)
|
||||||
|
slog.Debug("(4) moving player", "old", oldpos, "new", playerposition.String())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// we may have lost players, remove them here
|
// we may have lost players, remove them here
|
||||||
@ -124,6 +135,8 @@ func (system *PlayerSystem) Draw(screen *ebiten.Image) {
|
|||||||
op.GeoM.Translate(float64(pos.X), float64(pos.Y))
|
op.GeoM.Translate(float64(pos.X), float64(pos.Y))
|
||||||
|
|
||||||
screen.DrawImage(sprite.Image, op)
|
screen.DrawImage(sprite.Image, op)
|
||||||
|
|
||||||
|
ebitenutil.DebugPrintAt(screen, pos.String(), pos.X, pos.Y) // print player pos
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -196,6 +209,9 @@ func (system *PlayerSystem) CheckMovement(
|
|||||||
player.LoopCount = 0
|
player.LoopCount = 0
|
||||||
observer.AddMove()
|
observer.AddMove()
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
fmt.Println("------------------------")
|
||||||
|
slog.Debug("(1) player is at", "current", position.String())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user