Compare commits
8 Commits
separate-c
...
dc2574643c
| Author | SHA1 | Date | |
|---|---|---|---|
| dc2574643c | |||
| 4c2ecc6f1f | |||
| 5b7c88a1a9 | |||
| f8c09fda76 | |||
| 693293b8c8 | |||
| 51d3776abf | |||
| 19c9a5d502 | |||
| d055c9e913 |
1
.gitignore
vendored
@@ -1 +1,2 @@
|
||||
openquell*
|
||||
tmp
|
||||
|
||||
3
Makefile
@@ -22,5 +22,8 @@ buildwasm:
|
||||
zipwasm:
|
||||
zip -r openquell-$(SHORTVERSION).zip index.html openquell.wasm wasm_exec.js
|
||||
|
||||
wasm: buildwasm zipwasm
|
||||
@ls -l openquell-$(SHORTVERSION).zip
|
||||
|
||||
test:
|
||||
@echo $(VERSION)
|
||||
|
||||
5
TODO.md
@@ -24,7 +24,12 @@
|
||||
|
||||
- Turn menu button in hud_system (events in level_scene!) into ebitenui button
|
||||
|
||||
- Obstacle don't stop at collectibles
|
||||
|
||||
- Player can collect collectible hidden under obstacle (should be
|
||||
fixed when above is fixed)
|
||||
|
||||
- Remove Sprite from Tile{}, not used anymore
|
||||
|
||||
## Collider Rework [abandoned: see branch collider-system, fails]
|
||||
|
||||
|
||||
@@ -33,6 +33,8 @@ type Tile struct {
|
||||
TileNames []string // same thing, only the names
|
||||
Obstacle bool // is an obstacle/enemy
|
||||
Direction int // obstacle business end shows into this direction
|
||||
Shader *ebiten.Shader
|
||||
Alpha *ebiten.Image
|
||||
}
|
||||
|
||||
func (tile *Tile) Clone() *Tile {
|
||||
@@ -53,6 +55,8 @@ func (tile *Tile) Clone() *Tile {
|
||||
TileNames: tile.TileNames,
|
||||
Obstacle: tile.Obstacle,
|
||||
Direction: tile.Direction,
|
||||
Alpha: tile.Alpha,
|
||||
Shader: tile.Shader,
|
||||
}
|
||||
|
||||
return newtile
|
||||
@@ -158,24 +162,16 @@ func NewTileTranswall(class []string) *Tile {
|
||||
}
|
||||
}
|
||||
|
||||
func NewTileHiddenDoor(class []string) *Tile {
|
||||
sprites := []*ebiten.Image{}
|
||||
names := []string{}
|
||||
|
||||
for _, sprite := range class {
|
||||
sprites = append(sprites, Assets[sprite])
|
||||
names = append(names, sprite)
|
||||
}
|
||||
|
||||
func NewTileHiddenDoor(class, alpha string) *Tile {
|
||||
return &Tile{
|
||||
Id: 'W',
|
||||
Class: "hiddendoor",
|
||||
Solid: false,
|
||||
Renderable: true,
|
||||
Destroyable: true,
|
||||
Tiles: sprites,
|
||||
Sprite: sprites[0], // initially use the first
|
||||
TileNames: names,
|
||||
Sprite: Assets[class],
|
||||
Alpha: Assets[alpha],
|
||||
Shader: Shaders["destruct"],
|
||||
}
|
||||
}
|
||||
|
||||
@@ -196,7 +192,7 @@ func InitTiles() TileRegistry {
|
||||
"ObstacleWest": NewTileObstacle("obstacle-west", config.West),
|
||||
"ObstacleEast": NewTileObstacle("obstacle-east", config.East),
|
||||
"Particle": NewTileParticle([]string{
|
||||
//"particle-ring-1",
|
||||
"particle-ring-1",
|
||||
"particle-ring-2",
|
||||
"particle-ring-3",
|
||||
"particle-ring-4",
|
||||
@@ -204,7 +200,19 @@ func InitTiles() TileRegistry {
|
||||
"particle-ring-6",
|
||||
}),
|
||||
"Transient": NewTileTranswall([]string{"transwall", "block-orange-32"}),
|
||||
"HiddenDoor": NewTileHiddenDoor([]string{"block-greycolored", "block-greycolored-damaged"}),
|
||||
"HiddenDoor": NewTileHiddenDoor("block-greycolored", "damage"),
|
||||
"HiddenDoor2": NewTileHiddenDoor("block-greycolored", "damage"),
|
||||
"HiddenDoor3": NewTileHiddenDoor("block-greycolored", "damage"),
|
||||
"HiddenDoor4": NewTileHiddenDoor("block-greycolored", "damage"),
|
||||
"HiddenDoor5": NewTileHiddenDoor("block-greycolored", "damage"),
|
||||
"HiddenDoor6": NewTileHiddenDoor("block-greycolored", "damage"),
|
||||
"HiddenDoor7": NewTileHiddenDoor("block-greycolored", "damage"),
|
||||
"HiddenDoor8": NewTileHiddenDoor("block-greycolored", "damage"),
|
||||
"HiddenDoor9": NewTileHiddenDoor("block-greycolored", "damage"),
|
||||
"HiddenDoor10": NewTileHiddenDoor("block-greycolored", "damage"),
|
||||
"HiddenDoor11": NewTileHiddenDoor("block-greycolored", "damage"),
|
||||
"HiddenDoor12": NewTileHiddenDoor("block-greycolored", "damage"),
|
||||
"HiddenDoor13": NewTileHiddenDoor("block-greycolored", "damage"),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
49
assets/loader-shaders.go
Normal file
@@ -0,0 +1,49 @@
|
||||
package assets
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"log"
|
||||
"log/slog"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/hajimehoshi/ebiten/v2"
|
||||
)
|
||||
|
||||
type ShaderRegistry map[string]*ebiten.Shader
|
||||
|
||||
var Shaders = LoadShaders("shaders")
|
||||
|
||||
func LoadShaders(dir string) ShaderRegistry {
|
||||
shaders := ShaderRegistry{}
|
||||
|
||||
entries, err := assetfs.ReadDir(dir)
|
||||
if err != nil {
|
||||
log.Fatalf("failed to read shaders dir %s: %s", dir, err)
|
||||
}
|
||||
|
||||
for _, file := range entries {
|
||||
path := filepath.Join(dir, file.Name())
|
||||
fd, err := assetfs.Open(path)
|
||||
if err != nil {
|
||||
log.Fatalf("failed to open shader file %s: %s", file.Name(), err)
|
||||
}
|
||||
defer fd.Close()
|
||||
|
||||
name := strings.TrimSuffix(file.Name(), ".kg")
|
||||
|
||||
buf := new(bytes.Buffer)
|
||||
buf.ReadFrom(fd)
|
||||
|
||||
shader, err := ebiten.NewShader([]byte(buf.Bytes()))
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
shaders[name] = shader
|
||||
|
||||
slog.Debug("loaded shader asset", "path", path)
|
||||
}
|
||||
|
||||
return shaders
|
||||
}
|
||||
@@ -15,7 +15,7 @@ import (
|
||||
// Maps image name to image data
|
||||
type AssetRegistry map[string]*ebiten.Image
|
||||
|
||||
//go:embed sprites/*.png fonts/*.ttf levels/*.ldtk
|
||||
//go:embed sprites/*.png fonts/*.ttf levels/*.ldtk shaders/*.kg
|
||||
var assetfs embed.FS
|
||||
|
||||
var Assets = LoadImages("sprites")
|
||||
|
||||
36
assets/shaders/destruct.kg
Normal file
@@ -0,0 +1,36 @@
|
||||
// Copyright 2020 The Ebiten Authors
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
//go:build ignore
|
||||
|
||||
//kage:unit pixels
|
||||
|
||||
package main
|
||||
|
||||
var Damaged int
|
||||
|
||||
const HP float = 0
|
||||
|
||||
func Fragment(_ vec4, texCoord vec2, _ vec4) vec4 {
|
||||
wallpx := imageSrc0At(texCoord) // A pixel from the wall tile
|
||||
mask := imageSrc1At(texCoord) // A pixel from the damage mask image
|
||||
|
||||
if Damaged == 1 && (wallpx.a != 0.0 && mask.a != 0.0) {
|
||||
alpha := clamp(HP+(1.0-mask.a), 0.0, 1.0)
|
||||
// Create a darker pixel if it's inside a damage mask.
|
||||
return vec4(wallpx.r*alpha, wallpx.g*alpha, wallpx.b*alpha, wallpx.a)
|
||||
}
|
||||
|
||||
return wallpx // Otherwise, leave a pixel color as is
|
||||
}
|
||||
BIN
assets/sprites/crystal-entity-map.png
Normal file
|
After Width: | Height: | Size: 203 KiB |
BIN
assets/sprites/damage.png
Normal file
|
After Width: | Height: | Size: 5.4 KiB |
BIN
assets/sprites/entitymap.png
Normal file
|
After Width: | Height: | Size: 31 KiB |
BIN
assets/sprites/primarymap.png
Normal file
|
After Width: | Height: | Size: 132 KiB |
BIN
assets/sprites/tilemap.png
Normal file
|
After Width: | Height: | Size: 141 KiB |
@@ -8,6 +8,9 @@ import (
|
||||
|
||||
type Renderable struct {
|
||||
Image *ebiten.Image
|
||||
DamageImage *ebiten.Image
|
||||
Damaged int
|
||||
Shader *ebiten.Shader
|
||||
}
|
||||
|
||||
type Particle struct {
|
||||
|
||||
@@ -60,7 +60,7 @@ func (velocity *Velocity) InvertDirection() int {
|
||||
case North:
|
||||
return South
|
||||
case All:
|
||||
return Stop
|
||||
return All
|
||||
case Stop:
|
||||
return Stop
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ const (
|
||||
const PLAYERSPEED int = 5
|
||||
const PARTICLE_LOOPWAIT time.Duration = 250 * time.Millisecond
|
||||
const LEVEL_END_WAIT time.Duration = 500 * time.Millisecond
|
||||
const version string = "1.2.0"
|
||||
const version string = "1.2.1"
|
||||
|
||||
const MenuRectX int = 600
|
||||
const MenuRectY int = 0
|
||||
|
||||
@@ -52,7 +52,8 @@ func NewLevel(game *Game, cellsize int, plan *ldtkgo.Level) *Level {
|
||||
|
||||
systemlist = append(systemlist, systems.NewTransientSystem(game.World, gridcontainer))
|
||||
|
||||
systemlist = append(systemlist, systems.NewDestroyableSystem(game.World, gridcontainer))
|
||||
systemlist = append(systemlist, systems.NewDestroyableSystem(game.World, gridcontainer,
|
||||
game.Cellsize))
|
||||
|
||||
systemlist = append(systemlist, systems.NewHudSystem(game.World, plan))
|
||||
|
||||
@@ -145,7 +146,8 @@ func LevelToSlice(game *Game, level *ldtkgo.Level, tilesize int) (Map, Map) {
|
||||
// could use multiple tileset images
|
||||
tile := assets.Tiles["default"]
|
||||
|
||||
tile.Sprite = assets.Assets["map"].SubImage(
|
||||
// FIXME: load from LDTK file
|
||||
tile.Sprite = assets.Assets["primarymap"].SubImage(
|
||||
image.Rect(tileData.Src[0],
|
||||
tileData.Src[1],
|
||||
tileData.Src[0]+layer.GridSize,
|
||||
@@ -162,14 +164,15 @@ func LevelToSlice(game *Game, level *ldtkgo.Level, tilesize int) (Map, Map) {
|
||||
|
||||
case ldtkgo.LayerTypeEntity:
|
||||
// load mobile tiles (they call them entities) using static map map.png.
|
||||
tileset := assets.Assets["map"]
|
||||
tileset := assets.Assets["primarymap"]
|
||||
|
||||
for _, entity := range layer.Entities {
|
||||
if entity.TileRect != nil {
|
||||
tile := assets.Tiles[entity.Identifier]
|
||||
|
||||
slog.Debug("LOAD TILE", "tile", entity.TileRect)
|
||||
|
||||
tileRect := entity.TileRect
|
||||
//slog.Debug("tilerect", "x", tileRect.X, "y", tileRect.Y, "which", entity.Identifier)
|
||||
|
||||
tile.Sprite = tileset.SubImage(
|
||||
image.Rect(tileRect.X, tileRect.Y,
|
||||
|
||||
@@ -109,10 +109,17 @@ func NewGrid(world *ecs.World,
|
||||
entity := doormapper.New()
|
||||
pos, render, destroyable = doormapper.Get(entity)
|
||||
destroyable.Sprites = tile.Tiles
|
||||
render.DamageImage = tile.Alpha
|
||||
render.Shader = tile.Shader
|
||||
render.Damaged = 0
|
||||
default:
|
||||
log.Fatalln("unsupported tile type encountered")
|
||||
}
|
||||
|
||||
// FIXME: this image is never being used because it is
|
||||
// being overwritten in game/levels.go:LevelToSlice(). The
|
||||
// image is taken from the LDTK map, not from the Tile{}
|
||||
// definition anymore
|
||||
render.Image = tile.Sprite
|
||||
|
||||
default:
|
||||
|
||||
BIN
src/entities/church_3.png
Normal file
|
After Width: | Height: | Size: 2.0 KiB |
BIN
src/entities/cobalt_stone_10.png
Normal file
|
After Width: | Height: | Size: 514 B |
BIN
src/entities/crystal_wall_0.png
Normal file
|
After Width: | Height: | Size: 1.2 KiB |
BIN
src/entities/emerald_5.png
Normal file
|
After Width: | Height: | Size: 1.7 KiB |
BIN
src/entities/lab-stone_0.png
Normal file
|
After Width: | Height: | Size: 360 B |
BIN
src/entities/marble_wall_5.png
Normal file
|
After Width: | Height: | Size: 882 B |
BIN
src/entities/relief_1.png
Normal file
|
After Width: | Height: | Size: 1.1 KiB |
BIN
src/entities/relief_brown_1.png
Normal file
|
After Width: | Height: | Size: 571 B |
BIN
src/entities/stone2_brown_3_new.png
Normal file
|
After Width: | Height: | Size: 573 B |
BIN
src/entities/stone_2_brown0.png
Normal file
|
After Width: | Height: | Size: 555 B |
BIN
src/entities/stone_2_dark0.png
Normal file
|
After Width: | Height: | Size: 847 B |
BIN
src/entities/stone_2_gray0.png
Normal file
|
After Width: | Height: | Size: 909 B |
BIN
src/entities/stone_dark_3.png
Normal file
|
After Width: | Height: | Size: 2.5 KiB |
BIN
src/entities/stone_gray_1.png
Normal file
|
After Width: | Height: | Size: 884 B |
BIN
src/entitymap.xcf
Normal file
BIN
src/mixed-walls/church_0.png
Normal file
|
After Width: | Height: | Size: 1.8 KiB |
BIN
src/mixed-walls/church_1.png
Normal file
|
After Width: | Height: | Size: 1.9 KiB |
BIN
src/mixed-walls/church_2.png
Normal file
|
After Width: | Height: | Size: 2.0 KiB |
BIN
src/mixed-walls/church_3.png
Normal file
|
After Width: | Height: | Size: 2.0 KiB |
BIN
src/mixed-walls/church_4.png
Normal file
|
After Width: | Height: | Size: 1.9 KiB |
BIN
src/mixed-walls/cobalt_stone_10.png
Normal file
|
After Width: | Height: | Size: 514 B |
BIN
src/mixed-walls/cobalt_stone_11.png
Normal file
|
After Width: | Height: | Size: 516 B |
BIN
src/mixed-walls/cobalt_stone_12.png
Normal file
|
After Width: | Height: | Size: 519 B |
BIN
src/mixed-walls/cobalt_stone_6.png
Normal file
|
After Width: | Height: | Size: 497 B |
BIN
src/mixed-walls/cobalt_stone_7.png
Normal file
|
After Width: | Height: | Size: 498 B |
BIN
src/mixed-walls/cobalt_stone_8.png
Normal file
|
After Width: | Height: | Size: 510 B |
BIN
src/mixed-walls/cobalt_stone_9.png
Normal file
|
After Width: | Height: | Size: 511 B |
BIN
src/mixed-walls/crystal_wall_0.png
Normal file
|
After Width: | Height: | Size: 1.2 KiB |
BIN
src/mixed-walls/crystal_wall_12.png
Normal file
|
After Width: | Height: | Size: 1.2 KiB |
BIN
src/mixed-walls/crystal_wall_1_0.png
Normal file
|
After Width: | Height: | Size: 1.0 KiB |
BIN
src/mixed-walls/crystal_wall_4.png
Normal file
|
After Width: | Height: | Size: 1.2 KiB |
BIN
src/mixed-walls/crystal_wall_6.png
Normal file
|
After Width: | Height: | Size: 1.0 KiB |
BIN
src/mixed-walls/crystal_wall_8.png
Normal file
|
After Width: | Height: | Size: 1.1 KiB |
BIN
src/mixed-walls/crystal_wall_blue.png
Normal file
|
After Width: | Height: | Size: 1.3 KiB |
BIN
src/mixed-walls/crystal_wall_brown.png
Normal file
|
After Width: | Height: | Size: 917 B |
BIN
src/mixed-walls/crystal_wall_cyan.png
Normal file
|
After Width: | Height: | Size: 1.3 KiB |
BIN
src/mixed-walls/crystal_wall_green.png
Normal file
|
After Width: | Height: | Size: 1.3 KiB |
BIN
src/mixed-walls/crystal_wall_lightblue.png
Normal file
|
After Width: | Height: | Size: 1.3 KiB |
BIN
src/mixed-walls/crystal_wall_lightcyan.png
Normal file
|
After Width: | Height: | Size: 1.3 KiB |
BIN
src/mixed-walls/crystal_wall_lightgray.png
Normal file
|
After Width: | Height: | Size: 910 B |
BIN
src/mixed-walls/crystal_wall_lightgreen.png
Normal file
|
After Width: | Height: | Size: 1.3 KiB |
BIN
src/mixed-walls/crystal_wall_lightmagenta.png
Normal file
|
After Width: | Height: | Size: 1.3 KiB |
BIN
src/mixed-walls/crystal_wall_lightred.png
Normal file
|
After Width: | Height: | Size: 1.3 KiB |
BIN
src/mixed-walls/crystal_wall_magenta.png
Normal file
|
After Width: | Height: | Size: 1.3 KiB |
BIN
src/mixed-walls/crystal_wall_red.png
Normal file
|
After Width: | Height: | Size: 1.3 KiB |
BIN
src/mixed-walls/crystal_wall_white.png
Normal file
|
After Width: | Height: | Size: 975 B |
BIN
src/mixed-walls/crystal_wall_yellow.png
Normal file
|
After Width: | Height: | Size: 1.3 KiB |
BIN
src/mixed-walls/emerald_1.png
Normal file
|
After Width: | Height: | Size: 2.7 KiB |
BIN
src/mixed-walls/emerald_2.png
Normal file
|
After Width: | Height: | Size: 2.0 KiB |
BIN
src/mixed-walls/emerald_3.png
Normal file
|
After Width: | Height: | Size: 1.8 KiB |
BIN
src/mixed-walls/emerald_4.png
Normal file
|
After Width: | Height: | Size: 1.8 KiB |
BIN
src/mixed-walls/emerald_5.png
Normal file
|
After Width: | Height: | Size: 1.7 KiB |
BIN
src/mixed-walls/emerald_6.png
Normal file
|
After Width: | Height: | Size: 1.6 KiB |
BIN
src/mixed-walls/emerald_8.png
Normal file
|
After Width: | Height: | Size: 1.7 KiB |
BIN
src/mixed-walls/lab-metal_0.png
Normal file
|
After Width: | Height: | Size: 290 B |
BIN
src/mixed-walls/lab-metal_1.png
Normal file
|
After Width: | Height: | Size: 354 B |
BIN
src/mixed-walls/lab-metal_2.png
Normal file
|
After Width: | Height: | Size: 385 B |
BIN
src/mixed-walls/lab-metal_3.png
Normal file
|
After Width: | Height: | Size: 383 B |
BIN
src/mixed-walls/lab-metal_4.png
Normal file
|
After Width: | Height: | Size: 395 B |
BIN
src/mixed-walls/lab-stone_0.png
Normal file
|
After Width: | Height: | Size: 360 B |
BIN
src/mixed-walls/lab-stone_1.png
Normal file
|
After Width: | Height: | Size: 375 B |
BIN
src/mixed-walls/lab-stone_2.png
Normal file
|
After Width: | Height: | Size: 384 B |
BIN
src/mixed-walls/marble_wall_1.png
Normal file
|
After Width: | Height: | Size: 813 B |
BIN
src/mixed-walls/marble_wall_10.png
Normal file
|
After Width: | Height: | Size: 1.2 KiB |
BIN
src/mixed-walls/marble_wall_11.png
Normal file
|
After Width: | Height: | Size: 1.2 KiB |
BIN
src/mixed-walls/marble_wall_12.png
Normal file
|
After Width: | Height: | Size: 1.2 KiB |
BIN
src/mixed-walls/marble_wall_2.png
Normal file
|
After Width: | Height: | Size: 931 B |
BIN
src/mixed-walls/marble_wall_3.png
Normal file
|
After Width: | Height: | Size: 843 B |
BIN
src/mixed-walls/marble_wall_4.png
Normal file
|
After Width: | Height: | Size: 874 B |
BIN
src/mixed-walls/marble_wall_5.png
Normal file
|
After Width: | Height: | Size: 882 B |
BIN
src/mixed-walls/marble_wall_6.png
Normal file
|
After Width: | Height: | Size: 956 B |
BIN
src/mixed-walls/marble_wall_7.png
Normal file
|
After Width: | Height: | Size: 934 B |
BIN
src/mixed-walls/marble_wall_8.png
Normal file
|
After Width: | Height: | Size: 1.0 KiB |
BIN
src/mixed-walls/marble_wall_9.png
Normal file
|
After Width: | Height: | Size: 1.2 KiB |
BIN
src/mixed-walls/permarock_red_0.png
Normal file
|
After Width: | Height: | Size: 1.5 KiB |
BIN
src/mixed-walls/relief_0.png
Normal file
|
After Width: | Height: | Size: 1.2 KiB |
BIN
src/mixed-walls/relief_1.png
Normal file
|
After Width: | Height: | Size: 1.1 KiB |
BIN
src/mixed-walls/relief_2.png
Normal file
|
After Width: | Height: | Size: 1.1 KiB |
BIN
src/mixed-walls/relief_3.png
Normal file
|
After Width: | Height: | Size: 1.2 KiB |
BIN
src/mixed-walls/relief_brown_0.png
Normal file
|
After Width: | Height: | Size: 561 B |
BIN
src/mixed-walls/relief_brown_1.png
Normal file
|
After Width: | Height: | Size: 571 B |
BIN
src/mixed-walls/relief_brown_2.png
Normal file
|
After Width: | Height: | Size: 565 B |