1: 2: logic 3: { 4: int NO { 0 } 5: int YES { 1 } 6: 7: int FLOOR { 0 } 8: int PLAYER { 1 } 9: int WALL_HORIZ { 2 } 10: int WALL_VERT { 3 } 11: int ROCK { 4 } 12: int GOBLIN { 5 } 13: array map { 2,2,2,2,2,2,2,2,2,2,2,2, 14: 3,0,0,0,0,0,0,0,0,0,0,3, 15: 3,0,0,0,0,0,0,0,0,0,0,3, 16: 3,0,0,0,0,0,0,0,0,0,0,3, 17: 3,0,0,0,0,0,0,0,0,2,2,3, 18: 3,0,0,0,0,0,0,0,0,5,0,3, 19: 3,0,0,0,0,0,0,0,0,2,2,3, 20: 3,0,0,1,0,0,0,0,0,0,0,3, 21: 3,0,0,0,0,0,0,0,0,0,0,3, 22: 2,2,2,2,2,2,2,2,2,2,2,2, } 23: 24: int mapheight { 10 } 25: int mapwidth { 12 } 26: int player_x { 3 } 27: int player_y { 7 } 28: int hp { 4 } 29: int lose { 0 } 30: array msg_info { 0 } 31: array msg_combat { 0,0,0,0,0,0,0,0 } 32: int comb_parts { 8 } 33: array msg_surr { 0 } 34: 35: when 36: { 37: (lose == NO) and 38: (map[(player_y - 1)*mapwidth + (player_x - 1)] == FLOOR) 39: } 40: allow 41: { 42: map[(player_y)*mapwidth + player_x] = FLOOR; 43: player_x--; 44: player_y--; 45: map[(player_y)*mapwidth + player_x] = PLAYER; 46: 47: for ii ( 0 .. comb_parts - 1) 48: { 49: msg_combat[ii] = 0; 50: } 51: } 52: label { "Move NW" } 53: when 54: { 55: (lose == NO) and 56: (map[(player_y - 1)*mapwidth + player_x] == FLOOR) 57: } 58: allow 59: { 60: map[(player_y)*mapwidth + player_x] = FLOOR; 61: player_y--; 62: map[(player_y)*mapwidth + player_x] = PLAYER; 63: for ii ( 0 .. comb_parts - 1) 64: { 65: msg_combat[ii] = 0; 66: } 67: } 68: label { "Move N" } 69: when 70: { 71: (lose == NO) and 72: (map[(player_y - 1)*mapwidth + (player_x + 1)] == FLOOR) 73: } 74: allow 75: { 76: map[(player_y)*mapwidth + player_x] = FLOOR; 77: player_x++; 78: player_y--; 79: map[(player_y)*mapwidth + player_x] = PLAYER; 80: for ii ( 0 .. comb_parts - 1) 81: { 82: msg_combat[ii] = 0; 83: } 84: } 85: label { "Move NE" } 86: when 87: { 88: (lose == NO) and 89: (map[(player_y)*mapwidth + (player_x - 1)] == FLOOR) 90: } 91: allow 92: { 93: map[(player_y)*mapwidth + player_x] = FLOOR; 94: player_x--; 95: map[(player_y)*mapwidth + player_x] = PLAYER; 96: for ii ( 0 .. comb_parts - 1) 97: { 98: msg_combat[ii] = 0; 99: } 100: } 101: label { "Move W" } 102: when 103: { 104: lose == NO 105: } 106: allow 107: { 108: FLOOR = FLOOR; 109: for ii ( 0 .. comb_parts - 1) 110: { 111: msg_combat[ii] = 0; 112: } 113: } 114: label { "Stay still" } 115: when 116: { 117: (lose == NO) and 118: (map[(player_y)*mapwidth + (player_x + 1)] == FLOOR) 119: } 120: allow 121: { 122: map[(player_y)*mapwidth + player_x] = FLOOR; 123: player_x++; 124: map[(player_y)*mapwidth + player_x] = PLAYER; 125: for ii ( 0 .. comb_parts - 1) 126: { 127: msg_combat[ii] = 0; 128: } 129: } 130: label { "Move E" } 131: 132: when 133: { 134: (lose == NO) and 135: (map[(player_y + 1)*mapwidth + (player_x - 1)] == FLOOR) 136: } 137: allow 138: { 139: map[(player_y)*mapwidth + player_x] = FLOOR; 140: player_x--; 141: player_y++; 142: map[(player_y)*mapwidth + player_x] = PLAYER; 143: for ii ( 0 .. comb_parts - 1) 144: { 145: msg_combat[ii] = 0; 146: } 147: } 148: label { "Move SW" } 149: when 150: { 151: (lose == NO) and 152: (map[(player_y + 1)*mapwidth + player_x] == FLOOR) 153: } 154: allow 155: { 156: map[(player_y)*mapwidth + player_x] = FLOOR; 157: player_y++; 158: map[(player_y)*mapwidth + player_x] = PLAYER; 159: for ii ( 0 .. comb_parts - 1) 160: { 161: msg_combat[ii] = 0; 162: } 163: } 164: label { "Move S" } 165: when 166: { 167: (lose == NO) and 168: (map[(player_y + 1)*mapwidth + (player_x + 1)] == FLOOR) 169: } 170: allow 171: { 172: map[(player_y)*mapwidth + player_x] = FLOOR; 173: player_x++; 174: player_y++; 175: map[(player_y)*mapwidth + player_x] = PLAYER; 176: for ii ( 0 .. comb_parts - 1) 177: { 178: msg_combat[ii] = 0; 179: } 180: } 181: label { "Move SE" } 182: 183: when 184: { 185: (lose == NO) and 186: (map[(player_y - 1)*mapwidth + (player_x - 1)] == GOBLIN) 187: } 188: allow 189: { 190: hp--; 191: msg_combat[0] = 2; 192: msg_combat[1] = 7; 193: msg_combat[2] = 4; 194: msg_combat[3] = 7; 195: msg_combat[4] = 1; 196: msg_combat[5] = 8; 197: if (hp == 0) 198: { 199: lose = YES; 200: msg_info[0] = 1; 201: } 202: } 203: label { "Attack from NW" } 204: when 205: { 206: (lose == NO) and 207: (map[(player_y - 1)*mapwidth + (player_x)] == GOBLIN) 208: } 209: allow 210: { 211: hp--; 212: msg_combat[0] = 2; 213: msg_combat[1] = 7; 214: msg_combat[2] = 4; 215: msg_combat[3] = 7; 216: msg_combat[4] = 1; 217: msg_combat[5] = 8; 218: if (hp == 0) 219: { 220: lose = YES; 221: msg_info[0] = 1; 222: } 223: } 224: label { "Attack from N" } 225: when 226: { 227: (lose == NO) and 228: (map[(player_y - 1)*mapwidth + (player_x + 1)] == GOBLIN) 229: } 230: allow 231: { 232: hp--; 233: msg_combat[0] = 2; 234: msg_combat[1] = 7; 235: msg_combat[2] = 4; 236: msg_combat[3] = 7; 237: msg_combat[4] = 1; 238: msg_combat[5] = 8; 239: if (hp == 0) 240: { 241: lose = YES; 242: msg_info[0] = 1; 243: } 244: } 245: label { "Attack from NE" } 246: when 247: { 248: (lose == NO) and 249: (map[(player_y)*mapwidth + (player_x - 1)] == GOBLIN) 250: } 251: allow 252: { 253: hp--; 254: msg_combat[0] = 2; 255: msg_combat[1] = 7; 256: msg_combat[2] = 4; 257: msg_combat[3] = 7; 258: msg_combat[4] = 1; 259: msg_combat[5] = 8; 260: if (hp == 0) 261: { 262: lose = YES; 263: msg_info[0] = 1; 264: } 265: } 266: label { "Attack from W" } 267: when 268: { 269: (lose == NO) and 270: (map[(player_y)*mapwidth + (player_x + 1)] == GOBLIN) 271: } 272: allow 273: { 274: hp--; 275: msg_combat[0] = 2; 276: msg_combat[1] = 7; 277: msg_combat[2] = 4; 278: msg_combat[3] = 7; 279: msg_combat[4] = 1; 280: msg_combat[5] = 8; 281: if (hp == 0) 282: { 283: lose = YES; 284: msg_info[0] = 1; 285: } 286: } 287: label { "Attack from E" } 288: when 289: { 290: (lose == NO) and 291: (map[(player_y + 1)*mapwidth + (player_x - 1)] == GOBLIN) 292: } 293: allow 294: { 295: hp--; 296: msg_combat[0] = 2; 297: msg_combat[1] = 7; 298: msg_combat[2] = 4; 299: msg_combat[3] = 7; 300: msg_combat[4] = 1; 301: msg_combat[5] = 8; 302: if (hp == 0) 303: { 304: lose = YES; 305: msg_info[0] = 1; 306: } 307: } 308: label { "Attack from SW" } 309: when 310: { 311: (lose == NO) and 312: (map[(player_y + 1)*mapwidth + (player_x)] == GOBLIN) 313: } 314: allow 315: { 316: hp--; 317: msg_combat[0] = 2; 318: msg_combat[1] = 7; 319: msg_combat[2] = 4; 320: msg_combat[3] = 7; 321: msg_combat[4] = 1; 322: msg_combat[5] = 8; 323: if (hp == 0) 324: { 325: lose = YES; 326: msg_info[0] = 1; 327: } 328: } 329: label { "Attack from S" } 330: when 331: { 332: (lose == NO) and 333: (map[(player_y + 1)*mapwidth + (player_x + 1)] == GOBLIN) 334: } 335: allow 336: { 337: hp--; 338: msg_combat[0] = 2; 339: msg_combat[1] = 7; 340: msg_combat[2] = 4; 341: msg_combat[3] = 7; 342: msg_combat[4] = 1; 343: msg_combat[5] = 8; 344: if (hp == 0) 345: { 346: lose = YES; 347: msg_info[0] = 1; 348: } 349: } 350: label { "Attack from SE" } 351: } 352: 353: display 354: { 355: stringtable glyphs {".", "@", "—", "|", "#", "g"} 356: stringtable info { "Welcome. Your dungeon is being prepared. Mind the Goblin, he's cranky.", "You die" } 357: stringtable combat { " ", "you", "the goblin", "hit", "hits", "miss", "misses", " ", "." } 358: 359: box {content {"Rogue-Hack"}} 360: 361: newline 362: 363: // Draw the grid 364: for y ( 0 .. (mapheight-1) ) 365: { 366: for x ( 0 .. (mapwidth-1) ) 367: { 368: box 369: { 370: width { 1em } 371: height { 1em } 372: content { glyphs[ map[(y*mapwidth)+x] ] } 373: } 374: } 375: newline 376: } 377: 378: newline 379: 380: // Information 381: box 382: { 383: width { 3em } 384: height { 1em } 385: content { "HP: " hp } 386: } 387: 388: newline 389: 390: // Controls 391: box 392: { 393: width { 2em } 394: height { 2em } 395: border { 1px solid black } 396: content { "↖" } 397: bind_action { "Move NW" } 398: bind_action { "Attack from N" } 399: bind_action { "Attack from W" } 400: bind_action { "Attack from NW" } 401: } 402: box 403: { 404: width { 2em } 405: height { 2em } 406: border { 1px solid black } 407: content { "↑" } 408: bind_action { "Move N" } 409: bind_action { "Attack from NW" } 410: bind_action { "Attack from N" } 411: bind_action { "Attack from NE" } 412: bind_action { "Attack from W" } 413: bind_action { "Attack from E" } 414: } 415: box 416: { 417: width { 2em } 418: height { 2em } 419: border { 1px solid black } 420: content { "↗" } 421: bind_action { "Move NE" } 422: bind_action { "Attack from N" } 423: bind_action { "Attack from E" } 424: bind_action { "Attack from NE" } 425: } 426: 427: newline 428: 429: box 430: { 431: width { 2em } 432: height { 2em } 433: border { 1px solid black } 434: content { "←" } 435: bind_action { "Move W" } 436: bind_action { "Attack from NW" } 437: bind_action { "Attack from N" } 438: bind_action { "Attack from W" } 439: bind_action { "Attack from SW" } 440: bind_action { "Attack from S" } 441: } 442: box 443: { 444: width { 2em } 445: height { 2em } 446: border { 1px solid black } 447: content { "X" } 448: bind_action { "Stay still" } 449: bind_action { "Attack from NW" } 450: bind_action { "Attack from N" } 451: bind_action { "Attack from NE" } 452: bind_action { "Attack from W" } 453: bind_action { "Attack from E" } 454: bind_action { "Attack from SW" } 455: bind_action { "Attack from S" } 456: bind_action { "Attack from SE" } 457: } 458: box 459: { 460: width { 2em } 461: height { 2em } 462: border { 1px solid black } 463: content { "→" } 464: bind_action { "Move E" } 465: bind_action { "Attack from NE" } 466: bind_action { "Attack from N" } 467: bind_action { "Attack from E" } 468: bind_action { "Attack from SE" } 469: bind_action { "Attack from S" } 470: } 471: 472: newline 473: 474: box 475: { 476: width { 2em } 477: height { 2em } 478: border { 1px solid black } 479: content { "↙" } 480: bind_action { "Move SW" } 481: bind_action { "Attack from S" } 482: bind_action { "Attack from W" } 483: bind_action { "Attack from SW" } 484: } 485: box 486: { 487: width { 2em } 488: height { 2em } 489: border { 1px solid black } 490: content { "↓" } 491: bind_action { "Move S" } 492: bind_action { "Attack from SW" } 493: bind_action { "Attack from S" } 494: bind_action { "Attack from SE" } 495: bind_action { "Attack from W" } 496: bind_action { "Attack from E" } 497: } 498: box 499: { 500: width { 2em } 501: height { 2em } 502: border { 1px solid black } 503: content { "↘" } 504: bind_action { "Move SE" } 505: bind_action { "Attack from S" } 506: bind_action { "Attack from E" } 507: bind_action { "Attack from SE" } 508: } 509: 510: newline 511: box 512: { 513: content{ info[msg_info[0]] } 514: } 515: newline 516: box 517: { 518: content{ combat[msg_combat[0]] combat[msg_combat[1]] combat[msg_combat[2]] combat[msg_combat[3]] combat[msg_combat[4]] combat[msg_combat[5]] combat[msg_combat[6]] combat[msg_combat[7]] } 519: } 520: }