|
|
@ -4,46 +4,287 @@ |
|
|
|
# |
|
|
|
# 7 Hour Rogue Like, November 12, 2016 |
|
|
|
|
|
|
|
from time import sleep as sleep |
|
|
|
import sys |
|
|
|
import curses |
|
|
|
from curses import wrapper |
|
|
|
import sys, os, curses, random, threading |
|
|
|
|
|
|
|
# Curses config |
|
|
|
stdscr = curses.initscr() |
|
|
|
# Curses stuff |
|
|
|
term = curses.initscr() |
|
|
|
curses.noecho() |
|
|
|
curses.cbreak() |
|
|
|
stdscr.keypad(True) |
|
|
|
curses.start_color() |
|
|
|
term.keypad(True) |
|
|
|
#curses.start_color() |
|
|
|
curses.curs_set(0) |
|
|
|
term.nodelay(1) |
|
|
|
|
|
|
|
# Debug flags |
|
|
|
#sound trigger |
|
|
|
triggered = True |
|
|
|
|
|
|
|
FAST = False # disables slow printing (you know, dev) |
|
|
|
|
|
|
|
def game(something): |
|
|
|
def slow(string): |
|
|
|
slow = not FAST |
|
|
|
for char in string: |
|
|
|
term.addch(char) |
|
|
|
term.refresh() |
|
|
|
get = term.getch() |
|
|
|
if(get == -1): |
|
|
|
pass |
|
|
|
else: |
|
|
|
slow = False |
|
|
|
if slow: curses.napms(100) |
|
|
|
|
|
|
|
def soundOne(): |
|
|
|
os.system("play 1.ogg 2>/dev/null") |
|
|
|
|
|
|
|
def soundTwo(): |
|
|
|
''' |
|
|
|
os.system("play begin.ogg 2>/dev/null") |
|
|
|
os.system("play mid.ogg 2>/dev/null") |
|
|
|
os.system("play fin.ogg 2>/dev/null") |
|
|
|
''' |
|
|
|
os.system("play game.ogg 2>/dev/null") |
|
|
|
|
|
|
|
def shoot(): |
|
|
|
os.system("play blast.mp3 2>/dev/null") |
|
|
|
|
|
|
|
def rocket(): |
|
|
|
os.system("play rocket.mp3 2>/dev/null") |
|
|
|
|
|
|
|
def john(): |
|
|
|
os.system("play and-his-name-is-john-cena.mp3 2>/dev/null") |
|
|
|
|
|
|
|
def intro(): |
|
|
|
# Clear screen |
|
|
|
stdscr.clear() |
|
|
|
curses.init_pair(1, curses.COLOR_RED, curses.COLOR_BLACK) |
|
|
|
stdscr.addstr(0,0, "test", curses.color_pair(1)) |
|
|
|
term.clear() |
|
|
|
# intro |
|
|
|
string = "You enter a strange land, the trees are scragly and dark.\n" |
|
|
|
for char in string: |
|
|
|
stdscr.addch(char, curses.color_pair(1)) |
|
|
|
stdscr.refresh() |
|
|
|
if not FAST: sleep(0.1) |
|
|
|
sleep(2) |
|
|
|
string = "The sky is grey and gringy.\n" |
|
|
|
for char in string: |
|
|
|
stdscr.addch(char, curses.color_pair(1)) |
|
|
|
stdscr.refresh() |
|
|
|
if not FAST: sleep(0.1) |
|
|
|
sleep(2) |
|
|
|
string = "You walk along a path, aproaching a mountain through this dead forest.\n" |
|
|
|
for char in string: |
|
|
|
stdscr.addch(char, curses.color_pair(1)) |
|
|
|
stdscr.refresh() |
|
|
|
if not FAST: sleep(0.1) |
|
|
|
sleep(2) |
|
|
|
slow ("You enter a strange land, the trees are scragly and dark.\n") |
|
|
|
slow ("The sky is grey and gringy.\n") |
|
|
|
slow ("You walk along a cobblestone path,\n") |
|
|
|
slow ("through this dead forest.\n") |
|
|
|
term.nodelay(0) |
|
|
|
term.addstr(6,6, "Press any key to continue (or space to skip)") |
|
|
|
curses.curs_set(1) |
|
|
|
term.refresh() |
|
|
|
action = term.getch() |
|
|
|
if action == 32: FAST = True |
|
|
|
term.clear() |
|
|
|
term.refresh() |
|
|
|
if not FAST: curses.napms(800) |
|
|
|
st1.start() |
|
|
|
if not FAST: curses.napms(200)#200ms |
|
|
|
term.addstr(6,6, "As you walk, you notice a dark motion to the right.") |
|
|
|
term.refresh() |
|
|
|
if not FAST: curses.napms(2000)#2200ms |
|
|
|
term.addstr(8,6, "It is swift and secretive") |
|
|
|
term.refresh() |
|
|
|
if not FAST: curses.napms(2000)#4200ms |
|
|
|
term.addch(".") |
|
|
|
term.refresh() |
|
|
|
if not FAST: curses.napms(1000)#5200ms |
|
|
|
term.addch(".") |
|
|
|
term.refresh() |
|
|
|
if not FAST: curses.napms(1000)#6200ms |
|
|
|
term.addch(".") |
|
|
|
term.refresh() |
|
|
|
if not FAST: curses.napms(8000)#14200ms |
|
|
|
term.addstr(10, 6, "Frightened, you begin running up the path.") |
|
|
|
term.refresh() |
|
|
|
if not FAST: curses.napms(10000)#24200ms |
|
|
|
term.addstr(12, 6, "Suddenly, there's a flash") |
|
|
|
term.refresh() |
|
|
|
if not FAST: curses.napms(2000)#26200ms |
|
|
|
curses.curs_set(0) |
|
|
|
term.clear() |
|
|
|
term.refresh() |
|
|
|
if not FAST: curses.napms(4000)#30200ms |
|
|
|
term.addstr(6, 6, ".. and then you see nothing") |
|
|
|
curses.curs_set(1) |
|
|
|
term.refresh() |
|
|
|
if not FAST: curses.napms(5000)#35200ms |
|
|
|
term.addstr(8, 10, "It's as though you're in a daze, a dream.") |
|
|
|
term.refresh() |
|
|
|
if not FAST: curses.napms(18000)#53.2s |
|
|
|
term.clear() |
|
|
|
term.addstr(6,6, "You slowly move forwards, stumbling up the path") |
|
|
|
term.refresh() |
|
|
|
if not FAST: curses.napms(2000)#55.2s |
|
|
|
term.addstr(8, 6, "objects begin to flow into your vision,") |
|
|
|
term.refresh() |
|
|
|
if not FAST: curses.napms(3000)#58.2s |
|
|
|
term.addstr(10, 6, "abstract thoughts with no bearing or direction") |
|
|
|
term.refresh() |
|
|
|
if not FAST: curses.napms(12000)#70.2s |
|
|
|
term.addstr(12, 6, "A flash comes from the right,") |
|
|
|
term.addstr(14, 6, "as an alien enters your vision,") |
|
|
|
term.addstr(16, 6, "a purple, slimy, alien.") |
|
|
|
term.refresh() |
|
|
|
if not FAST: curses.napms(7800)#78s |
|
|
|
term.clear() |
|
|
|
term.addstr(6,6, "Another alien comes into view.") |
|
|
|
term.addstr(8,6, "You are very afraid now.") |
|
|
|
term.refresh() |
|
|
|
if not FAST: curses.napms(8000)#? doesn't matter |
|
|
|
term.clear() |
|
|
|
term.addstr(6,10, "Suddenly, the ground appears again!") |
|
|
|
term.addstr(10,10, "Controls: Press wasd (or the arrow keys) to move,") |
|
|
|
term.addstr(12,20, "and space to attack. TAP the keys") |
|
|
|
term.addstr(16,10, "Use the numeric keys 1-3 to select your weapon:") |
|
|
|
term.addstr(18,12, "1: gun") |
|
|
|
term.addstr(19,12, "2: gernade launcher") |
|
|
|
term.addstr(20,12, "3: john cena") |
|
|
|
term.addstr(22,12, "Press any key to continue") |
|
|
|
term.refresh() |
|
|
|
term.getch() |
|
|
|
|
|
|
|
def game(): |
|
|
|
curses.curs_set(0) |
|
|
|
os.system("pkill play 2>/dev/null 1>/dev/null 0>/dev/null") |
|
|
|
st2.start() |
|
|
|
curses.napms(100) |
|
|
|
term.clear() |
|
|
|
term.refresh() |
|
|
|
# 32space, a97, w119, s115, d100, up259, down258, left260, right261 |
|
|
|
# 1:49,2:50,3:51,4:52,5:53 |
|
|
|
|
|
|
|
cont = True |
|
|
|
|
|
|
|
# Player stats |
|
|
|
|
|
|
|
points = 1 |
|
|
|
weapon = 1 |
|
|
|
message = "" |
|
|
|
px = 0 |
|
|
|
py = 0 |
|
|
|
|
|
|
|
# Enemy Stats |
|
|
|
|
|
|
|
health = 20 |
|
|
|
epx = 0 |
|
|
|
epy = 0 |
|
|
|
|
|
|
|
# Enemy Sprite |
|
|
|
|
|
|
|
s1 = " _______" |
|
|
|
s2 = " .' '." |
|
|
|
s3 = " _.-~===========~-._" |
|
|
|
s4 = "(___________________)" |
|
|
|
s5 = " \_______/" |
|
|
|
|
|
|
|
while(cont): |
|
|
|
# Draw |
|
|
|
term.clear() |
|
|
|
term.border(0) |
|
|
|
term.addstr(0,30,"Destroy the aliens!") |
|
|
|
term.addstr(2,23,"Score: " + str(points)) |
|
|
|
term.addstr(2,35,"Alien Health: " + str(health)) |
|
|
|
term.addstr(4,28,message) |
|
|
|
term.addstr(6 + epy,6 + epx,s1) |
|
|
|
term.addstr(7 + epy,6 + epx,s2) |
|
|
|
term.addstr(8 + epy,6 + epx,s3) |
|
|
|
term.addstr(9 + epy,6 + epx,s4) |
|
|
|
term.addstr(10 + epy,6 + epx,s5) |
|
|
|
term.addch(18 + py, 6 + px, "#") |
|
|
|
term.refresh() |
|
|
|
# Act |
|
|
|
action = term.getch() |
|
|
|
if action != -1: |
|
|
|
if action == 32: |
|
|
|
if weapon == 1: |
|
|
|
if abs((epx+10) - px) < 15: |
|
|
|
shoot() |
|
|
|
message = "you aimed and shot an alien" |
|
|
|
points+=1 |
|
|
|
health-=1 |
|
|
|
else: |
|
|
|
message = "you were not close enough" |
|
|
|
elif weapon == 2: |
|
|
|
if abs((epx + 10) - px) < 30: |
|
|
|
rocket() |
|
|
|
message = "wrecked! a space ship blew up" |
|
|
|
points+=5 |
|
|
|
health-=3 |
|
|
|
else: |
|
|
|
message = "you were not close enough" |
|
|
|
else: |
|
|
|
john() |
|
|
|
message = "you scared an alien child away" |
|
|
|
points-=3 |
|
|
|
health-=1 |
|
|
|
elif action == 49: |
|
|
|
weapon = 1 |
|
|
|
os.system("espeak \"gun selected\" 2>/dev/null") |
|
|
|
elif action == 50: |
|
|
|
weapon = 2 |
|
|
|
os.system("espeak \"gernade launcher selected\" 2>/dev/null") |
|
|
|
elif action == 51: |
|
|
|
weapon = 3 |
|
|
|
os.system("espeak \"john cena selected\" 2>/dev/null") |
|
|
|
# a97, w119, s115, d100, up259, down258, left260, right261 |
|
|
|
elif action == 97: |
|
|
|
if px > 0: px-=1 |
|
|
|
elif action == 260: |
|
|
|
if px > 0: px-=1 |
|
|
|
elif action == 100: |
|
|
|
if px < 60: px+=1 |
|
|
|
elif action == 261: |
|
|
|
if px < 60: px+=1 |
|
|
|
elif action == 119: |
|
|
|
if py > 0: py-=1 |
|
|
|
elif action == 259: |
|
|
|
if py > 0: py-=1 |
|
|
|
elif action == 115: |
|
|
|
if py < 4: py+=1 |
|
|
|
elif action == 258: |
|
|
|
if py < 4: py+=1 |
|
|
|
else: |
|
|
|
os.system("espeak \"" + str(action) + "\" 2>/dev/null") |
|
|
|
pass |
|
|
|
|
|
|
|
movex = random.randint(1,3) |
|
|
|
movex-=2 |
|
|
|
if movex == -1: |
|
|
|
if epx > 0: epx+=movex |
|
|
|
elif movex == 1: |
|
|
|
if epx < 40: epx+=movex |
|
|
|
else: |
|
|
|
pass |
|
|
|
movey = random.randint(1,3) |
|
|
|
movey-=2 |
|
|
|
if movey == -1: |
|
|
|
if epy > 0: epy+=movey |
|
|
|
elif movey == 1: |
|
|
|
if epy < 4: epy+=movey |
|
|
|
else: |
|
|
|
pass |
|
|
|
if points < 0: |
|
|
|
cont = False |
|
|
|
term.clear() |
|
|
|
term.addstr(6,6,"You lost!") |
|
|
|
if health < 18: |
|
|
|
term.addstr(8,6, "You got shot") |
|
|
|
else: |
|
|
|
term.addstr(8,6, "You got bass blasted") |
|
|
|
term.addstr(10,6,"Your score was " + str(points)) |
|
|
|
term.refresh() |
|
|
|
curses.napms(5000) |
|
|
|
if health < 0: |
|
|
|
cont = False |
|
|
|
term.clear() |
|
|
|
term.addstr(6,6,"Your sanity has been returned") |
|
|
|
term.addstr(8,6,"Your score was " + str(points)) |
|
|
|
term.refresh() |
|
|
|
curses.napms(5000) |
|
|
|
|
|
|
|
points-=0.1 |
|
|
|
|
|
|
|
st1 = threading.Thread(target=soundOne) |
|
|
|
st2 = threading.Thread(target=soundTwo) |
|
|
|
|
|
|
|
wrapper(game) |
|
|
|
try: |
|
|
|
intro() |
|
|
|
game() |
|
|
|
except KeyboardInterrupt: |
|
|
|
curses.endwin() |
|
|
|
except Exception as err: |
|
|
|
curses.endwin() |
|
|
|
print(err) |
|
|
|
curses.endwin() |