1
0
mirror of https://github.com/dschmenk/PLASMA.git synced 2024-07-08 09:28:57 +00:00

Final rogue

This commit is contained in:
David Schmenk 2014-12-29 16:55:26 -08:00
parent bfa25bf2b6
commit ac3c5164d7
7 changed files with 290 additions and 211 deletions

View File

@ -0,0 +1 @@
## .#[-]#.......#&......&..* # ..*...*...###T#.....####.. # ...###.....##.#...&...##.. # ....###.&....#.#.......##.. .............#.+.......##.. .............#.#.T.....##.. ......&#.....&.#.:.......##.. ......###....###.:.......##.. ##.....#.....###.#......&##.. #&.....*...#####.##:#:#:###.. ######......####.#&.........* ###.T......#####.##*....##### #..........#####.##.....##[=] ##....&#....&###.##.....#..O. #.....###...####.###....#$... ##&....#.....###.#&#....###%# ,##....*....####.##.>>.##*..* .######+########.##<<<..##... ...............&.##>>>>>....&

View File

@ -1 +1 @@
##....&$&#####.......##..#[-]#..#...........................T. #.....#######. .&##..*...*..#.##########......*...*......& .....###..... .###.........#.#.......###...##.....##....# #........ .####.........#...#####.##&...##.T...##....# ##. ..###.........#.#.#.....####....*...*......& #### ....######+#####.#.#.##########.........<<<<< ######### ........###.#&#.#.#.#..........#####....>>>>>> ###....&##......T........##.#..#..#.#.########....##...<<<<<<< &#.## ##############*....#.#####.#.#.#...#.&####..:...>>>>>>> ...... ############.....T#.......#.#...#T...#.##*.:....<<<<<< ###.........#####........##########.########:#.##..#...>>>>>>$ ##.....................*##.....................##..#..<<<<<<.. ..&###*..##..............#+##################.###*.#.>>>>>.... ..#####..##......#&........#..................##...#.<<<<....# ..&##O...#.....####....*####.###################*..#.>>>>...## ...............T##*....##.....................#....#.<<<....## #...........&..........#########.*.*.########.#O...#.>>>...O.# ####..................##.........#.#.....###..#.##.#........&# ..$.########........###..#########.####+####.##.##.#.......### #####......##########.&.##....O$&#.#..&.##*..#.....##....##... ......*###............###..#######.#.T..##..##.....##########+ .####....##############...*#...&O#.#...*&#O.#...##.....O##&... .&..####.....................#####.#..T..##.#...##............ ###T#&.#######################.....##.....#.#...*...##....*##. ..####.........................###..##....#.#.......##*....##. &....###########+###############.....###.&#.#..&##......##.... .#.O.#...#...&.......#&###.......###...##.#.#.T....*##....*... ...#...#...#...#...#.....####.####Z###..#.#.#.......##........ .#...#.&O#.*.#...#...#*.#Z#.#+#.......*.#.#.#&.........T....&. ..,#...#...#...#...#......#.............#O#+####...&......#### .#.&.#...#...#...#....&..##...#.........#+#.########.....####& ...#..Z#...#&..#..*...####.O..:.&.......#.:.#......O.......... .#...#...#...#.......##..#....:.........*.:.*Z................ &.......*.......######...##&..#::::::#....:.................## ####........#####.........###.............:.&.#::::::::::::::# ...##########...............#......O......:............&...... ............................#.............#......Z............ ............................##.............................##. .............................########%######################## ...open space............###########..:....................... ........................##............:..Z.................... ....fill it in!!.......##..############....................... .......................#..##.................................. ......................##...:.................................. ...##########...............#......O......:............&...... ...##########...............#......O......:............&...... ...##########...............#......O......:............&...... ...##########...............#......O......:............&...... ............................#.............#......Z............ ...##########...............#......O......:............&...... ............................##.............................##. ...##########...............#......O......:............&...... .............................########%######################## ...##########...............#......O......:............&...... ...open space............###########..:....................... ...##########...............#......O......:............&...... ........................##............:..Z.................... ...##########...............#......O......:............&...... ....fill it in!!.......##..############....................... ...##########...............#......O......:............&...... .......................#..##.................................. ...##########...............#......O......:............&...... ......................##...:.................................. ............................#.............#......Z............ ............................#.............#......Z............ ...##########...............#......O......:............&...... .......... .......Z..&#.................................... .R.......... ..&.......#.................................... ........R.... ........*##.................................... ............................#.............#......Z............ ...open space............###########..:....................... ............................#.............#......Z............ ........................##............:..Z....................
##....&@&#####.......##..#[-]#..#...........................T. #.....#######. .&##..*...*..#.##########......*...*......& .....###..... .###.........#.#.......###...##.....##....# #........ .####.........#...#####.##&...##.T...##....# ##. ..###.........#.#.#.....####....*...*......& #### ....######+#####.#.#.##########.........<<<<< ######### ........###.#&#.#.#.#..........#####....>>>>>> ###....&##......T........##.#..#..#.#.########....##...<<<<<<< &#.## ##############*....#.#####.#.#.#...#.&####..:...>>>>>>> ...... ############.....T#.......#.#...#T...#.##*.:....<<<<<< ###.........#####........##########.########:#.##..#...>>>>>>$ ##.....................*##.....................##..#..<<<<<<.. ..&###*..##..............#+##################.###*.#.>>>>>.... ..#####..##......#&........#..................##...#.<<<<....# ..&##O...#.....####....*####.###################*..#.>>>>...## ...............T##*....##.....................#....#.<<<....## #...........&..........#########.*.*.########.#O...#.>>>...O.# ####..................##.........#.#.....###..#.##.#........&# ..$.########........###..#########.####+####.##.##.#.......### #####......##########.&.##....O$&#.#..&.##*..#.....##....##... ......*###............###..#######.#.T..##..##.....##########+ .####....##############...*#...&O#.#...*&#O.#...##.....O##&... .&..####.....................#####.#..T..##.#...##............ ###T#&.#######################.....##.....#.#...*...##....*##. ..####.........................###..##....#.#.......##*....##. &....###########+###############.....###.&#.#..&##......##.... .#.O.#...#...&.......#&###.......###...##.#.#.T....*##....*... ...#...#...#...#...#.....####.####Z###..#.#.#.......##........ .#...#.&O#.*.#...#...#*.#Z#.#+#.......*.#.#.#&.........T....&. ..,#...#...#...#...#......#.............#O#+####...&......#### .#.&.#...#...#...#....&..##...#.........#+#.########.....####& ...#..Z#...#&..#..*...####.O..:.&.......#.:.#......O.......... .#...#...#...#.......##..#....:.........*.:.*Z................ &.......*.......######...##&..#::::::#....:.................## ####........#####.........###.............:.&.#::::::::::::::# #####################.......#......O......:............&...... #...................##......#.............#......Z............ ........*...$$...*...#......##.............................##. .........#......#....#.......########%######################## ............................##.............................##. ...##########...............#......O......:............&...... ............................##.............................##. ............................#.............#......Z............ ............................##.............................##. ............................##.............................##. ............................##.............................##. .............................########%######################## ............................##.............................##. ...open space............###########..:....................... ............................##.............................##. ........................##............:..Z.................... ............................##.............................##. ....fill it in!!.......##..############....................... ............................##.............................##. .......................#..##.................................. ............................##.............................##. ......................##...:.................................. .............................########%######################## .............................########%######################## ...##########...............#......O......:............&...... .............................########%######################## ............................#.............#......Z............ .............................########%######################## ............................##.............................##. .............................########%######################## .............................########%######################## .............................########%######################## ...open space............###########..:....................... .............................########%######################## ........................##............:..Z.................... .............................########%######################## ....fill it in!!.......##..############....................... .............................########%######################## .......................#..##.................................. .............................########%######################## ......................##...:.................................. ...open space............###########..:....................... ...open space............###########..:....................... ...##########...............#......O......:............&...... ...open space............###########..:....................... ............................#.............#......Z............

View File

@ -30,9 +30,26 @@ struc t_player
word oil
byte gold
byte key
byte raft
byte[32] name[32]
end
//
// ASCII Warrior
//
byte[] ascii_warrior
byte = " | "
byte = " T "
byte = " \\ () "
byte = " \\^ "
byte = " #\\_] "
byte = " # ] "
byte = " /\\ "
byte = " / \\ "
byte = " / / "
byte = " = = "
//
// Other monsters
//
@ -87,16 +104,16 @@ byte = "|%%//%%%/|"
byte = "<===|@___/"
byte[] ascii_rogue
byte = " | "
byte = " T "
byte = " \\ () "
byte = " \\^ "
byte = " #\\_] "
byte = " # ] "
byte = " /\\ "
byte = " "
byte = " \\ / "
byte = " < - - > "
byte = " ( \" ) "
byte = " \\VVV/ "
byte = " \\M/ "
byte = " ^^^^^^ "
byte = " / \\ "
byte = " / / "
byte = " = = "
byte = "( ) ^^>--="
byte = "( ) WW>--//"
word ascii_entity = @ascii_thief, @ascii_ogre, @ascii_zombie, @ascii_rogue
//
@ -104,9 +121,9 @@ word ascii_entity = @ascii_thief, @ascii_ogre, @ascii_zombie, @ascii_rogue
//
byte thief = "Thief", 5
byte ogre = "Ogre", 15
byte zombie = "Zombie", 25
byte rogue = "Rogue", 50
byte ogre = "Ogre", 20
byte zombie = "Zombie", 40
byte rogue = "Rogue", 80
export word entity = @thief, @ogre, @zombie, @rogue
export word entities = 0
@ -153,7 +170,7 @@ export def fight(player, enemy)
puts(@lifestr); puti(enemy->life)
for e_atck = 0 to 9
gotoxy(0, 10 + e_atck)
puts(@ascii_rogue + e_atck * 11)
puts(@ascii_warrior + e_atck * 11)
gotoxy(20, 10 + e_atck)
puts(ascii_entity[enemy->kind] + e_atck * 11)
next

View File

@ -19,7 +19,7 @@ import ROGUEIO
end
const FALSE = 0
const TRUE = not FALSE
const TRUE = 1
//
// Octant beam parameters
@ -124,6 +124,7 @@ const LOCKED_TILE = '%'
const WATER1_TILE = '>'
const WATER2_TILE = '<'
const KEY_TILE = ','
const RAFT_TILE = '@'
const GOLD_TILE = '$'
const FOOD_TILE = '&'
const ENTER_TILE = '-'
@ -134,30 +135,7 @@ const LIT_TILE = $80
const INV_TILE = $3F
const MAP_TILE = $7F
//byte[] map
//byte = "###############################"
//byte = "### .#[-]#.......#&.....O&..*#"
//byte = "## ..*...*...###T#.....####..#"
//byte = "## ...###.T...##.#...&...##..#"
//byte = "## ....###.&....#.#.......##..#"
//byte = "# .............#.+.......##..#"
//byte = "# T.....T.......#.#.T.....##..#"
//byte = "#......&#.....&.#.:.......##..#"
//byte = "#......###....###.:.......##..#"
//byte = "###.....#.....###.#......&##..#"
//byte = "##&.....*...#####.##:#:#:###..#"
//byte = "#######......####.#&........Z*#"
//byte = "####.O......#####.##*....######"
//byte = "##..........#####.##.....##[=]#"
//byte = "###....&#....&###.##.....#..R.#"
//byte = "##.....###...####.###....#$...#"
//byte = "###&...T#.....###.#&#....###%##"
//byte = "#,##....*....####.##.>>.##*..*#"
//byte = "#.######+########.##<<<..##...#"
//byte = "#...............&.##>>>>>..Z.&#"
//byte = "###############################"
byte catacomb = "CATACOMB"
byte catacomb = "LEVEL0"
word map, viewmap
const xcentr = 20
@ -183,10 +161,10 @@ word = @linebuffer, @linebuffer, @linebuffer, @linebuffer, @linebuffer
word = @linebuffer, @linebuffer, @linebuffer, @linebuffer, @linebuffer
//
// Load map
// Load map - levels 0 to 9
//
export def loadmap
export def loadmap(level)
byte mapref, row, l
//
@ -203,6 +181,10 @@ export def loadmap
map = heapalloc(mapsize)
fin
memset(map, mapsize, $2323) // Solid walls
//
// Set level map and read it
//
catacomb[catacomb] = '0' + level
mapref = open(@catacomb, O_READ)
if mapref
newline(mapref, $7F, $0D)
@ -211,7 +193,9 @@ export def loadmap
^(map + (row << 6) + l) = WALL_TILE
next
close(mapref)
return TRUE
fin
return FALSE
end
//
@ -262,6 +246,9 @@ export def lighttorches
next
fin
next
if not (ymap & 7)
putc('.')
fin
next
end
@ -358,7 +345,9 @@ export def drawmap(xorg, yorg, viewfield, viewdir, lightdist, viewdist)
// Update view
//
^(viewmap + imap) = tile | VIEWED_TILE
if tile <> PIT_TILE
screen.[ycentr-ybeam[l], xcentr+xbeam[l]] = tile & INV_TILE
fin
else
vispix[l] = 0
fin
@ -430,7 +419,9 @@ export def drawmap(xorg, yorg, viewfield, viewdir, lightdist, viewdist)
fin
fin
^(viewmap + imap) = tile | VIEWED_TILE
if tile <> PIT_TILE
screen.[ycentr-xbeam[l], xcentr+ybeam[l]] = tile & INV_TILE
fin
else
vispix[l] = 0
fin
@ -478,7 +469,9 @@ export def drawmap(xorg, yorg, viewfield, viewdir, lightdist, viewdist)
fin
fin
^(viewmap + imap) = tile | VIEWED_TILE
if tile <> PIT_TILE
screen.[ycentr+xbeam[l], xcentr+ybeam[l]] = tile & INV_TILE
fin
else
vispix[l] = 0
fin
@ -526,7 +519,9 @@ export def drawmap(xorg, yorg, viewfield, viewdir, lightdist, viewdist)
fin
fin
^(viewmap + imap) = tile | VIEWED_TILE
if tile <> PIT_TILE
screen.[ycentr+ybeam[l], xcentr+xbeam[l]] = tile & INV_TILE
fin
else
vispix[l] = 0
fin
@ -574,7 +569,9 @@ export def drawmap(xorg, yorg, viewfield, viewdir, lightdist, viewdist)
fin
fin
^(viewmap + imap) = tile | VIEWED_TILE
if tile <> PIT_TILE
screen.[ycentr+ybeam[l], xcentr-xbeam[l]] = tile & INV_TILE
fin
else
vispix[l] = 0
fin
@ -622,7 +619,9 @@ export def drawmap(xorg, yorg, viewfield, viewdir, lightdist, viewdist)
fin
fin
^(viewmap + imap) = tile | VIEWED_TILE
if tile <> PIT_TILE
screen.[ycentr+xbeam[l], xcentr-ybeam[l]] = tile & INV_TILE
fin
else
vispix[l] = 0
fin
@ -670,7 +669,9 @@ export def drawmap(xorg, yorg, viewfield, viewdir, lightdist, viewdist)
fin
fin
^(viewmap + imap) = tile | VIEWED_TILE
if tile <> PIT_TILE
screen.[ycentr-xbeam[l], xcentr-ybeam[l]] = tile & INV_TILE
fin
else
vispix[l] = 0
fin
@ -718,7 +719,9 @@ export def drawmap(xorg, yorg, viewfield, viewdir, lightdist, viewdist)
fin
fin
^(viewmap + imap) = tile | VIEWED_TILE
if tile <> PIT_TILE
screen.[ycentr-ybeam[l], xcentr-xbeam[l]] = tile & INV_TILE
fin
else
vispix[l] = 0
fin

View File

@ -15,6 +15,7 @@ import ROGUEMAP
const mapsize = maprows*mapcols
const FLOOR_TILE = '.'
const WALL_TILE = '#'
const TORCH_TILE = '*'
const PIT_TILE = ' '
const DOOR_TILE = '+'
@ -22,6 +23,7 @@ import ROGUEMAP
const WATER1_TILE = '>'
const WATER2_TILE = '<'
const KEY_TILE = ','
const RAFT_TILE = '@'
const GOLD_TILE = '$'
const FOOD_TILE = '&'
const ENTER_TILE = '-'
@ -55,7 +57,8 @@ word xdir = 0, 1, 1, 1, 0, -1, -1, -1
word ydir = -1, -1, 0, 1, 1, 1, 0, -1
byte vplayer = '^', '\\', '>', '/', 'v', '\\', '<', '/'
byte totaldarkness = 0
byte level = 0
word free_entities
//
// Power-ups
//
@ -84,6 +87,7 @@ struc t_player
word oil
byte gold
byte key
byte raft
byte[16] name
end
@ -98,6 +102,7 @@ byte = 100 // energy
word = 500 // oil
byte = 0 // gold
byte = 0 // key
byte = 0 // raft
byte[16] = "Player"
predef moveplayer
@ -122,11 +127,12 @@ end
const statusline = 23
byte helthstr = "Helth:"
byte enrgystr = "Enrgy:"
byte helthstr = "Hlth:"
byte enrgystr = "NRG:"
byte oilstr = "Oil:"
byte goldstr = "Gold:"
byte goldstr = "Gld:"
byte keystr = "Key"
byte raftstr = "Flt"
//
// Messages
@ -134,11 +140,12 @@ byte keystr = "Key"
word instr
byte namestr = "\nGreetings Warrior,\n what is your name"
byte prepstr = "\nPrepare"
byte prepstr = "\nPrepare."
byte quitstr = "Are you sure you want to quit?"
byte youmadeitstr = "You made it out alive with $"
byte youdiedstr = "You perished inside the catacombs :-("
byte againstr = "\n\nPlay again by typing: +rogue\n"
//
// Utility functions
//
@ -171,6 +178,21 @@ def fall
next
end
def drown
word i
tone(10,20)
tone(10,1)
for i = 0 to 1000
next
tone(10,25)
tone(10,2)
for i = 0 to 1000
next
tone(10,30)
tone(10,3)
end
def groan
byte i
@ -187,15 +209,19 @@ def status
gotoxy(0, statusline)
puts(@helthstr)
puti(player.health)
gotoxy(10, statusline)
gotoxy(9, statusline)
puts(@enrgystr)
puti(player.energy)
gotoxy(20, statusline)
gotoxy(17, statusline)
puts(@oilstr)
puti(player:oil/10)
gotoxy(28, statusline)
gotoxy(25, statusline)
puts(@goldstr)
puti(player.gold)
if player.raft
gotoxy(32, statusline)
puts(@raftstr)
fin
if player.key
gotoxy(36, statusline)
puts(@keystr)
@ -211,16 +237,28 @@ end
//
def moveplayer(dir)
player.xpos = player.xpos + dir * xdir[player.angle]
player.ypos = player.ypos + dir * ydir[player.angle]
when getmaptile(player.xpos, player.ypos) & MAP_TILE
byte xmove, ymove
xmove = player.xpos + dir * xdir[player.angle]
ymove = player.ypos + dir * ydir[player.angle]
when getmaptile(xmove, ymove) & MAP_TILE
is PIT_TILE
fall
player.energy = 0
player.health = 0
break
is WATER1_TILE
is WATER2_TILE
if not player.raft
drown
player.energy = 0
player.health = 0
break
fin
is FLOOR_TILE
is TORCH_TILE
is KEY_TILE
is RAFT_TILE
is GOLD_TILE
is FOOD_TILE
if player.energy < 10
@ -229,10 +267,10 @@ def moveplayer(dir)
if player.energy
player.energy = player.energy - 1
fin
player.xpos = xmove
player.ypos = ymove
break
otherwise
player.xpos = player.xpos - dir * xdir[player.angle]
player.ypos = player.ypos - dir * ydir[player.angle]
ouch
wend
end
@ -507,12 +545,18 @@ def play
updtmaptile(player.xpos, player.ypos, FLOOR_TILE)
gotit
break
is RAFT_TILE
player.raft = 1
updtmaptile(player.xpos, player.ypos, FLOOR_TILE)
gotit
break
is GOLD_TILE
player.gold = player.gold + 1
updtmaptile(player.xpos, player.ypos, FLOOR_TILE)
gotit
break
is TORCH_TILE
if player.oil < 1000
player:oil = player:oil + TORCH_OIL
if player:oil > 1000
player:oil = 1000
@ -524,8 +568,10 @@ def play
next
next
gotit
fin
break
is FOOD_TILE
if player.health < 100 or player.energy < 100
player.health = player.health + MANA/2
if player.health > 100
player.health = 100
@ -537,6 +583,7 @@ def play
updtmaptile(player.xpos, player.ypos, FLOOR_TILE)
player.fov = 1
gotit
fin
break
wend
break
@ -573,24 +620,25 @@ def play
player:oil = 0
player.lamp = 0
fin
return TRUE
return player.health
end
//
// Main loop
//
loadmap
puts(@namestr)
instr = gets($BA)
if ^instr > 15
^instr = 15
fin
memcpy(@player.name, instr, ^instr + 1)
puts(@prepstr)
findentities
lighttorches
repeat
while loadmap(level)
puts(@prepstr)
free_entities = heapmark()
findentities
lighttorches
repeat
moveentities(player.lamp or getmaptile(player.xpos, player.ypos) & LIT_TILE))
totaldarkness = drawmap(player.xpos, player.ypos, player.fov, player.angle, player.lamp, maxview)
if not totaldarkness
@ -599,9 +647,17 @@ repeat
putc(vplayer[player.angle])
fin
status
until not play or player.health == 0
clearstatus
gotoxy(0, statusline)
until not play
heaprelease(free_entities)
entities = 0
player.key = 0
level = level + 1
clearstatus
gotoxy(0, statusline)
if player.health == 0
break
fin
loop
if player.health > 0
puts(@youmadeitstr)
puti(player.gold)

View File

@ -1758,8 +1758,10 @@ def editmode
if flags & insmode
splitline
else
openline(cursrow + 1)
cursdown
curscol = 0
cursx = 0
scrnleft = 0
redraw
fin
break

View File

@ -774,11 +774,11 @@ def allocalignheap(size, pow2, freeaddr)
return addr
end
def markheap
return heap//
return heap
end
def releaseheap(newheap)
heap = newheap//
return @newheap - heap//
heap = newheap
return @newheap - heap
end
def allocxheap(size)
word xaddr