Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
155 commits
Select commit Hold shift + click to select a range
0e2e6e4
refactor: look work on single item and stay in inventory
caspersg Jan 19, 2025
d7a413b
refactor: pilfer without removing from inventory
caspersg Jan 19, 2025
d0578a0
refactor: use get_item where possible, and less notify on pickup
caspersg Jan 19, 2025
7678673
fix: bug on player position when inserting
caspersg Jan 19, 2025
d21104e
feat: create dynamic keymaps to get player input for actions, dynamic…
caspersg Jan 19, 2025
43f4229
fix: only show groups for keymaps that exist, so only show possible a…
caspersg Jan 19, 2025
13fb275
feat: rest up to 9 turns with menu
caspersg Jan 19, 2025
bc2017a
fix: bug with missing moves, probably on items
caspersg Jan 19, 2025
e3c3f70
feat: say spells to enemies/items using keymap menu
caspersg Jan 19, 2025
0e16494
feat: use letters so action menu is flatter
caspersg Jan 19, 2025
5160ab6
fix: bug with old wear keymaps no being removed, and other old groups…
caspersg Jan 19, 2025
f5d6942
fix: try to reduce flickering
caspersg Mar 13, 2025
b13281a
wip: love2d hello world
caspersg Mar 14, 2025
8fb4564
feat: basic love build and run makefile
caspersg Mar 14, 2025
7e3f342
feat: add makefile to build windows exe
caspersg Mar 14, 2025
1073102
style: add love as a global
caspersg Mar 14, 2025
65a1930
chore: only build DIST if it's changed
caspersg Mar 14, 2025
3742564
feat: add rotLove v0.4.0 lib and build an example
caspersg Mar 23, 2025
cb2f116
chore: update rotLove to include type annotations
caspersg Mar 23, 2025
ef5fc82
style: update main to work with type annotations
caspersg Mar 23, 2025
54b7340
chore: update rotLove
caspersg Mar 23, 2025
0a83b18
feat: get a basic generated map being written, with faked vim functions
caspersg Mar 23, 2025
0b67d54
wip: extract love2d render file
caspersg Apr 7, 2025
ecf6780
wip: extract vim message and part of vim render
caspersg Apr 7, 2025
7726248
wip: move handlers into view_buffer and wip love2d message
caspersg Apr 7, 2025
31bc2cf
fix: makefile detecting source changes
caspersg Apr 7, 2025
ee931d6
wip: write messages to lower area
caspersg Apr 7, 2025
c4a6e28
fix: rot bug
caspersg Apr 7, 2025
692a95e
wip: draw message text with wrap
caspersg Apr 7, 2025
f7dfc88
refactor: abstract cursor get/set
caspersg Apr 7, 2025
f2888a2
wip: pull create view buffer apart from create buffer down not settin…
caspersg Apr 7, 2025
7b174f1
wip: minor refactor of view_buffer function names
caspersg Apr 8, 2025
c273e78
wip: simplify usage of view_buffer
caspersg Apr 8, 2025
ea9910f
refactor: extract cursor highlight
caspersg Apr 8, 2025
f5c7b15
refactor: extract write_buf to render
caspersg Apr 8, 2025
7d44fe1
refactor: use level instead of bufnr to index buffers
caspersg Apr 8, 2025
71a63c9
refactor: remove current_bufnr and use 0 which is always current bufnr
caspersg Apr 8, 2025
24e642c
wip: set view size
caspersg Apr 8, 2025
09403e2
refactor: move view_buffer under vim
caspersg Apr 8, 2025
6c01174
refactor: extract vim buffer setup and event handlers setup
caspersg Apr 8, 2025
6b5f366
refactor: extract dynamic_keymaps
caspersg Apr 8, 2025
8f518e9
wip: use game.start_game, map is rendering
caspersg Apr 8, 2025
c235fb9
wip: extract set_highlight
caspersg Apr 9, 2025
66cc7a9
wip: extract visual mode sneak
caspersg Apr 9, 2025
14c332d
wip: deal with change events later on
caspersg Apr 9, 2025
952c466
feat: ignore animations for now. Tick working on keypress enemies can…
caspersg Apr 9, 2025
6a71e09
wip: extract async api
caspersg Apr 11, 2025
d2f637b
fix: cursor api to be 1 indexed
caspersg Apr 11, 2025
e7ff15e
wip: extract color / highlight
caspersg Apr 11, 2025
94f759f
wip: store next frame colors and display once. love colors are wrong.
caspersg Apr 11, 2025
e3c8a3f
fix: love2d notify with multiple args
caspersg Apr 11, 2025
70e1e0b
fix: compile error
caspersg Apr 11, 2025
78708dd
wip: basic buffer of messages for love2d
caspersg Apr 11, 2025
8ebaaa0
fix: using a proper equal assert function now, no longer giving false…
caspersg Apr 11, 2025
21fe3a3
fix: only generate colors between 0,255
caspersg Apr 11, 2025
889a045
fix: use 0,1 not 0,255 since love2D version 11
caspersg Apr 11, 2025
2796b3b
chore: make run command
caspersg Apr 14, 2025
ae1b76f
feat: add basic love cursor using just a highlight
caspersg Apr 14, 2025
ece1cef
wip: add highlights for the cursor, and allow fg and bg highlights fo…
caspersg Apr 14, 2025
414923b
fix: calculate love colors up on creation, not render
caspersg Apr 14, 2025
ef13fce
wip: implement async defer and later, so cursor highlights can be cle…
caspersg Apr 14, 2025
e7764ca
refactor: use consistent types for cursor highlight
caspersg Apr 14, 2025
e81b986
wip: todo fix cursor trails
caspersg Apr 14, 2025
1dd40c6
feat: debug to console for love
caspersg Apr 16, 2025
dbfcdf0
fix: cursor trail by storing all unrendered cursor positions, to unhi…
caspersg Apr 16, 2025
a732631
fix: draw cursor in love.draw
caspersg Apr 17, 2025
736c891
chore: cleanup old code
caspersg Apr 17, 2025
24a8353
feat: basic menu
caspersg Apr 17, 2025
75ce27d
fix: show inventory on one line
caspersg Apr 17, 2025
ed69ab8
wip: start on more complete menu
caspersg Apr 17, 2025
18cc626
fix: bounce working again
caspersg Apr 17, 2025
01ee66e
test: fix tests and extract some helpers
caspersg Apr 17, 2025
1843ca1
wip: basic next/back by word
caspersg Apr 17, 2025
5cc3951
feat: rework messages so only player actions are shown by default, ad…
caspersg Apr 18, 2025
6097246
wip: add keys for sneaking, and minor keymap refactor
caspersg Apr 18, 2025
e7567a9
wip: added sub menu for kick
caspersg Apr 18, 2025
539f3be
docs: add todos
caspersg Apr 18, 2025
a50b5e1
fix: update immediately to render properly on startup
caspersg Apr 21, 2025
7b77af8
wip: menu takes up whole message window
caspersg Apr 21, 2025
ac1029e
wip: rework messages and help, varargs is working but wrong
caspersg Apr 21, 2025
e720d79
fix: use notify_lines for multi-line messages
caspersg Apr 21, 2025
476f5e8
wip: refactor tick logic, and bounce cursor as part of logic
caspersg Apr 21, 2025
936461c
wip: animate cursor bounce directly after writing buffer
caspersg Apr 21, 2025
41435d2
fix: simplify love cursor, and rely on animate for bounce
caspersg Apr 21, 2025
cf59000
wip: add more inventory keymaps
caspersg Apr 21, 2025
e82ce9f
wip: refactor nested menus, 3 deep still not working
caspersg Apr 21, 2025
399fd75
wip: got fuse menu working
caspersg Apr 21, 2025
1cd65e0
wip: got wear working
caspersg Apr 21, 2025
1401fb4
wip: show all inventory on multiple lines
caspersg Apr 21, 2025
98f4372
fix: end game working in love2d
caspersg Apr 22, 2025
9348c18
feat: added status line
caspersg Apr 22, 2025
562ebd3
feat: fullscreen based off resolution and scaling of 1 for chars
caspersg Apr 22, 2025
31caca8
wip: extract display scale
caspersg Apr 22, 2025
ac99d9d
fix: slow render by removing highlight from all terrain
caspersg Apr 22, 2025
d8f4aef
wip: quite menu with escape
caspersg Apr 22, 2025
5be60cd
wip: draw a map separator line
caspersg Apr 22, 2025
9eb1644
wip: rework all keys to be in a keymap, movement, inv, kick working
caspersg Apr 22, 2025
2ce7219
wip: got all keys working within a pending_keys menu framework. Shoul…
caspersg Apr 23, 2025
a2ef5cc
wip: write messages during draw only. Make menu override messages and…
caspersg Apr 23, 2025
e471a44
feat: add quit action and command
caspersg Apr 26, 2025
84a5564
fix: menu border covering text
caspersg Apr 26, 2025
61eb831
feat: add profiler
caspersg Apr 27, 2025
a3dfb79
fix: reduce expensive debug logging
caspersg Apr 27, 2025
3bd793e
fix: improve performance by limiting to view_distance rather than all…
caspersg Apr 27, 2025
27be642
fix: skip color validation for slightly improved performance
caspersg Apr 27, 2025
5bea736
fix: nil entity
caspersg Apr 27, 2025
ee1858b
test: turn profile off
caspersg Apr 27, 2025
febf28e
fix: print table error
caspersg Apr 27, 2025
ef9ce06
fix: keep keymaps working on death
caspersg Apr 27, 2025
d691187
wip: allow action and menu
caspersg Apr 27, 2025
c159897
wip: got rest for 1 turn working
caspersg Apr 28, 2025
ddc30ce
wip: got say action working
caspersg Apr 28, 2025
803ca86
wip: got rename working
caspersg Apr 28, 2025
59875c1
refactor: prompt logic
caspersg Apr 28, 2025
e525782
wip: fallback when there's no data text files
caspersg Apr 29, 2025
98b0d80
test: fix get_visible_entities test to ignore manhattan_distance
caspersg Apr 29, 2025
1b8845f
fix: previously broken test, terrain has no highlights now
caspersg Apr 29, 2025
17d8e25
wip: implement f and F find keymaps
caspersg Apr 29, 2025
7ee0b74
wip: implement t and T keymaps
caspersg Apr 29, 2025
9054bc1
wip: add gg and G keymaps
caspersg Apr 29, 2025
099a26b
wip: add / search keymap with a literal search only
caspersg Apr 29, 2025
ffb607b
wip: add regex for / and fix col offset for word
caspersg Apr 29, 2025
f0c5e8e
wip: added ? keymap and back search, but doesn't include cursor posit…
caspersg Apr 29, 2025
1537f84
wip: extract edits for vim/love2d, pickup working in vim again
caspersg Apr 30, 2025
cdfd178
new todos
caspersg May 2, 2025
6ad71cd
wip: add y while sneaking
caspersg May 4, 2025
4310da9
wip: add C-v for sneaking
caspersg May 4, 2025
05a5f87
refactor: fix spelling mistake
caspersg May 4, 2025
d95a6fd
wip: add aiming and other mode
caspersg May 4, 2025
2250ac6
wip: add cursor color for different modes, and refactor modes
caspersg May 4, 2025
c124c8d
wip: give entities a speed attribute, currently at 0.5 so enemies get…
caspersg May 9, 2025
89239e8
wip: add proper speed attribute
caspersg May 9, 2025
26121fc
wip: add up to one additional move depending on speed. render is brok…
caspersg May 9, 2025
04947c8
wip: add state.update to trigger a re-render
caspersg May 9, 2025
4c734a2
fix: flashing and showing whole map on start
caspersg May 9, 2025
1c3e0a2
fix: char flashing in non visible areas, by copying visible param whe…
caspersg May 9, 2025
718c5c6
wip: make async moves optional
caspersg May 9, 2025
2c69339
wip: try async movement in vim
caspersg May 9, 2025
9efd5ce
Merge pull request #28 from caspersg/async_moves
caspersg May 9, 2025
7be7fdb
wip: replace async with realtime, so enemies can move continually bas…
caspersg May 10, 2025
b131378
fix: write cursor on buffer write to fix cursor flashing
caspersg May 10, 2025
562baa7
fix: broken test
caspersg May 10, 2025
57c29eb
feat: add quit keymap for vim
caspersg May 10, 2025
51baeda
feat: pause when in menu
caspersg May 10, 2025
a542331
fix: picked up items disappear properly, but flashes are back
caspersg May 10, 2025
df110af
docs: document entry points
caspersg Sep 12, 2025
4ea7cab
ci: default make is now dist
caspersg Sep 15, 2025
4821bbc
fix: fatal error in love search for '$'
caspersg Sep 15, 2025
f0b8432
docs: add ready to release checkbox
caspersg Sep 15, 2025
d6d14ec
feat: better intro text
caspersg Sep 17, 2025
c26beb1
fix: handle death properly for love
caspersg Sep 17, 2025
d36b231
feat: debug mode off
caspersg Sep 17, 2025
40ee2af
fix: hide plenary notification
caspersg Sep 17, 2025
b32173b
fix: neovim initial state hides map
caspersg Sep 17, 2025
685147e
docs: add play instructions
caspersg Sep 17, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ luac.out
*.exp

# Shared objects (inc. Windows DLLs)
*.dll
# *.dll
*.so
*.so.*
*.dylib
Expand All @@ -40,3 +40,6 @@ luac.out
*.hex

.vim

Neohack
build
3 changes: 2 additions & 1 deletion .luarc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"diagnostics.globals": [
"describe",
"it"
"it",
"love"
]
}
49 changes: 48 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,54 @@
.PHONY: test
.PHONY: test ci clean dist
.DEFAULT_GOAL := dist

BUILD = build
TARGET = $(BUILD)/Neohack.love
SRC_DIR = lua
SRC = $(shell find $(SRC_DIR) -type f)
EXE = $(DIST)/Neohack.exe
DIST = Neohack
ZIP = Neohack.zip
DEPS = love/deps
DATA = data

test:
nvim --headless -u lua/config.lua -c "PlenaryBustedDirectory tests { minimal_init = 'lua/config.lua' }"

ci:
nvim --headless --noplugin -u scripts/minimal_init.vim -c "PlenaryBustedDirectory tests { minimal_init = './scripts/minimal_init.vim' }"

clean:
rm -rf $(TARGET)
rm -rf $(DIST)
rm -rf $(BUILD)
rm $(ZIP)

updateRotLove:
cp -r ../rotLove/src/* lua/lib/rotLove/

$(BUILD):
mkdir $(BUILD)

$(DIST): $(DATA) $(DEPS)
rm -rf $(DIST)
mkdir $(DIST)
cp $(DEPS)/* $(DIST)
mkdir $(DIST)/$(DATA)
cp $(DATA)/* $(DIST)/$(DATA)

$(TARGET): $(SRC) $(BUILD)
cd $(SRC_DIR) && zip -9 -r ../$(TARGET) *

run_love: $(TARGET)
love $(TARGET)

$(EXE): $(TARGET) $(DIST)
cat love/love.exe $(TARGET) > $(EXE)

$(ZIP): $(EXE)
cd $(DIST) && zip -9 -r ../$(ZIP) *

dist: $(ZIP)

run: dist
love $(BUILD)/Neohack.love
52 changes: 43 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# neohack.nvim
Roguelike game built inside neovim
Traditional Roguelike game built inside neovim and ported to love2d.

Move your cursor to move your player.
Because you have vim motions, your player can attack and teleport from a distance.
Expand All @@ -9,19 +9,32 @@ Insert text to drop items from you inventory, then pick it up to reorder invento
Yank to search.
Visual mode is sneaking which searches, avoids attacking, and avoids being hit.

Actions
- <leader>i show inventory
- <leader>l look at item in inventory
- <leader>w wield item as weapon
- <leader>f fuse multiple items into one item
- <leader>k kick in a direction
## Play

### As a Neovim plugin
Install neovim, Clone the repo, and run start.sh

This starts neovim with a custom config designed to play the game.

### On windows
Download the zip, Run the exe on windows

### On linux
Clone the repo, run `make run`

## TODO
- [x] Proof of Concept
- [x] basic controls
- [x] good enough performance
- [x] explore some features
- [x] enough vim features to try out an exe for windows
- [ ] neovim plugin mode to use your code as the map (reintroduce this mode)
- [ ] refactor all the code
- [x] add features first
- [x] refactor to have types
- [ ] have actually nice code
- [ ] unit tests
- [ ] performance
- [x] basics
- [x] track cursor movement
- [x] bounce off walls
Expand Down Expand Up @@ -157,19 +170,40 @@ Actions
- [ ] undo?
- [x] varied entities
- [x] item and enemy generation from dictionary
- [x] item and enemy variations with different colours
- [x] item and enemy variations with different colors
- [ ] map generation
- [x] generate random map progressively
- [x] have some structure to generated maps
- [x] new buffer for down
- [ ] add enemies and items in a later stage
- [ ] pick a selection, not fully random
- [ ] buffer as multidimensional movement
- [ ] :bprev dig lower, :bnext dig higher
- [ ] allow entities to do it too
- [ ] performance
- [x] write buffer once per tick
- [x] store map as 2D array
- [ ] vim tutor/tutorial map
- [ ] teach basic vim motions as game mechanics
- [ ] easy run
- [x] minimal neovim config with single command to run
- [ ] slash screen
- [ ] bundled exe?
- [ ] love2d
- [x] win exe
- [x] make run for linux
- [ ] reimplement vim motions
- [x] hjkl
- [x] words
- [x] ftFT
- [ ] counts
- [x] reimplement which-key
- [ ] modes
- [x] v sneak
- [ ] V aiming
- [ ] C-v - other TODO: what should this mode do?
- [x] colored cursor and status line for different modes
- [ ] try different timers for each entity
- [ ] async movement
- [ ] change events
- [ ] insert for commands

Loading