So, I have started on my ATC project. I thought I'd document here my struggles, learning, and how I did it. I'm hoping it'll engage other BASIC programmers in discussion, and maybe you (yes, YOU!) will help me if you can see me getting stuck. Please remember this is primarily an exercise in improving and restoring my mind after a bump on the noggin. I'm fighting against some short term memory problems.
I'm using the Mac version 1.0 of Q-Emulator, and SuperBASIC on JS ROMS with TK2. I'm writing it to run at standard QL speeds, and to run at a consistent speed on faster hardware. So far, I have written out a table of some of the variables I need, and their valid ranges, and how I will auto-generate pseudo-random flight numbers, altitudes and speeds for various aircraft profiles. Next, I will work out a co-ordinate base for a local airport. I have chosen Bergstrom because it is local to me, and I know where all the beacons and VORs are. I have decided that there are "hard bits" (it's a technical term) in this project for me (I know to some of you, these will be trivial, but to me, the solution isn't obvious): 1. I'll be keeping the aircraft, their altitude, speed, direction, intended alt, speed and direction, etc, in a large DIMmed array that can hold 10 aircraft. Landed or departed aircraft will be removed from the array and any newer aircraft will be scrolled up one spot. Like in real life, the oldest aircraft is always at the top of the stack. There will be inbound and outbound aircraft. Inbound aircraft will be announced and placed at the edge of the screen, and outbound aircraft will originate from the runway when given flight instructions and clearance to take off. The aircraft must always maintain "separation" of 1000 feet altitude and 3 miles horizontally. Checking all the aircraft against each other to see if any violate airspace of others, or have collided, might be hard to code. 2. I need to write a command parser to accept input from the user, namely instruction for flights. There is a standard way of doing this and I will follow this. This means I need to accept input and add it to a stack, then when it is "entered" I need to parse it to ensure valid, rational input. Once I know it is within bounds, I need to carry out the action, i.e. instruct the aircraft to follow the instruction. 3. I need to write routines for landing aircraft. Once instructed to land, I need to detect when they cross the glide-slope, and get them to follow it to landing, land, then remove themselves from the stack. 4. I need to write a "ticker"... No matter the speed of the hardware, the game should run at the same speed. This means events should be triggered at an interval, complete (even on the slowest hardware) before the next interval. This interval should ideally be 1 second, but could be 2 seconds. Despite the ticker, the input routines need to continue unaffected. Responsiveness of keyboard input is essential. 5. I need to plot this on a 512x256 screen. I can't let flights go off the edge of the screen. 6. I need to detect valid landings of arrivals and proper exits of departures. 7. I'd like to add an element of realism where planes, including departures, can declare emergencies. Well, those are the "hard bits" I can see up front. I can foresee earning a little money next week, so maybe a compiler will be in my future? I'd prefer an easy compiler over a good compiler. I would also love to have an external USB floppy so I could save my stuff somewhere other than my OS X HD... Maybe later... In the mean time, I'll work on this and keep sharing. Hopefully it'll work out. Dave _______________________________________________ QL-Users Mailing List http://www.q-v-d.demon.co.uk/smsqe.htm
