aboutsummaryrefslogtreecommitdiff
path: root/rocks.py
diff options
context:
space:
mode:
Diffstat (limited to 'rocks.py')
-rw-r--r--rocks.py41
1 files changed, 41 insertions, 0 deletions
diff --git a/rocks.py b/rocks.py
new file mode 100644
index 0000000..975c799
--- /dev/null
+++ b/rocks.py
@@ -0,0 +1,41 @@
+from explore import Explore
+import curses
+from math import floor
+
+explore = Explore(0.0025)
+
+screen = curses.initscr()
+curses.noecho() #makes keys not put text on screen
+curses.cbreak() #removes buffer, allowing prog to receive control immediately
+screen.keypad(True) #allows arrow keys and things to work
+screen.scrollok(False) #disables scrolling
+
+key = ''
+while key != ord('q'):
+ dim = screen.getmaxyx()
+ if key in [curses.KEY_DOWN, curses.KEY_RIGHT, curses.KEY_UP, curses.KEY_LEFT]:
+ explore.displace(explore.interpretkey(key),(floor(dim[0]/2),floor(dim[1]/4)))
+ if key in [ord('.'), ord('/')]:
+ explore.rockmod((floor(dim[0]/2), floor(dim[1]/4)), key == ord('/'))
+ if key in [ord('s'), ord('l')]:
+ screen.addstr(dim[0]-1, 0, 'File:'+' '*(dim[1]-6))
+ curses.echo()
+ file = screen.getstr(dim[0]-1, 6)
+ curses.noecho()
+ if key == ord('s'):
+ explore.save(file)
+ else:
+ screen.clear()
+ explore.load(file)
+ if key == ord('\\'):
+ explore.setportal((floor(dim[0]/2), floor(dim[1]/4)))
+ screen.addstr(0, 0, explore.get_area(dim))
+ screen.addstr(dim[0]-1, 0, str(explore.getinv()))
+ screen.refresh()
+ key = screen.getch(floor(dim[0]/2), 2*floor(dim[1]/4))
+
+screen.scrollok(True)
+curses.nocbreak()
+screen.keypad(False)
+curses.echo()
+curses.endwin() #finished program; resets to normal