From 0ca5d8f4a0940c77032817a2cd7243a413028aad Mon Sep 17 00:00:00 2001 From: Thomas von Dein Date: Mon, 26 Feb 2024 14:43:03 +0100 Subject: [PATCH] more TODO --- TODO.md | 49 +++++++++++++++++++++++------------------ assets/sprites/hud.png | Bin 0 -> 1969 bytes game/game.go | 7 ------ game/level_scene.go | 13 +++++++++++ 4 files changed, 40 insertions(+), 29 deletions(-) create mode 100644 assets/sprites/hud.png diff --git a/TODO.md b/TODO.md index e448b58..8add34a 100644 --- a/TODO.md +++ b/TODO.md @@ -1,9 +1,10 @@ ## Levels: -- use first line as background image name - ignore comments in lvl files + - check when sphere bounces from one end to the other endlessly w/o any solids in between. this is a game lock and equals game over + - Start the game end timer and add a score FIXME: put the actual max reachable score into the level definition along with the minimum steps required to reach it, also add a step counter @@ -11,31 +12,35 @@ - Grid Observer: https://github.com/mlange-42/arche/issues/374 - -Screenshot: - -Yes, since *ebiten.Image implements the standard image.Image interface -I just made a screenshot example (in Draw() function): -if inpututil.IsKeyJustPressed(ebiten.KeyS) { - f, err := os.Create("screenshot.png") - if err != nil { - log.Fatal("can't create file: ", err) - } - png.Encode(f, screen) -} - - - Add some final message when the player reaches the last level, start from scratch or a message to buy me some beer, whatever -- Calculate obstacle collision the same as solid collision with future - velocity and included snap in so that the player ends up right on - the edge of the obstacle and not inside as it is now - - Check player-player collisions! -- Do all collision detections in ONE system +- Add player mergers, possibly as an option, so maybe we could have + different primary and secondary players: one pair can merge, the + other not. Like S + s and M + m or something. + +- Add shaders for animation (player destruction etc) + +- Add player HUD + Stats (as hud_system!) + + +## Collider Rework - do not use the map anymore for collision detection - -- check swept AABB instead of my collision detection, to allow for higher speeds +- central collision_system +- add Collider component with callback funcs to call on certain events +- callback types: + - rect intersect (== future collision) + - collision resolve (set new position) + - pass over foreign rect (to e.g. change sprite while flying over sprite) + - pass over done (switch sprite) +- check for all moving objects against non-moving ones like moving + obstacle, player, bullet, laser +- check if executing callbacks within query loop is allowed +- callback function needs to be able to modify other components, so + possibly use observers for them, e.g.: + Collider.IntersectResolve => func(newpos) {player.pos = newpos; player.vel = stop} +- 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! diff --git a/assets/sprites/hud.png b/assets/sprites/hud.png new file mode 100644 index 0000000000000000000000000000000000000000..0a23d9aeb395d479b0d4004934f1e7b66601b316 GIT binary patch literal 1969 zcmeAS@N?(olHy`uVBq!ia0y~yU}|7sV0^&A1{5*9c;^X_)12w-9N_8ftWZ#tpO%@E z%D|v8v38=Z$6*JVqw&E@m2~;aCM=q;(CX&VE{khgA`6{Xh(?tf?EJz#Ym17eUSCu8 z!GrxrS2cHUUdOktN#O_Mqc;zhyiij8r?0uC)^mS!_!6d~iuha5Z?H5o;vcxr_#5q4VH#M(> z!MP|ku_QG`p**uBL&4qCHz2%`Pn>~)wae4RF{I+w+q)Zin+-%-3iJ*hsUUcXnJ14HDg)3=Av^z_cR(OfDP@4Gb&{4h&2T3Ji=4 z0u2ld91d8eaR_74)ewJnmDL#ruz@=Y8Q!HaFr45zuwIgZVH4AbWHyF|H4HVg85tC` z8REfG4(dQ#6B%FdDKI!hFjTSfFbIe>>|^EtQU6$&7)HTp2#kin@DG6l_HO0;#taNk zW`wE&%c4U}1+&1Vggm4Gxyr-95Xrb>CRl7fQ6&ecaN4o@C=01&9Y`N(CFFxkoaHn4 UB5yVpz6V8=r>mdKI;Vst07YRrZ~y=R literal 0 HcmV?d00001 diff --git a/game/game.go b/game/game.go index 22f58a4..d3c697b 100644 --- a/game/game.go +++ b/game/game.go @@ -8,7 +8,6 @@ import ( "openquell/observers" "github.com/hajimehoshi/ebiten/v2" - "github.com/hajimehoshi/ebiten/v2/ebitenutil" "github.com/mlange-42/arche/ecs" ) @@ -119,13 +118,7 @@ func (game *Game) Update() error { } func (game *Game) Draw(screen *ebiten.Image) { - //slog.Debug("FPS", "fps", ebiten.ActualFPS()) game.GetCurrentScene().Draw(screen) - ebitenutil.DebugPrintAt(screen, fmt.Sprintf( - "FPS: %02.f TPS: %02.f", - ebiten.ActualFPS(), - ebiten.ActualTPS(), - ), 0, 0) } func (g *Game) Layout(newWidth, newHeight int) (int, int) { diff --git a/game/level_scene.go b/game/level_scene.go index d181702..0033e8a 100644 --- a/game/level_scene.go +++ b/game/level_scene.go @@ -1,10 +1,12 @@ package game import ( + "fmt" "log/slog" "openquell/assets" "github.com/hajimehoshi/ebiten/v2" + "github.com/hajimehoshi/ebiten/v2/ebitenutil" ) type LevelScene struct { @@ -69,12 +71,23 @@ func (scene *LevelScene) Update() error { } func (scene *LevelScene) Draw(screen *ebiten.Image) { + // FIXME: why not in Update() ?!?!?! if scene.CurrentLevel != scene.Game.Observer.CurrentLevel { slog.Debug("level", "current", scene.CurrentLevel, "next", scene.Game.Observer.CurrentLevel) scene.CurrentLevel = scene.Game.Observer.CurrentLevel scene.Levels[scene.CurrentLevel].SetupGrid(scene.Game) } + screen.Clear() scene.Levels[scene.CurrentLevel].Draw(screen) + + // FIXME: put into hud_system + op := &ebiten.DrawImageOptions{} + screen.DrawImage(assets.Assets["hud"], op) + ebitenutil.DebugPrintAt(screen, fmt.Sprintf( + "FPS: %02.f TPS: %02.f", + ebiten.ActualFPS(), + ebiten.ActualTPS(), + ), 10, 10) }