1: 2: logic 3: { 4: // ~~~~~~~ Initial map layout 5: // 0 = floor 6: // 1 = wall 7: // 2 = player 8: 9: array map 10: { 11: 1, 1, 1, 1, 1, 1, 1, 1, 1, 12: 1, 0, 0, 0, 0, 0, 2, 0, 1, 13: 1, 0, 0, 0, 0, 0, 0, 0, 1, 14: 1, 0, 0, 0, 0, 1, 0, 0, 1, 15: 1, 0, 0, 0, 0, 1, 0, 0, 1, 16: 1, 0, 0, 1, 1, 1, 1, 1, 1, 17: 1, 0, 0, 0, 0, 0, 0, 0, 1, 18: 1, 0, 0, 0, 0, 0, 0, 0, 1, 19: 1, 1, 1, 1, 1, 1, 1, 1, 1 20: } 21: int mapwidth { 9 } 22: int mapheight { 9 } 23: 24: // Denote the current location of the player 25: // This should be set automatically, but I don't want to deal with an 26: // initialisation step at this point 27: int location { 15 } 28: 29: // Allow the four movement actions when it is safe to move that way 30: when { (map[location-1] == 0) } 31: allow 32: { 33: map[location-1] = map[location]; 34: map[location] = 0; 35: location = location - 1; 36: } 37: label { "key_a" } 38: 39: when { (map[location+1] == 0) } 40: allow 41: { 42: map[location+1] = map[location]; 43: map[location] = 0; 44: location = location + 1; 45: } 46: label { "key_d" } 47: 48: when { (map[location+mapwidth] == 0) } 49: allow 50: { 51: map[location+mapwidth] = map[location]; 52: map[location] = 0; 53: location = location + mapwidth; 54: } 55: label { "key_s" } 56: 57: when { (map[location-mapwidth] == 0) } 58: allow 59: { 60: map[location-mapwidth] = map[location]; 61: map[location] = 0; 62: location = location - mapwidth; 63: } 64: label { "key_w" } 65: } 66: 67: display 68: { 69: stringtable counters {".", "#", "@"} 70: 71: box {content {"Pseudo-Doom"}} 72: 73: newline 74: 75: // Draw the grid 76: for y ( 0 .. (mapheight-1) ) 77: { 78: for x ( 0 .. (mapwidth-1) ) 79: { 80: box 81: { 82: width { 1.1em } 83: height { 1em } 84: content { counters[ map[(y*mapwidth)+x] ] } 85: } 86: } 87: newline 88: } 89: 90: newline 91: 92: // Controls 93: box 94: { 95: width { 2em } 96: height { 1em } 97: border { 1px solid black } 98: content { "q" } 99: bind_action { "key_q" } 100: } 101: box 102: { 103: width { 2em } 104: height { 1em } 105: border { 1px solid black } 106: content { "w" } 107: bind_action { "key_w" } 108: } 109: box 110: { 111: width { 2em } 112: height { 1em } 113: border { 1px solid black } 114: content { "e" } 115: bind_action { "key_e" } 116: } 117: 118: newline 119: 120: box //Spacer for that Authentic Keyboard Look (TM) 121: { 122: width { 0.6em } 123: height { 1em } 124: } 125: box 126: { 127: width { 2em } 128: height { 1em } 129: border { 1px solid black } 130: content { "a" } 131: bind_action { "key_a" } 132: } 133: box 134: { 135: width { 2em } 136: height { 1em } 137: border { 1px solid black } 138: content { "s" } 139: bind_action { "key_s" } 140: } 141: box 142: { 143: width { 2em } 144: height { 1em } 145: border { 1px solid black } 146: content { "d" } 147: bind_action { "key_d" } 148: } 149: 150: newline 151: 152: box 153: { 154: content{ "WASD... Now all we need is 3D and we'll have Quake in no time..." } 155: } 156: }